theislab / zellkonverter

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

Error when reading .h5ad written with anndata v0.8.0 #71

Closed alexlenail closed 1 year ago

alexlenail commented 2 years ago

I'm trying to read a 600k cell h5ad file into a SingleCellExperiment object in R, but it's throwing a timeout error. Can I extend the timelimit?

Reading /.../.../.../.../.../.../.../PFC.h5ad [30.2s]

Error in py_call_impl(callable, dots$args, dots$keywords): anndata._io.utils.AnnDataReadError: Above error raised while reading key '/layers' of type <class 'h5py._hl.group.Group'> from /.

Traceback:

1. withTimeout({
 .     readH5AD(input_file, verbose = TRUE)
 . }, timeout = 120, onTimeout = "silent")
2. tryCatch({
 .     eval(expr, envir = envir)
 . }, error = function(ex) {
 .     msg <- ex$message
 .     pattern <- gettext("reached elapsed time limit", "reached CPU time limit", 
 .         domain = "R")
 .     pattern <- paste(pattern, collapse = "|")
 .     if (regexpr(pattern, msg) != -1L) {
 .         ex <- TimeoutException(msg, cpu = cpu, elapsed = elapsed)
 .         if (onTimeout == "error") {
 .             throw(ex)
 .         }
 .         else if (onTimeout == "warning") {
 .             warning(getMessage(ex))
 .         }
 .         else if (onTimeout == "silent") {
 .         }
 .     }
 .     else {
 .         throw(ex)
 .     }
 . })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. throw(ex)
7. throw.error(ex)
alexlenail commented 2 years ago

Sorry I may have been misreading the error message. The important bit might just be

Error in py_call_impl(callable, dots$args, dots$keywords): anndata._io.utils.AnnDataReadError: Above error raised while reading key '/layers' of type <class 'h5py._hl.group.Group'> from /.

But the "above" might not be getting printed, despite verbose = TRUE

alexlenail commented 2 years ago

in python, I can do

import anndata
adata = anndata.read_h5ad(input_file)

without any issues. The input_file was created with scanpy.write_h5ad() -- scanpy version '1.9.1', anndata version 0.8.0. The file can't be ready by Package zellkonverter version 1.4.0

The anndata file has no layers, and no raw.

lazappi commented 2 years ago

Hi @alexlenail

Thanks for giving {zellkonverter} a go 🎉 ! I'm not sure what the timeout message is but {zellkonverter} v1.4.0 is only compatible with .h5ad files written with anndata v0.7.x. If you want to read a .h5ad written with anndata > v0.8 you need to either use {zellkonverter} > v1.6 or (if you are comfortable managing your own Python environment) use {reticulate} and zellkonverter::AnnData2SCE() directly.

Hope that helps

lazappi commented 1 year ago

@alexlenail Were you able to get this working after my suggestions?

alexlenail commented 1 year ago

@lazappi yes! It was just a version issue