drieslab / Giotto

Spatial omics analysis toolbox
https://drieslab.github.io/Giotto_website/
Other
258 stars 98 forks source link

installGiottoEnvironment fails in Apple Silicon (m1) #250

Closed sinanugur closed 1 year ago

sinanugur commented 2 years ago

I think this is related to python=3.6 being unavailable in any channel for M1 arch. I also tried using my own conda environment. It returns an error and so cannot find the modules despite being installed.

 |---- install giotto environment ----|
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/sium/Library/r-miniconda-arm64/envs/giotto_env

  added / updated specs:
    - python=3.8

The following NEW packages will be INSTALLED:

  bzip2              conda-forge/osx-arm64::bzip2-1.0.8-h3422bc3_4
  ca-certificates    conda-forge/osx-arm64::ca-certificates-2022.5.18.1-h4653dfc_0
  libffi             conda-forge/osx-arm64::libffi-3.4.2-h3422bc3_5
  libzlib            conda-forge/osx-arm64::libzlib-1.2.11-h90dfc92_1014
  ncurses            conda-forge/osx-arm64::ncurses-6.3-h07bb92c_1
  openssl            conda-forge/osx-arm64::openssl-3.0.3-ha287fd2_0
  pip                conda-forge/noarch::pip-22.1.1-pyhd8ed1ab_0
  python             conda-forge/osx-arm64::python-3.8.13-hd3575e6_0_cpython
  python_abi         conda-forge/osx-arm64::python_abi-3.8-2_cp38
  readline           conda-forge/osx-arm64::readline-8.1-hedafd6a_0
  setuptools         conda-forge/osx-arm64::setuptools-62.3.2-py38h10201cd_0
  sqlite             conda-forge/osx-arm64::sqlite-3.38.5-h40dfcc0_0
  tk                 conda-forge/osx-arm64::tk-8.6.12-he1e0b03_0
  wheel              conda-forge/noarch::wheel-0.37.1-pyhd8ed1ab_0
  xz                 conda-forge/osx-arm64::xz-5.2.5-h642e427_1
  zlib               conda-forge/osx-arm64::zlib-1.2.11-h90dfc92_1014

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - python=3.6

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Error: installation of 'python=3.6' into environment 'giotto_env' failed [error code 1]
RubD commented 2 years ago

Thanks for letting us know. You can always provide your own PATH to another python version or conda environment with the necessary modules installed. You can set that PATH when creating the giotto instructions and then provide these instructions when you make the Giotto object.

On our side we're looking to see if we can create another updated giotto environment (e.g. python 3.8) for automatic installation through installGiottoEnvironment

sinanugur commented 2 years ago

Hello, I created an environment with all the packages installed and tested. However, Giotto still complains about missing packages. I guess I hit a bug.

> instrs = createGiottoInstructions(python_path = "/Users/sium/opt/miniconda3/envs/giotto/bin/python",save_dir = "/Users/sium/projects/colon/tuva_analysis/giotto/",
+                                   save_plot = TRUE,
+                                   show_plot = FALSE)

 external python path provided and will be used 
