Datasets can be downloaded from https://www.dropbox.com/sh/e3z9hzgoefpntjm/AADYmowe_-aF-C2dWJxp9q-xa?dl=0
Ref: Paul, F. et al. Transcriptional Heterogeneity and Lineage Commitment in Myeloid Progenitors. Cell 163, 1663-1677 (2015).

In [1]:
%matplotlib inline
In [2]:
import stream as st
st.__version__
Out[2]:
'0.3.5'
In [3]:
adata=st.read(file_name='data_paul.tsv.gz',file_path='./',workdir='./stream_result_high_dim/')
Saving results in: ./stream_result_high_dim/
In [4]:
st.add_cell_labels(adata,file_name='cell_label2.tsv.gz',file_path='./')
st.add_cell_colors(adata,file_name='cell_label2_color.tsv.gz',file_path='./')
In [5]:
adata
Out[5]:
AnnData object with n_obs × n_vars = 2699 × 3004 
    obs: 'label', 'label_color'
    uns: 'experiment', 'workdir', 'label_color'
In [6]:
st.normalize_per_cell(adata)
st.log_transform(adata)
st.remove_mt_genes(adata)
In [7]:
st.select_variable_genes(adata,loess_frac=0.01,n_genes=500)
500 variable genes are selected
In [8]:
st.dimension_reduction(adata,n_components=10,nb_pct=0.025)
44 cpus are being used ...
In [9]:
st.plot_dimension_reduction(adata,n_components=2)
In [10]:
st.plot_visualization_2D(adata,use_precomputed=False)
In [ ]:
 

switch to low dimensional space

In [11]:
adata_low = st.switch_to_low_dimension(adata,n_components=2)
In [12]:
st.plot_dimension_reduction(adata_low,n_components=2)
In [13]:
st.plot_visualization_2D(adata_low,use_precomputed=False)
In [14]:
st.seed_elastic_principal_graph(adata_low,damping=0.9)
Seeding initial elastic principal graph...
Clustering...
Affinity propagation ...
The number of initial nodes is 18
Calculatng minimum spanning tree...
Number of initial branches: 4
In [15]:
st.plot_branches(adata_low,n_components=2)
st.plot_branches_with_cells(adata_low,n_components=2)
In [16]:
st.elastic_principal_graph(adata_low)
Learning elastic principal graph...
[1]
 "Constructing tree 1 of 1 / Subset 1 of 1"


[1]
 "Computing EPG with 50 nodes on 2699 points and 2 dimensions"


[1]
 "Using a single core"


Nodes = 
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
 
45
 
46
 
47
 
48
 
49
 


BARCODE	ENERGY	NNODES	NEDGES	NRIBS	NSTARS	NRAYS	NRAYS2	MSE	MSEP	FVE	FVEP	UE	UR	URN	URN2	URSD

1||50
	
1.225e-05
	
50
	
49
	
46
	
1
	
0
	
0
	
5.025e-06
	
4.528e-06
	
0.9932
	
0.9939
	
6.755e-06
	
4.661e-07
	
2.33e-05
	
0.001165
	
0


147.082 sec elapsed

[[1]]



Number of branches after learning elastic principal graph: 3
In [17]:
st.plot_branches(adata_low,n_components=2)
st.plot_branches_with_cells(adata_low,n_components=2)
In [18]:
st.subwaymap_plot(adata_low,root='S0',percentile_dist=100)
In [ ]:
 

switch back to high dimensional space

In [19]:
init_nodes_pos,init_edges = st.infer_initial_structure(adata_low)
Node 12 is calculated using 5nearest neighbor cells
In [20]:
st.seed_elastic_principal_graph(adata,init_nodes_pos=init_nodes_pos,init_edges=init_edges)
Seeding initial elastic principal graph...
Setting initial nodes...
The number of initial nodes is 50
Setting initial edges...
Number of initial branches: 3
In [21]:
st.plot_branches(adata,n_components=2)
st.plot_branches_with_cells(adata,n_components=2)