-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample_mESC.py
44 lines (28 loc) · 1.01 KB
/
example_mESC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# coding: utf-8
import sys
import pandas as pd
import numpy as np
import pickle as pkl
import sklearn as skl
import sklearn.preprocessing
import matplotlib as mpl
import matplotlib.pyplot as plt
import cyclum
from cyclum import writer
input_file_mask = 'data/mESC/mesc-tpm'
output_file_mask = './results/mESC_original/mesc-tpm'
# ## Read data
# Here we have label, so we load both. However, the label is not used until evaluation.
# In[5]:
def preprocess(input_file_mask):
"""
Read in data and perform log transform (log2(x+1)), centering (mean = 1) and scaling (sd = 1).
"""
tpm = writer.read_df_from_binary(input_file_mask).T
sttpm = pd.DataFrame(data=skl.preprocessing.scale(np.log2(tpm.values + 1)), index=tpm.index, columns=tpm.columns)
label = pd.read_csv(input_file_mask + '-label.txt', sep="\t", index_col=0).T
return sttpm, label
sttpm, label = preprocess(input_file_mask)
model = cyclum.core.PreloadCyclum2(sttpm.values)
pseudotime, rotation = model.train()