How to calculate pseudo time for all cells with monocle3
0
0
Entering edit mode
4.4 years ago
xiaoguang ▴ 140

I use the latest version of monocle3 and follow the official tutorial to calculate the pseudotime ,but since there are two partitions in the calculation result, when I set the root node, half of my pseudotime is always gray. How can I do this for all Cell calculates pseudo time?

my code is like this:

cds <- preprocess_cds(cds, num_dim = 20)
cds <- reduce_dimension(cds,umap.n_neighbors = 20L)
cds <- cluster_cells(cds,resolution = 0.1)
cds <- learn_graph(cds)
##PF is the earliest sample
get_earliest_principal_node <- function(cds, time_bin="PF"){
  cell_ids <- which(colData(cds)[, "time"] == time_bin)
  closest_vertex <-
  cds@principal_graph_aux[["UMAP"]]$pr_graph_cell_proj_closest_vertex
  closest_vertex <- as.matrix(closest_vertex[colnames(cds), ])
  root_pr_nodes <-
  igraph::V(principal_graph(cds)[["UMAP"]])$name[as.numeric(names
  (which.max(table(closest_vertex[cell_ids,]))))]
  root_pr_nodes
}
cds <- order_cells(cds, root_pr_nodes=get_earliest_principal_node(cds))
names(table(partitions(cds)))
##1 2
scRNAseq monocle3 • 2.0k views
ADD COMMENT

Login before adding your answer.

Traffic: 2517 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6