theislab / scvelo

RNA Velocity generalized through dynamical modeling
https://scvelo.org
BSD 3-Clause "New" or "Revised" License
414 stars 102 forks source link

Problems combining loom file with my adata object #1054

Closed zincfingers89 closed 1 year ago

zincfingers89 commented 1 year ago

Hi, Im having a somewhat similar issue and wondered if you could help.

I have a scRNA seq dataset pre-processed in seurat, I have then used SeuratDisk to convert this into h5ad - named adata. I have also using scvelo made a loom file of this data - named ldata1. However I cannot seem to merge the two for further analysis. I cannot seem to work out the error message either? Any help/pointers really appreciated.

reload dataset

adata = sc.read_h5ad('data.h5ad')

adata

AnnData object with n_obs × n_vars = 11246 × 2000 obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'sample', 'group', 'sex', 'percent.mt', 'RNA_snn_res.0.5', 'seurat_clusters', 'barcode' var: 'vst.mean', 'vst.variance', 'vst.variance.expected', 'vst.variance.standardized', 'vst.variable' uns: 'neighbors' obsm: 'X_pca', 'X_umap' varm: 'PCs' obsp: 'distances'

scv.settings.verbosity = 3 scv.settings.set_figure_params('scvelo', facecolor='white', dpi=100, frameon=False) cr.settings.verbosity = 2

ldata1 = scv.read('IM188-N.loom', cache=True) ldata1.var_names_make_unique()

ldata1

AnnData object with n_obs × n_vars = 2993 × 36601 obs: 'initial_size_unspliced', 'initial_size_spliced', 'initial_size' var: 'Accession', 'Chromosome', 'End', 'Start', 'Strand' layers: 'ambiguous', 'matrix', 'spliced', 'unspliced'

merge matrices into the original adata object

adata = scv.utils.merge(adata, ldata1)


UnboundLocalError Traceback (most recent call last) Cell In[10], line 2 1 # merge matrices into the original adata object ----> 2 adata = scv.utils.merge(adata, ldata1)

File /opt/anaconda3/lib/python3.8/site-packages/scvelo/core/_anndata.py:526, in merge(adata, ldata, copy, **kwargs) 524 if "id_length" in kwargs: 525 id_length = kwargs.get("id_length") --> 526 clean_obs_names(adata, id_length=id_length) 527 clean_obs_names(ldata, id_length=id_length) 528 common_obs = adata.obs_names.intersection(ldata.obs_names)

UnboundLocalError: local variable 'id_length' referenced before assignment

zincfingers89 commented 1 year ago

https://github.com/theislab/scvelo/issues/989