cole-trapnell-lab / monocle3

Other
330 stars 100 forks source link

The meaning of cds@principal_graph_aux[["UMAP"]]$pr_graph_cell_proj_closest_vertex #663

Closed tengdiyouying608 closed 1 year ago

tengdiyouying608 commented 1 year ago

Hi, I want to select root node programmatically,And I used the followed code successfully.But I don't understand . Are there anyone could tell me the data structures? get_earliest_principal_node <- function(cds, time_bin="130-170"){ cell_ids <- which(colData(cds)[, "embryo.time.bin"] == 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 }

Thanks.

yuw444 commented 1 year ago

Not part of the development team, but here is my understanding.

Every cell is associated with one vertex, the number of vertexes is less than the number of cells.

Essentially, you are trying to select the one vertex that has most of the members of your selected cells cell_ids.

brgew commented 1 year ago

Hi,

Please post questions to the Monocle3 Google discussion group

https://groups.google.com/g/monocle-3-users

Best Wishes, Brent