Monocle3
Monocle3的安装
Monocle3示例代码
- 将Seurat对象转为cds对象
Seurat2Monocle3 <- function(Seurat_Object){
library(monocle3)
library(Seurat)
data <- as(as.matrix(Seurat_Object@assays$RNA@counts), 'sparseMatrix')
pd <- tumor@meta.data
fd <- data.frame(gene_short_name = row.names(data), row.names = row.names(data)) # 基因注释必须包含一列名为“gene_short_name”
cds <- new_cell_data_set(data,
cell_metadata = pd,
gene_metadata = fd)
return(cds)
}
tumor <- readRDS('../data8/tumor4_0830.RDS')
tumor_cds <- Seurat2Monocle3(tumor)
- 创建cds对象
tumor_cds <- Seurat2Monocle3(tumor)
- PCA降维
tumor_cds <- preprocess_cds(tumor_cds, num_dim = 100)
plot_pc_variance_explained(tumor_cds)
- UMAP可视化
tumor_cds <- reduce_dimension(tumor_cds, preprocess_method = 'PCA')
plot_cells(tumor_cds, color_cells_by="batch")
- MNN去批次效应
tumor_cds = align_cds(tumor_cds, alignment_group = "batch",alignment_k = 20)
tumor_cds = reduce_dimension(tumor_cds)
plot_cells(tumor_cds, color_cells_by="batch", label_cell_groups=FALSE)
plot_cells(tumor_cds, color_cells_by="scref17.MK")
plot_cells(tumor_cds, genes=c("GFAP","EGFR",'TOP2A','CDK1'))
- 聚类细胞
tumor_cds <- cluster_cells(tumor_cds)
plot_cells(tumor_cds, color_cells_by = "partition")
- 学习轨迹
tumor_cds <- learn_graph(tumor_cds)
plot_cells(tumor_cds,color_cells_by = "scref17.MK", cell_size = 0.5,label_cell_groups=FALSE)
- 排序细胞
# 手动鼠标选择起点
tumor_cds <- order_cells(tumor_cds)
# 手动指定选择起点
tumor_cds <- order_cells(tumor_cds, root_pr_nodes=c('Y_4','Y_8'))
plot_cells(tumor_cds,color_cells_by = "pseudotime")
- 3d轨迹图
cds_3d <- reduce_dimension(tumor_cds, max_components = 3)
cds_3d <- cluster_cells(cds_3d)
cds_3d <- learn_graph(cds_3d)
plot_cells_3d(cds_3d, color_cells_by="scref17.MK")
cds_3d <- order_cells(cds_3d)
plot_cells_3d(cds_3d, color_cells_by="scref17.MK")
参考
Blog: https://www.jianshu.com/p/e94cff521ebc
Tutorial:https://cole-trapnell-lab.github.io/monocle3/
Paper:https://www.nature.com/articles/s41586-019-0969-x
网友评论