> tuvas_131_giotto = createGiottoVisiumObject(visium_dir = "/Users/sium/projects/colon/spatial-workflow/data/Tuva-test-13-1/outs", expr_data = 'raw',
+                                          png_name = 'tissue_lowres_image.png',
+                                          gene_column_index = 2, instructions = instrs)
A structured visium directory will be used 
Consider to install these (optional) packages to run all possible Giotto commands for spatial analyses:  scran MAST smfishHmrf trendsceek SPARK multinet RTriangle FactoMiner
 Giotto does not automatically install all these packages as they are not absolutely required and this reduces the number of dependenciesWarning in createGiottoObject(raw_exprs = raw_matrix, spatial_locs = spatial_locs,  :
  module: pandas was not found with python path: /Users/sium/opt/miniconda3/envs/giotto/bin/python

Warning in createGiottoObject(raw_exprs = raw_matrix, spatial_locs = spatial_locs,  :
  module: igraph was not found with python path: /Users/sium/opt/miniconda3/envs/giotto/bin/python

Warning in createGiottoObject(raw_exprs = raw_matrix, spatial_locs = spatial_locs,  :
  module: leidenalg was not found with python path: /Users/sium/opt/miniconda3/envs/giotto/bin/python

Warning in createGiottoObject(raw_exprs = raw_matrix, spatial_locs = spatial_locs,  :
  module: community was not found with python path: /Users/sium/opt/miniconda3/envs/giotto/bin/python

Warning in createGiottoObject(raw_exprs = raw_matrix, spatial_locs = spatial_locs,  :
  module: networkx was not found with python path: /Users/sium/opt/miniconda3/envs/giotto/bin/python

Warning in createGiottoObject(raw_exprs = raw_matrix, spatial_locs = spatial_locs,  :
  module: sklearn was not found with python path: /Users/sium/opt/miniconda3/envs/giotto/bin/python

This is the environment, all the packages are there:

(giotto) ➜  ~ /Users/sium/opt/miniconda3/envs/giotto/bin/python
Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:45:10) [Clang 12.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> import sklearn
>>> import community
>>> import networkx
>>> import leidenalg
>>>
R version 4.2.0 (2022-04-22)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

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

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

other attached packages:
[1] Giotto_1.1.1  spacexr_2.0.0

loaded via a namespace (and not attached):
  [1] Seurat_4.1.1          Rtsne_0.16            colorspace_2.0-3      deldir_1.0-6          ellipsis_0.3.2        ggridges_0.5.3        rprojroot_2.0.3       rstudioapi_0.13      
  [9] spatstat.data_2.2-0   leiden_0.4.2          listenv_0.8.0         ggrepel_0.9.1         fansi_1.0.3           R.methodsS3_1.8.1     codetools_0.2-18      splines_4.2.0        
 [17] doParallel_1.0.17     knitr_1.39            polyclip_1.10-0       jsonlite_1.8.0        ica_1.0-2             cluster_2.1.3         R.oo_1.24.0           png_0.1-7            
 [25] rgeos_0.5-9           uwot_0.1.11           shiny_1.7.1           sctransform_0.3.3     spatstat.sparse_2.1-1 compiler_4.2.0        httr_1.4.3            assertthat_0.2.1     
 [33] SeuratObject_4.1.0    Matrix_1.4-1          fastmap_1.1.0         lazyeval_0.2.2        cli_3.3.0             later_1.3.0           htmltools_0.5.2       tools_4.2.0          
 [41] igraph_1.3.1          gtable_0.3.0          glue_1.6.2            RANN_2.6.1            reshape2_1.4.4        dplyr_1.0.9           Rcpp_1.0.8.3          scattermore_0.8      
 [49] vctrs_0.4.1           nlme_3.1-157          progressr_0.10.0      iterators_1.0.14      lmtest_0.9-40         spatstat.random_2.2-0 xfun_0.30             stringr_1.4.0        
 [57] globals_0.15.0        mime_0.12             miniUI_0.1.1.1        lifecycle_1.0.1       irlba_2.3.5           goftest_1.2-3         future_1.25.0         MASS_7.3-56          
 [65] zoo_1.8-10            scales_1.2.0          spatstat.core_2.4-2   promises_1.2.0.1      spatstat.utils_2.3-1  parallel_4.2.0        lightgbm_3.3.2        RColorBrewer_1.1-3   
 [73] reticulate_1.24       pbapply_1.5-0         gridExtra_2.3         ggplot2_3.3.6         rpart_4.1.16          stringi_1.7.6         foreach_1.5.2         rlang_1.0.2          
 [81] pkgconfig_2.0.3       matrixStats_0.62.0    lattice_0.20-45       ROCR_1.0-11           purrr_0.3.4           tensor_1.5            patchwork_1.1.1       htmlwidgets_1.5.4    
 [89] cowplot_1.1.1         tidyselect_1.1.2      here_1.0.1            parallelly_1.31.1     RcppAnnoy_0.0.19      plyr_1.8.7            magrittr_2.0.3        R6_2.5.1             
 [97] magick_2.7.3          generics_0.1.2        DBI_1.1.2             pillar_1.7.0          mgcv_1.8-40           fitdistrplus_1.1-8    survival_3.3-1        abind_1.4-5          
[105] sp_1.4-7              tibble_3.1.7          future.apply_1.9.0    crayon_1.5.1          KernSmooth_2.23-20    utf8_1.2.2            spatstat.geom_2.4-0   plotly_4.10.0        
[113] grid_4.2.0            data.table_1.14.2     digest_0.6.29         xtable_1.8-4          tidyr_1.2.0           httpuv_1.6.5          R.utils_2.11.0        munsell_0.5.0        
[121] viridisLite_0.4.0    
sinanugur commented 2 years ago

Well it seem pythonw must be created using a symlink. Giotto looks for pythonw

RubD commented 2 years ago

Did using "/Users/sium/opt/miniconda3/envs/giotto/bin/pythonw" resolve the issue?

sinanugur commented 2 years ago

Did using "/Users/sium/opt/miniconda3/envs/giotto/bin/pythonw" resolve the issue?

Yes. I mean first I had to create an empty environment (called giotto_env as suggested, using the default path /Users/sium/Library/r-miniconda-arm64/envs/giotto_env) and forced it to use ARM64 architecture. I manually installed all the packages using pip and mamba. Then I created pythonw symlink pointing python binary. Then it worked. It seems Giotto seeks for pythonw in MAC.