Tangram icon indicating copy to clipboard operation
Tangram copied to clipboard

Map multimodal data such as SHARE-seq to reveal spatial patterns of chromatin accessibility

Open daixinap opened this issue 3 years ago • 5 comments

Hi, thank you very much for developing such a helpful tool! I am interested in mapping multimodal data such as SHARE-seq to reveal spatial patterns of chromatin accessibility, but I don't know how to do that. I can map snRNA-seq to spatial data, but I have no idea to transfer snATAC-seq profile of the same cells to space. I want to visualize inferred spatial patterns of chromatin accessibility and transcription factor motif scores at single-cell resolution. Thank you very much if there is a tutorial or code.

daixinap avatar Dec 02 '21 16:12 daixinap

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.

gaddamshreya avatar Dec 03 '21 13:12 gaddamshreya

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

daixinap avatar Dec 08 '21 15:12 daixinap

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.

lewlin avatar Dec 10 '21 03:12 lewlin

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.

daixinap avatar Dec 20 '21 14:12 daixinap

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

daixinap avatar Dec 20 '21 14:12 daixinap