Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapping scATAC-seq data with precomputated UMAP #139

Open
ccshao opened this issue May 25, 2022 · 0 comments
Open

mapping scATAC-seq data with precomputated UMAP #139

ccshao opened this issue May 25, 2022 · 0 comments

Comments

@ccshao
Copy link

ccshao commented May 25, 2022

First thanks for the nice tool!

I was trying to mapping two scATAC-seq data, eg, ko to wt, with stream v1.0

In both datasets I used the precomputated UMAP projections. The codes for wt is shown bellow, in which the steps on add umap were taken from #100 (comment).

import stream as st
import pandas as pd

st.__version__

st.set_figure_params(dpi=300,
                     style='white',
                     figsize=[5.4, 4.8],
                     rc={'image.cmap': 'viridis'})

adata = st.read(file_name='wt_counts.tsv.gz', workdir='./result_atac')
st.add_cell_labels(adata, file_name='wt_cell_label.tsv')
st.add_cell_colors(adata, file_name='wt_cell_label_col.tsv')

st.cal_qc(adata, assay='atac')
st.normalize(adata, method='tf_idf')
st.select_top_principal_components(adata, first_pc=False, n_pc=50, save_fig=True)

#- Precompuated umap.
umap_res = pd.read_csv("wt_umap.csv", sep="\t")

adata.obsm['X_dr'] = umap_res.to_numpy()
adata.obsm['X_vis_umap'] = umap_res.to_numpy()

st.plot_visualization_2D(adata,
                         n_neighbors=100,
                         color=['label'],
                         use_precomputed=True,
                         save_fig=True)

st.seed_elastic_principal_graph(adata, n_clusters=3, use_vis=True)
st.elastic_principal_graph(adata, epg_alpha=0.05)

However, when trying to align ko to wt:

adata_wt = st.read(file_name='CR_wt_atac_peaks.pkl')
adata_ko = st.read(file_name='CR_ko_atac_peaks.pkl')
adata_all = st.map_new_data(adata_wt, adata_ko)

Got the error:

Traceback (most recent call last):
File "", line 1, in
File "/home/shao/miniconda3/envs/env_stream/lib/python3.7/site-packages/stream/core.py", line 4040, in map_new_data
feature = adata_ref.uns['params']['dimension_reduction']['feature']
KeyError: 'dimension_reduction'

In the source, I saw there is an transform step.

    if(method == 'umap'):
        if('trans_umap' in adata_ref.uns_keys()):
            trans = adata_ref.uns['trans_umap']
            adata_new.obsm['X_umap_mapping'] = trans.transform(input_data)
            adata_new.obsm['X_dr'] = adata_new.obsm['X_umap_mapping'].copy()
        else:
            raise Exception("Please run 'st.dimension_reduction()' using 'umap' first.")  

As I am using the precompuated umap, how could I instruct stream to use that projection?

Thanks and I am happy to provide more details if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant