Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems setting up the proper environment #67

Open
mariapozo opened this issue Dec 15, 2022 · 1 comment
Open

Problems setting up the proper environment #67

mariapozo opened this issue Dec 15, 2022 · 1 comment

Comments

@mariapozo
Copy link

I've been struggling with this package for several days, can't seem to figure out how this is supposed to be set up (I've never used R and don't have a lot of experience with this type of thing.

I'm on a Mac, using either Terminal or Rstudio to install the packages I'm supposed to have to run sceasy. But I'm very confused about where certain commands are supposed to executed from...

In RStudio I've installed sceasy and the Rstudio dev version of reticulate (https://github.com/rstudio/reticulate) and I've loaded the seurat object that I'm trying to convert.

In Terminal I've created a new conda environment, activated it, and installed the anndata package as instructed.

But when I go back to Rstudio to run sceasy, I get an error that there is no module named 'anndata'. So I tried to make sure I was using the conda environment that I opened by running the following in Rstudio: use_condaenv('myenv'). But I get the following error:

Error in use_python(python, required = required) :
Specified version of python '/Users/bme_admin/opt/miniconda3/envs/myenv/bin/python' does not exist.

I don't understand how the connection works between python, conda, and R in this situation and how to get them to be communicating... I don't fully understand which commands from the sceasy instructions are supposed to be used in Terminal vs in python vs in R.

What I'm trying to do should be pretty simple, I just want to convert this seurat object from the NIH repository (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=gse183852), filename GSE183852_DCM_Nuclei.Robj, into an h5ad file so I can explore it in python, which is what I'm more comfortable with. But I can't seem to understand how to set myself up correctly. Thank you in advance for any advice!

@tkakar
Copy link

tkakar commented Mar 10, 2023

@mariapozo I had issues in making it work as well. Here is the script that worked for me. Hope this helps you as well.

install.packages("devtools")
install.packages("reticulate")
install.packages("Seurat")

#!!!-----create and activate a conda enviroment (on your machine's terminal) using the following commands
#!!! conda create -n cellxgene python=3
#!!! conda activate cellxgene
#!!! ----- On mac I got an error around arm64 which was fixed by this next command
#!!! conda config --env --set subdir osx-arm64
#!!! pip install anndata

library(devtools)
devtools::install_github("cellgeni/sceasy")

Sys.setenv(RETICULATE_PYTHON = "path to miniconda3/envs/cellxgene/bin/python")
library(reticulate)
library(sceasy)
library(Seurat)

reticulate::py_discover_config()
reticulate::use_condaenv('/Users/tkakar/miniconda3/envs/cellxgene')
use_condaenv('/Users/tkakar/miniconda3/envs/cellxgene')

rdsObj<-readRDS('rdsFile')

sceasy::convertFormat(rdsObj, from="seurat", to="anndata",outFile='filename.h5ad')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants