SnapATAC2 icon indicating copy to clipboard operation
SnapATAC2 copied to clipboard

AnnDataSet can not be converted to AnnData when the X is empty

Open beyondpie opened this issue 1 year ago • 3 comments

Hi Kai,

I have several AnnData created directly from fragment files. If I did not add any matrix to AnnData's X, and combine them into AnnDataSet (this step is OK).

  1. I find that it always report Errors when I used to_adata function for the merged AnnDataSet object.

thread '' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anndata-0.3.1/src/anndata/dataset.rs:302:81: called Option::unwrap() on a None value note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

  1. if I run a.X (a: AnnDataSet), it also reports error:

PanicException: called Option::unwrap() on a None value. (this is the last line of the Error, the whole stacks are about using pretty method to print the results in IPython.)

But AnnData is OK if X is empty. Just nothing is showed in my IPython REPL.

Thanks! Songpeng

beyondpie avatar Aug 30 '24 17:08 beyondpie

  1. It seems OK now for to_adata, but still a.X has error.
  2. Another question is when I transform it into Ann, the fragment information is lost. Can I also keep the fragment information to Ann, too?

beyondpie avatar Sep 25 '24 18:09 beyondpie

  • It seems OK now for to_adata, but still a.X has error.
  • Another question is when I transform it into Ann, the fragment information is lost. Can I also keep the fragment information to Ann, too?

Before you run to_adata() you need to run the following: datas.obsm['fragment_paired'] = datas.adatas.obsm['fragment_paired'] and then convert your dataset to data. Also, you may want to check this link too: https://kzhang.org/epigenomics-analysis/anndata.html#combining-multiple-anndata-objects-into-a-anndataset-object

yojetsharma avatar Sep 25 '24 18:09 yojetsharma

@yojetsharma Thank you! From API, it does not mention this. Sincerely, Songpeng

beyondpie avatar Sep 25 '24 22:09 beyondpie