Tips:
Tip1. 当前ccAFv2已经有Python和R版本,本文是R版本的安装和使用;
Tip2.ccAFv2依赖tensorflow 2.12.0,而tensorflow 2.12.0依赖python 3.9(可能3.8也可以,但3.11不行)。python 3.11会默认安装2.19版本,ccAFv2使用时会报错;
Tip3. ThresholdPlot() 函数得出的结果,值越大,可信度一般越高。后续如果没指定,默认为0.5。
1. tensorflow安装
python3.9 -m pip install tensorflow==2.12.0
install_tensorflow(
method = "auto",
version = "2.12.1",
conda_python_version = "3.9",
extra_packages = c("matplotlib", "numpy", "pandas", "scikit-learn")
)
2. ccAFv2安装
remotes::install_github('plaisier-lab/ccafv2_R/ccAFv2')
3. ccAFv2 running
3.1 Without Neural G0
Predict cell cycle states
seurat_obj = PredictCellCycle(seurat_obj,gene_id = "symbol",assay='RNA') ##注意参数的设置
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_DimPlot.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_ThresholdPlot.pdf')
ThresholdPlot(seurat_obj)
dev.off()
Adjust ccAFv2 threshold to 0.9
seurat_obj = AdjustCellCycleThreshold(seurat_obj, threshold=0.9)
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_DimPlot_T_0.9.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()
Adjust ccAFv2 threshold back to 0.5
seurat_obj = AdjustCellCycleThreshold(seurat_obj, threshold=0.5)
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_DimPlot_T_0.5.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()
3.2 With Neural G0
Predict cell cycle states
seurat_obj = PredictCellCycle(seurat_obj, include_g0=TRUE)
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_DimPlot_wNeuralG0.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_ThresholdPlot_wNeuralG0.pdf')
ThresholdPlot(seurat_obj)
dev.off()
Adjust ccAFv2 threshold to 0.9
seurat_obj = AdjustCellCycleThreshold(seurat_obj, threshold=0.9, include_g0=TRUE)
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_DimPlot_T_0.9_wNeuralG0.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()
Adjust ccAFv2 threshold back to 0.5
seurat_obj = AdjustCellCycleThreshold(seurat_obj, threshold=0.5, include_g0=TRUE)
Plot DimPlot colorized by cell cycle states
pdf('ccAFv2_DimPlot_T_0.5_wNeuralG0.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()
3.3 Cell cycle regression
Regress out cell cycle
seurat_obj = PrepareForCellCycleRegression(seurat_obj)
seurat_obj = SCTransform(seurat_obj, vars.to.regress = c("Late.G1_exprs1", "S_exprs2", "S.G2_exprs3", "G2.M_exprs4", "M.Early.G1_exprs5"))
Plot cell cycle regressed UMAP
seurat_obj = RunPCA(seurat_obj)
seurat_obj = RunUMAP(seurat_obj, dims=1:10)
pdf('ccAFv2_DimPlot_regressed.pdf')
DimPlot.ccAFv2(seurat_obj)
dev.off()