官网给出的详细指南,只是可能大家打不开或者懒得去看E文。
第一步,下载CytoTRACE安装包。
wget https://cytotrace.stanford.edu/CytoTRACE_0.3.3.tar.gz
第二步,打开R或者Rstudio-server
# 安装依赖包
if (!requireNamespace("BiocManager", quietly = TRUE))install.packages("BiocManager")
BiocManager::install("sva")# 安装CytoTRACE
# PATH/TO/DIRECTORY 写自己的路径install.packages("devtools")
devtools::install_local("PATH/TO/DIRECTORY/CytoTRACE_0.3.3.tar.gz")Or
getwd()#获取路径,然后把CytoTRACE_0.3.3.tar.gz移动到相应位置
install.packages("devtools")
devtools::install_local("./CytoTRACE_0.3.3.tar.gz")
第三步,安装python相关的包
$ pip install scanoramaCT
$ pip install numpy# 官网原文
The iCytoTRACE() function in the R package requires 2 Python packages,
scanoramaCT, an adapted version of the original Scanorama code for application to CytoTRACE, and numpy.
The CytoTRACE() function will run without these dependencies,
but to enable application of CytoTRACE across multiple batches/datasets,
install the Python dependencies by running:
第四步,设置Python路径
# 这些是我调用conda环境的命令不用输入
# 不用输入
# 不用输入,快进到sys.setenv。
.libPaths(c('/data/anaconda3/envs/public/lib/R/library',.libPaths()))
current_paths <- .libPaths()
new_paths <- current_paths# 将第三个路径移到第一位
new_paths[1] <- current_paths[2]
new_paths[2] <- current_paths[1]
.libPaths(new_paths)
.libPaths()# 就是下面这句,因为我调用了public环境,所有python路径用conda中的。
Sys.setenv(RETICULATE_PYTHON="/data/anaconda3/envs/public/bin/python")
library(CytoTRACE)
第五步,测试
# 删除未表达的基因
expressed_genes <- rowSums(marrow_10x_expr > 0) > 0
marrow_10x_expr_filtered <- marrow_10x_expr[expressed_genes, ]# 调整表型标签长度
shortened_labels <- substr(marrow_10x_pheno, 1, 25)# 运行 CytoTRACE,并关闭快速模式
results <- CytoTRACE(marrow_10x_expr_filtered,enableFast = FALSE, ncores = 8, subsamplesize = 1000)# 可视化
plotCytoTRACE(results, phenotype = shortened_labels, gene = "Kit")