theislab / zellkonverter

Conversion between scRNA-seq objects
https://theislab.github.io/zellkonverter/
Other
145 stars 27 forks source link

Results from rank_genes_groups are not converted #28

Closed lazappi closed 1 year ago

lazappi commented 3 years ago

The scanpy rank_genes_groups() function stores it's results in adata.uns['rank_genes_groups']. Currently conversion fails with the following warning (from reading example_anndata.h5ad):

Warning message:
conversion failed for the item 'rank_genes_groups' in 'uns' with the following error and has been skipped
Error message: Error in py_ref_to_r(x): Conversion from numpy array type 20 is not supported

It would be worth having special code to handle this as many AnnData objects are likely to contain this and users may want to be able to access it in R.

lazappi commented 3 years ago

One possible option is to use scanpy.get.rank_genes_groups_df() to convert it to a DataFrame which {reticulate} would convert. Downside is that this would require adding scanpy as a dependency.

Interestingly the native HDF5 reader seems to (mostly) handle this (see #46) but that doesn't help for other uses of AnnData2SCE().

LTLA commented 3 years ago

What happens on the anndata side, without scanpy, when an object like this is saved to HDF5? We should be able to reproduce that logic to obtain some simple data structures that can pass through the language barrier.

Side note 1: seems like it would have made more sense for the DE results to live in obsm, given that they're parallel to the observations.

Side note 2: ... though I don't think it's a good practice to routinely store the DE results in the same file as the expression values, given that they evolve at different rates.