To install CellTypist and configure the environment, follow these steps:
1. Create a conda environment called "celltypist" with the command: conda create -n celltypist -c conda-forge r-base=4.1.2
2. Activate the conda environment with: conda activate celltypist
3. Install the required packages: conda install -c conda-forge r-seurat=4.1.0 -y, conda install -c conda-forge r-irkernel=1.3 -y, IRkernel::installspec(name='celltypist', displayname='r-celltypist'), conda install -c conda-forge scanpy=1.8.2 -y, /opt/conda/envs/celltypist/bin/pip3 install celltypist -i https://pypi.tuna.tsinghua.edu.cn/simple, conda install -c conda-forge r-reticulate=1.24 -y
4. Open a Python session and import the necessary packages: import celltypist, library(reticulate), scanpy = import("scanpy"), celltypist = import("celltypist"), pandas <- import("pandas"), numpy = import("numpy"), py_config()
5. Load the data using the Seurat package: library(Seurat), sce <- readRDS("~/upload/yy_zhang_data/scRNA-seq/pca.celltype.rds")
6. Subset the data for the "Myeloid" cell type: Myeloid <- subset(sce, cell_type=='Myeloid')
7. Convert the Seurat object to a scanpy object: adata.X = numpy$array(t(as.matrix(Myeloid[['RNA']]@counts)))
8. Set the observations for each cell: adata.obs = pandas$DataFrame(
[email protected][colnames(Myeloid[['RNA']]@counts),