宇宙免责声明:乱写的,引用部分侵删
官网的Subset cells by branch步骤cds_sub <- choose_graph_segments(cds)是交互式的,集群用不了,那么如何把想要选择的分支写在代码里?
首先尝试用修改参数设置起点和终点的choose_graph_segments(),以及手动提取细胞(详见链接),参考了这个github提问里的方法,但是报错了
cells.branch <- choose_graph_segments(
cds,
reduction_method = "UMAP",
starting_pr_node = "A",
ending_pr_nodes = c("B","C"),
return_list = F,
clear_cds = T
)
#报错
Error in choose_graph_segments(cds, reduction_method = "UMAP", starting_pr_node = "A", :
unused arguments (starting_pr_node = "A", ending_pr_nodes = c("B","C"))
Execution halted
另一种手动提取细胞的方法:根据细胞类型取cds子集
> class(cds)
[1] "cell_data_set"
attr(,"package")
[1] "monocle3"
> cds@
cds@preprocess_aux cds@principal_graph_aux cds@clusters cds@int_colData cds@rowRanges cds@assays cds@elementMetadata
cds@reduce_dim_aux cds@principal_graph cds@int_elementMetadata cds@int_metadata cds@colData cds@NAMES cds@metadata
> cds$
cds$Tissue cds$celltype cds$tech cds$Size_Factor
#各种取子集尝试但是都报错了
#报错1
cds <- subset(cds, celltype == c("A", "B","C"))
Error in eval(expr, as.env(envir, enclos)) : object 'celltype' not found
#报错2
cds <- subset(cds, subset=celltype %in% c("A", "B","C"))
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function '%in%': object 'celltype' not found
#报错3
cds <- cds[ colData(cds) %>% subset( celltype == c("A", "B","C") ) ]
Error in as.vector(subset) :
no method for coercing this S4 class to a vector
#报错4
cds <- cds[ colData(cds) %>% subset( (celltype == "A")|(celltype == "B")|(celltype == "C")) ]
Error in as.vector(subset) :
no method for coercing this S4 class to a vector
真的会谢
cds_sub <- cds[ ,cds$celltype == c("A", "B","C") ]
#检查下成功了
unique(cds_sub$celltype)
head(colData(cds_sub))
或者创建cds前就根据细胞类型subset
那对seurat对象就可以用subset啦,不想从头跑就优先尝试上面一个方法了
P.S. 想要umap一样记得保留之前的umap,简书里能搜到不再赘述。