Coder Social home page Coder Social logo

Comments (5)

gaddamshreya avatar gaddamshreya commented on June 7, 2024 2

Hi @daixinap,

Thank you for your interest in Tangram! We're glad you like it! You should be able to map snATAC-seq with spatial data as follows:

  • Compute mapping anndata using RNA-seq data and spatial data, once you pre-process both data like in the tutorial:
ad_map = tg.map_cells_to_space(
        adata_sc=ad_sc, #scRNA-seq
        adata_sp=ad_sp, #spatial data 
        device='cuda:0',
    )
  • To visualize spatial patterns of chromatin accessibility with respect to cell types, you can do:
#use cell type label name in your data as annotation to project annotations 
tg.project_cell_annotations(ad_map, ad_sp, annotation='cell-type_label')
annotation_list = list(pd.unique(ad_atac.obs['cell-type_label'])) 
tg.plot_cell_annotation_sc(ad_sp, annotation_list,x='x', y='y',spot_size= 60, perc=0.001)

Let me know if this solution helped solve your issue! I'd be happy to help otherwise.

Edit: Added changes per suggestions below i.e., align with RNA-Seq data and project ATAC-seq data over space.

from tangram.

daixinap avatar daixinap commented on June 7, 2024

Hi @gaddamshreya,

Thanks very much for your prompt reply! I downloaded the multimodal scATAC-seq data to map and the result is very great. Since there is no annotated information, I have drawn some specific transcription factors (chromatin accessibility and motif scores). I would like to know why you only emphasize the use of multimodal data (SHARE-seq) in your published paper. I think scATAC-seq data can be used to map even if there is no corresponding scRNA-seq data.
Your kind help and swift reply is highly appreciated.

image
image
image

from tangram.

lewlin avatar lewlin commented on June 7, 2024

Mh - I am a bit confused about what is happening.

When you map, you don't want to align the single cell ATAC-seq data with the spatial RNA data, because the signals are different. What Tangram does, is to align data from the same modality, for example, RNA from single cells with RNA on the spatial data.

If your single cell data are multi-modal (like SHARE-seq, where you measure RNA and ATAC), once you map RNA using map_cell_to_space you can then transfer the other mode (eg ATAC) to space using project_cell_annotations.

I am not exactly sure what your figures are showing (even though the look pretty :)): it is possible that you are visualizing gene expression. If you walk me through your example by pasting code, I'll help.

from tangram.

daixinap avatar daixinap commented on June 7, 2024

Hi @lewlin @gaddamshreya

Thank you for your prompt reply. According to gaddamshreya‘s suggestion before editing, I mapped motif score matrix with spatial data directly (so as gene scores). According to the new suggestions I tried to map RNA and then transfer ATAC, but It looks like the results were wrong.
In addition to the spatial pattern of ATAC cell types, I also need to plot spatial patterns of transcription factor motif scores (calculated by R package chromVAR).

Here is code that I mapped motif score matrix with spatial data directly:

path = os.path.join('sp.h5ad')
ad_sp = sc.read_h5ad(path)

path = os.path.join('chromvar.h5ad')
ad_sc = sc.read_h5ad(path)

markers = list(ad_sc.var_names) # use all 746 TF motifs
tg.pp_adatas(ad_sc, ad_sp, genes=markers)

assert ad_sc.uns['training_genes'] == ad_sp.uns['training_genes']

ad_map = tg.map_cells_to_space(
    adata_sc=ad_sc,
    adata_sp=ad_sp,
    device='cpu',
    #device='cuda:0',
)

ad_ge = tg.project_genes(adata_map=ad_map, adata_sc=ad_sc)
genes = ['sox2', 'dlx1', 'lhx2', 'emx1']
ad_map.uns['train_genes_df'].loc[genes]

tg.plot_genes_sc(genes, adata_measured=ad_sp, adata_predicted=ad_ge, spot_size=1.5, perc = 0.001, return_figure=False)
plt.savefig('marTF_chromvar.png')

Here is code that I mapped RNA and then transfer ATAC:

path = os.path.join('sp.h5ad')
ad_sp = sc.read_h5ad(path)

path = os.path.join('multiModal_rna.h5ad')
ad_sc = sc.read_h5ad(path)

path = os.path.join('chromvar.h5ad')
ad_atac = sc.read_h5ad(path)

df_genes = pd.read_csv('markers.csv', index_col=0)
markers = np.reshape(df_genes.values, (-1, )) # 553 marker genes
tg.pp_adatas(ad_sc, ad_sp, genes=markers)

assert ad_sc.uns['training_genes'] == ad_sp.uns['training_genes']

ad_map = tg.map_cells_to_space(
    adata_sc=ad_sc,
    adata_sp=ad_sp,
    device='cpu',
    #device='cuda:0',
)

ad_ge = tg.project_genes(adata_map=ad_map, adata_sc=ad_atac) # ATAC and RNA data have the same obs_names

genes = ['sox2', 'dlx1', 'lhx2', 'emx1']
ad_map.uns['train_genes_df'].loc[genes]

tg.plot_genes_sc(genes, adata_measured=ad_sp, adata_predicted=ad_ge, spot_size=1.5, perc = 0.001, return_figure=False)
plt.savefig('multiModal_marTF_chromvar.png')

Your kind help and swift reply is highly appreciated.

from tangram.

daixinap avatar daixinap commented on June 7, 2024

Here is result that I mapped RNA and then transfer ATAC (motif scores):
E13 5_multiModal_marTF_chromvar

from tangram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.