Skip to content

cannot coerce type 'environment' to vector of type 'character' #299

@ynanli

Description

@ynanli

Hi,
Thanks for the nice package.

I am encounter issue when reading an AnnData object from h5ad file. Not sure what exactly the issue is.

> obj <- anndataR::read_h5ad(h5ad_path)
Error in as.vector(x, "character") : 
  cannot coerce type 'environment' to vector of type 'character'

I checked the h5ad file, and it seems to be fine.

> ad <- import("anndata", convert = FALSE)
> adata <- ad$read_h5ad(h5ad_path)
> adata
AnnData object with n_obs × n_vars = 403759 × 30647
    obs: 'sampleID', 'study', 'diagnosis', 'Disease_study', 'compartment', 'cell type', 'cell subtype', 'n_genes', 'log1p_n_genes_by_counts', 'total_counts', 'pct_counts_mitochondrial', 'Source'
    var: 'gene_ids', 'gene_name', 'mitochondrial'
    uns: 'cell subtype_colors', 'cell type_colors', 'compartment_colors', 'diagnosis_colors', 'neighbors', 'study_colors', 'umap'
    obsm: 'X_scVI', 'X_umap'
    layers: 'counts', 'log10_10k_normalized', 'log1p'
    obsp: 'connectivities', 'distances'

Any idea what might cause this issue?

> sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0

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

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
[1] reticulate_1.42.0

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5         cli_3.6.4           knitr_1.50          rlang_1.1.6         xfun_0.51          
 [6] purrr_1.0.4         png_0.1-8           jsonlite_1.9.1      bit_4.6.0           htmltools_0.5.8.1  
[11] rsconnect_1.3.4     rmarkdown_2.29      rappdirs_0.3.3      grid_4.4.2          evaluate_1.0.3     
[16] fastmap_1.2.0       yaml_2.3.10         lifecycle_1.0.4     compiler_4.4.2      Rcpp_1.0.14        
[21] rstudioapi_0.17.1   anndataR_0.1.0.9009 lattice_0.22-7      digest_0.6.37       R6_2.6.1           
[26] magrittr_2.0.3      Matrix_1.7-3        hdf5r_1.3.12        tools_4.4.2         withr_3.0.2        
[31] bit64_4.6.0-1    

> py_config()
python:         /mnt/data/home/yinanli/miniforge3/envs/popv/bin/python
libpython:      /mnt/data/home/yinanli/miniforge3/envs/popv/lib/libpython3.12.so
pythonhome:     /mnt/data/home/yinanli/miniforge3/envs/popv:/mnt/data/home/yinanli/miniforge3/envs/popv
version:        3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:38:13) [GCC 12.3.0]
numpy:          /mnt/data/home/yinanli/miniforge3/envs/popv/lib/python3.12/site-packages/numpy
numpy_version:  2.1.3

NOTE: Python version was forced by use_python() function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions