zellkonverter icon indicating copy to clipboard operation
zellkonverter copied to clipboard

Error when reading .h5ad written with anndata v0.8.0

Open alexlenail opened this issue 2 years ago • 3 comments

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 avatar Aug 24 '22 16:08 alexlenail

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 avatar Aug 24 '22 17:08 alexlenail

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.

alexlenail avatar Aug 24 '22 17:08 alexlenail

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 avatar Aug 25 '22 07:08 lazappi

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

lazappi avatar Oct 06 '22 14:10 lazappi

@lazappi yes! It was just a version issue

alexlenail avatar Oct 06 '22 16:10 alexlenail