Wednesday, August 30, 2023

My conda environments for single cell analysis

Environment 1 - Automatic annotation_celltypist (successful)
 
 conda create --name annotation_celltypist
 conda activate annotation_celltypist
 conda install -c conda-forge mamba
 mamba install -c conda-forge scanpy python-igraph leidenalg
 pip install jupyter
 mamba install -c bioconda -c conda-forge celltypist
 pip install -U scarches
 pip install urllib - was automatically installed via scarches I think

 pip install "pandas<2.0.0"

=========================================

Environment 2 - scanpy (successful)

conda create --name sc_manual_annotation
conda activate sc_manual_annotation
conda install -c conda-forge mamba
mamba install -c conda-forge scanpy
pip install jupyter

=========================================

Environment 3 - counts_to_clustering + nichenet (successful)

conda create --name singlecell
conda activate singlecell
conda install -c conda-forge mamba
mamba install -c conda-forge scanpy python-igraph leidenalg
mamba install -c conda-forge altair matplotlib numpy pandas seaborn
pip install jupyter
pip install anndata2ri
pip install sccoda

In linux:
sudo apt install libcurl4-openssl-dev
sudo apt-get install libmkl-rt
sudo apt install libfontconfig1-dev
sudo apt-get install libcairo2-dev
sudo apt-get install  libharfbuzz-dev libfribidi-dev
sudo apt-get install libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
sudo apt install cmake


In R studio:
install.packages("SoupX")
install.packages("systemfonts", dependencies = TRUE)
remotes::install_github("davismcc/scater", dependencies = TRUE)
install.packages("Cairo")
install.packages("textshaping")
install.packages("ragg")
install.packages("ggraster")
BiocManager::install("scDblFinder")
BiocManager::install("BiocParallel")
BiocManager::install("scry")
install.packages("ggpubr")
library("devtools"); install_github("lme4/lme4",dependencies=TRUE)
BiocManager::install("ComplexHeatmap")
devtools::install_github("saeyslab/nichenetr")
install.packages("tidyverse")

## advise to self: dont install R packages in jupyter notebook install in Rstudio

 =========================================

Environment 4 - CITE-Seq data analysis (in Apple M2 Macbook) - successful

brew install --cask mambaforge 

mamba create -n scvi_mamba

mamba activate scvi_mamba

mamba install -y -c conda-forge  python=3.9 scanpy python-igraph leidenalg altair matplotlib numpy pandas seaborn scvi-tools muon

pip install jupyter

pip install --user scikit-misc

Issue 1: Sometimes mamba activate does not work in mac m2 notebooks and it would just throw only the following lines when trying to activate an environment.

% mamba activate scvi_mamba

Run 'mamba init' to be able to run mamba activate/deactivate

and start a new shell session. Or use conda to activate/deactivate.

Then, copy the following contents in .bash_profile to .zhsrc file


# >>> conda initialize >>>

# !! Contents within this block are managed by 'conda init' !!

......

# <<< conda initialize <<<

Now 

source ~/.zshrc


Issue 2: 

NotImplementedError: The operator 'aten::lgamma.out' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.

Solution: In the terminal run this before opening Jupyter notebook

% export PYTORCH_ENABLE_MPS_FALLBACK=1

Else, in the Jupyter notebook

% env PYTORCH_ENABLE_MPS_FALLBACK=1

In my case, I aborted my notebook and ran the command in terminal which then resolve the issue.


Environment 5 - RNA velocity - successful
conda create -n scvelo_env python=3.9
conda activate scvelo_env
conda install numpy scipy cython numba matplotlib scikit-learn h5py click
pip install notebook
pip install scanpy
pip install leidenalg
pip install scvelo
pip install pandas==1.1.5 
pip install numpy==1.21.1
pip install git+https://github.com/theislab/cellrank.git@main
pip install pandas==1.1.5 
pip install numpy==1.21.1
pip install rpy2
cellrank==2.0.0 scanpy==1.9.3 anndata==0.9.2 numpy==1.24.4 numba==0.57.1 scipy==1.10.1 pandas==2.0.3 pygpcca==1.0.4 scikit-learn==1.1.3 statsmodels==0.14.0 scvelo==0.3.0 pygam==0.8.0 matplotlib==3.7.1 seaborn==0.12.2

Environment 5 - Differential Gene Expression - successful

conda create -n deg
conda activate deg
 conda install -c conda-forge scanpy python-igraph leidenalg
 pip install jupyter
pip install diffxpy

Monday, August 28, 2023

Installing Singularity version: 3.6.3 in Ubuntu Linux

 I was facing the following error when installing singularity:

checking: host Go compiler (at least version 1.20)... not found! mconfig: could not complete configuration

Running the following commands in terminal, resolved the problem by installing singularity version: 3.6.3

Check this thread for more information: https://github.com/apptainer/singularity/issues/5099#issuecomment-1286798317


sudo apt-get update && \ sudo apt-get install -y build-essential \ libseccomp-dev pkg-config squashfs-tools cryptsetup sudo rm -r /usr/local/go export VERSION=1.13.15 OS=linux ARCH=amd64 # change this as you need wget -O /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/go${VERSION}.${OS}-${ARCH}.tar.gz && \ sudo tar -C /usr/local -xzf /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz echo 'export GOPATH=${HOME}/go' >> ~/.bashrc && \ echo 'export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin' >> ~/.bashrc && \ source ~/.bashrc curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0 mkdir -p ${GOPATH}/src/github.com/sylabs && \ cd ${GOPATH}/src/github.com/sylabs && \ git clone https://github.com/sylabs/singularity.git && \ cd singularity git checkout v3.6.3 cd ${GOPATH}/src/github.com/sylabs/singularity && \ ./mconfig && \ cd ./builddir && \ make && \ sudo make install singularity version