CellphoneDB需要python环境,以Linux服务器安装为例,演示conda安装,并使用conda创建虚拟python隔离环境以安装CllphoneDB3
1、下载安装anaconda
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
2、root权限下修改权限
chmod 777 Miniconda3-latest-Linux-x86_64.sh
3、运行安装脚本
sh Miniconda3-latest-Linux-x86_64.sh
4、出现Do you accept license term? ---->yes
安装过程中出现
5、添加环境变量
sudo vim .bashrc
在尾部添加 (位置不一样,修改自己的位置)
export PATH="/home/xuran/miniconda3/bin:"$PATH
6、刷新环境变量
source .bashrc
conda安装结束
创建python虚拟环境并激活,安装CellphoneDB
#创建
conda create -n cellphonedb3 python=3.7
#激活
source activate cellphonedb3
#安装
pip install cellphonedb
提取seurat对象表达矩阵和注释用来进行CellPhoneDB分析
library(Seurat)
load(file = "07.肿瘤重新聚类分群/tumor.cluster.anned.rdata")
pbmc3k=subset(sce,subset=cell_type%in%c("Epithelial_cell","Macrophage","Monocyte","Mast_cell","B_cell","T_Cell","NK","DC"))
table(pbmc3k$cell_type)
rt=as.matrix(pbmc3k@assays$SCT@data)
gene=rownames(rt)
rt2=cbind(gene,rt)
write.table(rt2, '08.cellphone/cellphonedb_count.txt', sep='\t', quote=F,row.names = F,col.names = T)
meta_data <- cbind(rownames(pbmc3k@meta.data), pbmc3k@meta.data[,'cell_type', drop=F])
meta_data <- as.matrix(meta_data)
# meta_data[is.na(meta_data)] = "Unkown" # 细胞类型中不能有NA
write.table(meta_data, '08.cellphone/cellphonedb_meta.txt', sep='\t', quote=F, row.names=F)
可以看到之前已经创建的cellphonedb3环境
进入分析流程
#需要首先cd到刚准备的两个文件的目录下
cellphonedb method statistical_analysis cellphonedb_meta.txt cellphonedb_count.txt --threads 32 --counts-data gene_name
CellphoneDB v3添加了其他分析模式,具体参数请参照作者Github
结果保存在默认的out目录下
也可继续使用自带函数进行绘图可视化
cellphonedb plot dot_plot
cellphonedb plot heatmap_plot cellphonedb_meta.txt
具体参数请参照作者Github
对于结果的解读请自行查阅。
参考来源:
https://github.com/ventolab/CellphoneDB
https://blog.csdn.net/weixin_42362597/article/details/120428783
鸣谢:
I thank Dr.Jianming Zeng(University of Macau), and all the members of his bioinformatics team, biotrainee, for generously sharing their experience and codes.
问题交流:
Email: xuran@hrbmu.edu.cn