theislab / zellkonverter

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

read_h5ad issue ( python reader raise issue , R reader work but dont read the meta data while raise this warning Warning message: In value[[3L]](cond) : setting 'colData' failed for 'adata1.h5ad': cannot coerce class "list" to a DataFrame #102

Closed Marwansha closed 10 months ago

Marwansha commented 10 months ago

Hi ! first thanks for devleoping the tool. i have issue where i have h5ad files that am trying to read then convert to sce object, the h5ad file have many layers init and many adata.obs columns. i encountered 3 problem here : ther read_h5ad only worked when i used the R reader, yielding an warning error message saying failed to read the colData

> adata <- readH5AD("adata1.h5ad",use_hdf5=TRUE,reader= "R")
Warning message:
In value[[3L]](cond) :
  setting 'colData' failed for 'adata1.h5ad': cannot coerce class "list"
  to a DataFrame
adata
class: SingleCellExperiment 
dim: 27113 8306 
metadata(2): log1p neighbors
assays(7): X Cellbender_filtered ... raw scran
rownames: NULL
rowData names(12): RP feature_types.categories ...
  pct_dropout_by_counts total_counts
colnames: NULL
colData names(0):
reducedDimNames(1): X_pca
mainExpName: NULL
altExpNames(0):

while the python reader gave an error

    adata <- readH5AD("adata1.h5ad",use_hdf5=TRUE,reader= "python")
    Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AnnDataReadError: Above error raised while reading key '/obsm' of type <class 'h5py._hl.group.Group'> from /.
    ##another try with hdf5 - false
adata <- readH5AD("adata1.h5ad",use_hdf5=FALSE,reader= "python")
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AnnDataReadError: Above error raised while reading key '/layers' of type <class 'h5py._hl.group.Group'> from /.

Detailed traceback:
  File "/pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv/lib/python3.7/site-packages/anndata/_io/h5ad.py", line 421, in read_h5ad
    d[k] = read_attribute(f[k])
  File "/pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv/lib/python3.7/functools.py", line 840, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv/lib/python3.7/site-packages/anndata/_io/utils.py", line 184, in func_wrapper
    f"Above error raised while reading key {elem.name!r} of "

## **when running using python option for first time it created a conda enviroment** 
> readH5AD("adata1.h5ad",use_hdf5=TRUE,reader= "python")
+ /pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/0/bin/conda 'create' '--yes' '--prefix' '/pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv' 'python=3.7.7' '--quiet' '-c' 'conda-forge'
Collecting package metadata (current_repodata.json): ...working... done

this is the py config , t uses the python from the created conda env, which have the python packages as in the tutorial

> py_config()
> /pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv/bin/python
> libpython:      /pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv/lib/libpython3.7m.so
> pythonhome:     /pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv:/pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv
> version:        3.7.7 (default, May  7 2020, 21:25:33)  [GCC 7.3.0]
> numpy:          /pasteur/appa/homes/masharaw/.cache/R/basilisk/1.4.0/zellkonverter/1.2.1/zellkonverterAnnDataEnv/lib/python3.7/site-packages/numpy
> numpy_version:  1.20.2

sessionInfo

>  sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.8 (Ootpa)

Matrix products: default
BLAS:   /opt/gensoft/lib/atlas/3.10.2/lib/libf77blas.so
LAPACK: /opt/gensoft/lib/lapack/3.9.0/lib64/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reticulate_1.20     zellkonverter_1.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3                XVector_0.32.0             
 [3] GenomicRanges_1.44.0        BiocGenerics_0.38.0        
 [5] zlibbioc_1.38.0             IRanges_2.26.0             
 [7] lattice_0.20-44             GenomeInfoDb_1.28.4        
 [9] tools_4.1.0                 SummarizedExperiment_1.22.0
[11] parallel_4.1.0              grid_4.1.0                 
[13] rhdf5_2.36.0                Biobase_2.52.0             
[15] png_0.1-7                   HDF5Array_1.20.0           
[17] basilisk_1.4.0              matrixStats_0.61.0         
[19] Matrix_1.3-3                GenomeInfoDbData_1.2.6     
[21] dir.expiry_1.0.0            Rhdf5lib_1.14.2            
[23] rhdf5filters_1.4.0          S4Vectors_0.30.2           
[25] bitops_1.0-7                basilisk.utils_1.4.0       
[27] RCurl_1.98-1.6              SingleCellExperiment_1.14.1
[29] DelayedArray_0.18.0         compiler_4.1.0             
[31] filelock_1.0.2              MatrixGenerics_1.4.2       
[33] stats4_4.1.0                jsonlite_1.8.0    
Marwansha commented 10 months ago

Update, the h5ad read only works when i update anndata from 0.7.6 to 0.8.0