STREAM icon indicating copy to clipboard operation
STREAM copied to clipboard

Mapping KO data to trajectory built from WT data

Open leiliuC opened this issue 4 years ago • 6 comments

Hi, I have scRNA-seq data from two conditions: WT and KO. I would like to build a trajectory based on WT data and then map KO data to the WT trajectory as you have illustrated in your mapping function tutorial. However, despite the successful mapping step: st.map_new_data(adata,adata_new, method="mlle") I was not able to visualize the results in any plots following the tutorial, e.g. st.plot_visualization_2D(adata,adata_new=adata_new,nb_pct=0.8,use_precomputed=False) I got the same error message:

Traceback (most recent call last): File "", line 1, in File "/home/lei/bin/current/miniconda2/envs/myenv/lib/python3.7/site-packages/stream/core.py", line 2232, in subwaymap_plot if(adata_new!=None): File "/home/lei/bin/current/miniconda2/envs/myenv/lib/python3.7/site-packages/anndata/_core/anndata.py", line 544, in eq "Equality comparisons are not supported for AnnData objects, " NotImplementedError: Equality comparisons are not supported for AnnData objects, instead compare the desired attributes.

I wonder if you could give me some suggestions to solve this problem. Greetings, Lei

leiliuC avatar Mar 03 '20 09:03 leiliuC

could you share with me the parameters you are using in the function st.dimension_reduction when building the reference trajectory?

The current tutorial for mapping is a bit outdated (it's based on v0.3.5). Some default settings have been changed since v4.0. In order to reproduce the tutorial, for the step, st.dimension_reduction, you need to explicitly specify st.dimension_reduction(adata,method='mlle',nb_pct=0.1)

But thanks for reporting this. We will update our tutorial for mapping soon.

huidongchen avatar Mar 03 '20 16:03 huidongchen

This is the parameter that I used for dimension reduction: st.dimension_reduction(adata, n_neighbors=100,n_components=3,n_jobs=40, method='mlle') I initially used default method='se' and I figured out that it is not compatible with mapping function, but it was not clear or mentioned in the tutorial. I will try your suggestion tomorrow and let you know.

Thanks for developing STREAM, it is a great tool to illustrate cell lineage and gene expression changes along the lineage. Another question, is it possible to have multiple cell labels and colors. e.g. I would like to make a stream plot with either color by sample condition or color by cell type.

leiliuC avatar Mar 03 '20 20:03 leiliuC

Your current parameter setting looks fine to me, i.e. you are using the same feature and dimension reduction method for the mapping. So I don't think it's necessary to try my suggestion. Now i'm a bit puzzled about the error.. I saw a previous issue #61 related to this error too but unfortunately I haven't been able to reproduce it yet..

I figured out that it is not compatible with mapping function, but it was not clear or mentioned in the tutorial

Sorry about the confusion. Yeah, I have updated the mapping part by adding more detailed and intuitive exception handling. It will be available in the upcoming version.

Another question, is it possible to have multiple cell labels and colors. e.g. I would like to make a stream plot with either color by sample condition or color by cell type.

The easiest way to achieve it would be : st.add_cell_labels(adata,file_name='./your_new_cell_label.tsv') st.add_cell_colors(adata,file_name='./your_new_cell_label_color.tsv')

or simply: st.add_cell_labels(adata,file_name='./your_new_cell_label.tsv') st.add_cell_colors(adata)

or if you have your metadata dataframe, adata.obs['label'] = yourmetadata['condition'] st.add_cell_colors(adata)

This will update the current labels.

I will add explicit illustration of these steps as well in the next version.

huidongchen avatar Mar 03 '20 21:03 huidongchen

I really like your stream gene plot, I wonder if it is possible to display the gene expression with only selected cells. For example, if I built trajectory using both KO and WT cells, but I would like to show gene expression only in KO or WT cells using stream plot, how can I achieve that?

leiliuC avatar Mar 03 '20 22:03 leiliuC

I have found out how to plot the gene expression with selected conditions: adata_df_wt = adata[adata.obs.label == 'WT' ].copy() st.stream_plot(adata_df_wt, root='S3',factor_min_win=1.0,factor_num_win=10,flag_log_view=True,factor_width=2,fig_legend_ncol=5,fig_size=(8,8), fig_name='stream_plot_wt.pdf',save_fig=True, fig_path=out_path)

leiliuC avatar Mar 04 '20 11:03 leiliuC

@leiliuC @huidongchen do you have updates on the error "Equality comparisons are not supported for AnnData objects..."?

My codes used to work fine (stream, 0.3.9; anndata, 0.6.22.post1 ) but failed now with the latest anndata (stream 0.3.9; anndata, 0.7.1). Thanks for looking into this.

It seems there is a new attr "_eq" added to anndata "_core" four months ago, might be relevent? https://github.com/theislab/anndata/blame/9e0767b7611fd3c784303dd60e5ebf3070825adf/anndata/_core/anndata.py

ccshao avatar Apr 21 '20 11:04 ccshao