Closed rbutleriii closed 1 year ago
I believe this is a versioning issue.
Can you re-install basilisk.utils and basilisk from github and let me know if that works?
With the github versions of both I now get runtime errors. Doesn't really give me anything to go on though.
> sce <- liana_tensor_c2c(sce = sce,
+ score_col = 'LRscore',
+ rank = 7, # set to None to estimate for you data!
+ how='outer', # defines how the tensor is built
+ conda_env = NULL, # used to pass an existing conda env with cell2cell
+ use_available = FALSE # detect & load cell2cell if available
+ )
Setting up Conda Environment with Basilisk
Error : RuntimeError: The current Numpy installation ('/home/rrbutler/.cache/R/basilisk/1.11.2/liana/0.1.10/liana_cell2cell/lib/python3.8/site-packages/numpy/__init__.py') fails to pass simple sanity checks. This can be caused for example by incorrect BLAS library being linked in, or by mixing package managers (pip, conda, apt, ...). Search closed numpy issues for similar problems.
In addition: Warning message:
In exec(output, ...) : `sce` was superseded by `context_df_dict`!
Error in .activate_fallback(proc, testload, env = env, envpath = envpath) :
RuntimeError: The current Numpy installation ('/home/rrbutler/.cache/R/basilisk/1.11.2/liana/0.1.10/liana_cell2cell/lib/python3.8/site-packages/numpy/__init__.py') fails to pass simple sanity checks. This can be caused for example by incorrect BLAS library being linked in, or by mixing package managers (pip, conda, apt, ...). Search closed numpy issues for similar problems.
> traceback()
4: stop(msg)
3: .activate_fallback(proc, testload, env = env, envpath = envpath)
2: basilisk::basiliskStart(liana_env, testload = "scipy.optimize")
1: liana_tensor_c2c(sce = sce, score_col = "LRscore", rank = 7,
how = "outer", conda_env = NULL, use_available = FALSE)
I have a hunch this is a cluster issue (on an academic cluster with managed packages), as when I back out and examine the Lmod
setup, it appears R
has its own version of python that probably is missing some libraries, but loading anaconda
as a module first it breaks the R
. Is there a conda yml to build the environment for c2c so I can just link it?
Things I have tried with basilisk:
Sys.setenv(RETICULATE_PYTHON = "/scg/apps/software/anaconda/3/bin/python")
.cache/R/
and repeatingTrying to build the conda env separately:
liana_env.yml
plus adding pip install cell2cell
. However, if I loaded the modules ml anaconda R
, the it can't find the correct pythonml R/4.1.2 anaconda
in that order, and then calling explicitly the full path to the R
module, It did launch and started running, but failed:
> Sys.setenv(RETICULATE_PYTHON = "/scg/apps/software/anaconda/3/bin/python")
library(tidyverse, quietly = TRUE) library(SingleCellExperiment, quietly = TRUE) library(reticulate, quietly = TRUE) library(magrittr, quietly = TRUE) library(liana, quietly = TRUE) sce = readRDS("sce_temp.rds")
sce = liana_tensor_c2c(
- sce=sce,
- score_col='LRscore',
- rank=7, # set to None to estimate for you data!
- how='outer', # defines how the tensor is built
- conda_env="liana_env", # used to pass an existing conda env with cell2cell
- use_available=FALSE # detect & load cell2cell if available
- ) [1] 0 Loading
liana_env
Conda Environment Error: ImportError: /lib64/libz.so.1: versionZLIB_1.2.9' not found (required by /home/rrbutler/.conda/envs/liana_env/lib/python3.8/site-packages/matplotlib/../../.././libpng16.so.16) In addition: Warning message: In exec(output, ...) :
scewas superseded by
context_df_dict`!- Lastly, build out the
liana_env
completely withr-base
r-essentials
r-tidyverse
bioconductor-singlecellexperiment
r-reticulate
r-magrittr
to be completely freestanding. At that point anaconda quit and started crying in the corner (was not able to successfully build, just failed to solve the environment for an hour).
Hmmm, actually you don't necessarily need to set up an R environment (basilisk sets up a pure Python one in this case).
Instead, what you could do is to set up a conda env /w the same parameters that liana needs to run tensor (in Python).
These are the package versions that are currently used to create the conda env via basilis: https://github.com/saezlab/liana/blob/10d81773e0874de676eb106ce56e3cf9d4fe01d3/R/liana_tensor.R#L714
Would suggest creating a conda env with those and passing that one :)
Updates: I did install that liana_env
by opening the pandora's box of making all dependencies >=
. However, there is no way to install liana via remotes
in a conda version of r
. In any case, that was more of a tangent, as i could build the tensor environment.
But using python 3.8.8
was giving me issues with the pip installs, seemingly from this pypa
issue that was not backported. So setting it to >=3.9
got me moving...right back to the original basilisk error.
> sce = liana_tensor_c2c(
+ sce=sce,
+ score_col='LRscore',
+ rank=7, # set to None to estimate for you data!
+ how='outer', # defines how the tensor is built
+ conda_env="cell2cell", # used to pass an existing conda env with cell2cell
+ use_available=TRUE # detect & load cell2cell if available
+ )
[1] 0
Loading `cell2cell` Conda Environment
Error: RuntimeError: The current Numpy installation ('/home/rrbutler/miniconda3/envs/cell2cell/lib/python3.10/site-packages/numpy/__init__.py') fails to pass simple sanity checks. This can be caused for example by incorrect BLAS library being linked in, or by mixing package managers (pip, conda, apt, ...). Search closed numpy issues for similar problems.
In addition: Warning message:
In exec(output, ...) : `sce` was superseded by `context_df_dict`!
It appears reticulate
set it up right after all, but that there is another issue with numpy
via reticulate
in R
when depending on anaconda versions of numpy
. Despite it importing successfully in python outside of reticulate
. As in that suggested solution, you can force a reinstallation of numpy
(but it should be <1.24
or it conflicts with numba
).
reticulate::py_install("numpy<1.24", envname="cell2cell", pip=T, pip_options=c("--force-reinstall", "--no-binary numpy"))
This accepts numpy, but errors out soon after with a python error, that can be replicated in the conda
envrionment:
>>> import cell2cell
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rrbutler/.local/lib/python3.10/site-packages/cell2cell/__init__.py", line 3, in <module>
from cell2cell import analysis
File "/home/rrbutler/.local/lib/python3.10/site-packages/cell2cell/analysis/__init__.py", line 1, in <m odule>
from cell2cell.analysis.cell2cell_pipelines import (initialize_interaction_space, BulkInteractions, S ingleCellInteractions)
File "/home/rrbutler/.local/lib/python3.10/site-packages/cell2cell/analysis/cell2cell_pipelines.py", li ne 6, in <module>
import scanpy
File "/home/rrbutler/.local/lib/python3.10/site-packages/scanpy/__init__.py", line 16, in <module>
from . import plotting as pl
File "/home/rrbutler/.local/lib/python3.10/site-packages/scanpy/plotting/__init__.py", line 1, in <modu le>
from ._anndata import (
File "/home/rrbutler/.local/lib/python3.10/site-packages/scanpy/plotting/_anndata.py", line 28, in <mod ule>
from . import _utils
File "/home/rrbutler/.local/lib/python3.10/site-packages/scanpy/plotting/_utils.py", line 35, in <modul e>
class _AxesSubplot(Axes, axes.SubplotBase, ABC):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the me taclasses of all its bases
Ultimately this has something to do with some combination of the way pip operates in conda when called up through a yml
file or the reticulate
method. The final solution was to just build a stock cell2cell
conda environment exactly as explained in the cell2cell pypi (or their tutorial). This builds, and can be passed into R
(even an Lmod
installation) by specifying the correct reticulate
python location:
Sys.setenv(RETICULATE_PYTHON = "~/miniconda3/envs/cell2cell/bin/python")
library(tidyverse, quietly = TRUE)
library(SingleCellExperiment, quietly = TRUE)
library(reticulate, quietly = TRUE)
library(magrittr, quietly = TRUE)
library(liana, quietly = TRUE)
# library(ExperimentHub, quietly = TRUE)
sce = readRDS("sce_temp.rds")
sce = liana_tensor_c2c(
sce=sce,
score_col='LRscore',
rank=7, # set to None to estimate for you data!
how='outer', # defines how the tensor is built
conda_env="cell2cell", # used to pass an existing conda env with cell2cell
use_available=TRUE # detect & load cell2cell if available
)
Oh, I guess as a prologue, that means I never actually got basilisk
to build the environment for me. Something about the location of pip
via a conda
yml
, and just calling pip install
inside the conda env.
Hi @rbutleriii,
Oh okay. Maybe in your case I would suggest checking liana-py x Tensor fully in Python, this would resolve all of the issues that you are having with reticulate. https://liana-py.readthedocs.io/en/latest/notebooks/liana_c2c.html
Though this line might be what is breaking it (reticulate is a funny package from my experience):
Sys.setenv(RETICULATE_PYTHON = "~/miniconda3/envs/cell2cell/bin/python")
gets the following error: