kaizhang/SnapATAC2

info lost after converting anndataset into anndata

TingTingShao opened this issue · 2 comments

Hi,

I used simply run this to convert anndataset into anndata
dataset=datas.to_adata()

However, when I call peaks with snap.tl.macs3, error shows:

neither 'fragment_single' nor 'fragment_paired' is present in the '.obsm'

AnnData
AnnData object with n_obs × n_vars = 2552 × 6062095
    obs: 'sample', 'tsse', 'leiden_1_mnc', 'leiden_0.3_mnc'
    var: 'count', 'selected'
    uns: 'reference_sequences', 'AnnDataSet', 'spectral_eigenvalue'
    obsm: 'X_spectral', 'X_umap', 'X_spectral_mnc', 'X_umap_mnc'
    obsp: 'distances'

AnnDataSets
AnnDataSet object with n_obs x n_vars = 2552 x 6062095 backed at 'microglia_5_500_005.h5ads'
contains 2 AnnData objects with keys: 'D19-13155', 'D19-8608'
    obs: 'sample'
    uns: 'reference_sequences', 'AnnDataSet'

Looking forward to your reply!
thanks
tingting

This is an expected behavior. datas.to_adata() will not copy those in datas.adatas.obsm. In order to copy fragment_paired, you need to do this before calling to_adata():

datas.obsm['fragment_paired'] = datas.adatas.obsm['fragment_paired']

Thanks!