Skip to content

Misinformation when using anndataToGiotto with non default env_name #230

@wwang-chcn

Description

@wwang-chcn

Describe the Error

The function anndataToGiotto, even though it runs successfully, throws an error message.
This will happen if I use an alternative env_name.

...

Error Message

Details
# ERROR: The requested version of Python
# ('/Users/wwang/miniconda3/envs/giotto_env/bin/python')
# cannot be used, as another version of Python
# ('/Users/wwang/miniconda3/envs/giotto_ontrac_env/bin/python')
# has already been initialized. Please restart the R
# session if you need to attach reticulate to a different
# version of Python.

To Reproduce

Steps to reproduce the behavior, i.e.:

  1. Install a custom conda env
installGiottoEnvironment(
  packages_to_install = c(
    "pandas==1.5.1",
    "networkx==2.8.8",
    "python-igraph==0.10.2",
    "leidenalg==0.9.0",
    "python-louvain==0.16",
    "python.app==1.4",
    "scikit-learn==1.1.3",
    "smfishhmrf",
    "scanpy",
    "session-info"
  ),
  pip_packages = c("python-louvain", "smfishhmrf", "session-info", "scanpy"),
  envname = "giotto_alt_env"
)
  1. Try to read an .h5ad obj using anndataToGiotto
set_giotto_python_path("giotto_alt_env")
# a python path has been provided
# Using python path:
#  "/Users/wwang/miniconda3/envs/giotto_alt_env/bin/python"
giotto_all_slices_obj <- anndataToGiotto(file.path("data/03_session5/counts.h5ad"),
                                         env_name = "giotto_alt_env")
# python already initialized in this session
#  active environment : 'giotto_alt_env'
#  python version : 3.10
# checking default envname 'giotto_env'
# a system default python environment was found
# Using python path:
#  "/Users/wwang/miniconda3/envs/giotto_env/bin/python"
# ERROR: The requested version of Python
# ('/Users/wwang/miniconda3/envs/giotto_env/bin/python') cannot be used, as
# another version of Python
# ('/Users/wwang/miniconda3/envs/giotto_alt_env/bin/python') has already been
# initialized. Please restart the R session if you need to attach reticulate
# to a different version of Python.
# There are non numeric or integer columns for the spatial location
#  input at column position(s): 1
#  The first non-numeric column will be considered as a cell ID
#  to test for consistency with the expression matrix
#  Other non numeric columns will be removed
# 
# List item [1]:
#  spat_unit: cell
#  feat_type: rna
# > Cell metadata for spat_unit " cell " and feat_type " rna " already exists and
#  will be replaced with new metadata.
# Setting cell metadata [cell][rna]
# list depth of 2
# 
# List item [1]:
#  spat_unit: cell
#  feat_type: rna
# > Feat metadata for spat_unit " cell " and feat_type " rna " already exists and
#  will be replaced with new metadata.
# Setting feature metadata [cell][rna]
# 
# AnnData object successfully converted to Giotto.
# Warning message:
# Python is required for full Giotto functionality. 
# Spatial locations were not found. If spatial locations should have been found,
#         please modify the anndata object to include a keyword-value pair within the obsm slot,
#         in which the keyword contains the phrase "spatial" and the value corresponds to the spatial locations.
# 
#         In the Giotto Object resulting from this conversion, dummy locations will be used.

Expected behavior

This function ran successfully, no error message should thros.

Screenshots

image

System Information

R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Ventura 13.6.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] GiottoClass_0.3.5

loaded via a namespace (and not attached):
 [1] Matrix_1.7-0       jsonlite_1.8.8     compiler_4.4.0     gtools_3.9.5       Rcpp_1.0.13        magick_2.8.4       parallel_4.4.0     png_0.1-8         
 [9] yaml_2.3.8         fastmap_1.2.0      reticulate_1.38.0  lattice_0.22-6     deldir_2.0-4       dbscan_1.2-0       generics_0.1.3     igraph_2.0.3      
[17] knitr_1.47         backports_1.5.0    checkmate_2.3.2    R.utils_2.12.3     GiottoUtils_0.1.11 rlang_1.1.4        sp_2.1-4           terra_1.7-78      
[25] xfun_0.44          cli_3.6.3          withr_3.0.1        magrittr_2.0.3     digest_0.6.35      grid_4.4.0         rstudioapi_0.16.0  lifecycle_1.0.4   
[33] R.methodsS3_1.8.2  R.oo_1.26.0        evaluate_0.24.0    glue_1.7.0         data.table_1.15.4  codetools_0.2-20   rmarkdown_2.27     matrixStats_1.3.0 
[41] tools_4.4.0        pkgconfig_2.0.3    htmltools_0.5.8.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions