kaizhang / SnapATAC2

Single-cell epigenomics analysis tools
https://kzhang.org/SnapATAC2/
197 stars 20 forks source link

make_gene_matrix: cannot set n_obs unless n_obs == 0 #289

Closed wgao688 closed 3 months ago

wgao688 commented 3 months ago

Hi Kai,

Thanks for your help and quick responses. I am trying to run make_gene_matrix and I run in this error. This AnnDataSet object was loaded with snap.read_dataset()

AnnDataSet object with n_obs x n_vars = 191927 x 606219 obs: 'sample', 'leiden', 'age_group' var: 'count', 'selected' uns: 'spectral_eigenvalue', 'reference_sequences', 'AnnDataSet', 'macs3' obsm: 'fragment_paired', 'X_spectral_mnn', 'X_spectral', 'X_umap', 'X_spectral_harmony' obsp: 'distances'

Then, I run: query= snap.pp.make_gene_matrix(filtered_adata, gene_anno=snap.genome.hg38)

which produces this error: `/home/william/anaconda3/envs/snapatac/lib/python3.12/site-packages/anndata/_core/aligned_df.py:67: ImplicitModificationWarning:

Transforming to str index.


RuntimeError Traceback (most recent call last) Cell In[24], line 1 ----> 1 query = snap.pp.make_gene_matrix(filtered_adata, gene_anno=snap.genome.hg38) 2 query.write("/mnt/data1/william/ATAC/SnapATAC_gene_matrix.h5ad", compression='gzip')

File ~/anaconda3/envs/snapatac/lib/python3.12/site-packages/snapatac2/preprocessing/_basic.py:680, in make_gene_matrix(adata, gene_anno, inplace, file, backend, chunk_size, use_x, id_type, transcript_name_key, transcript_id_key, gene_name_key, gene_id_key, min_frag_size, max_frag_size, counting_strategy) 678 else: 679 out = internal.AnnData(filename=file, backend=backend, obs=adata.obs[:]) --> 680 internal.mk_gene_matrix(adata, gene_anno, chunk_size, use_x, id_type, 681 transcript_name_key, transcript_id_key, gene_name_key, gene_id_key, 682 counting_strategy, min_frag_size, max_frag_size, out) 683 return out

RuntimeError: cannot set n_obs unless n_obs == 0`

I get the same error with the function make_peak_matrix

Thanks for your help!

kaizhang commented 3 months ago

Which version are you using? This issue should be fixed in v2.6 or the nightly version.

wgao688 commented 3 months ago

I am using '2.6.0' (checked via snap._version). Should I use the nightly version then?

wgao688 commented 3 months ago

Hi Kai, I was able to get this to work by rerunning everything with the nightly version. Thanks!