Open curiegat opened 2 years ago
I modified the code to assign my initial nodes to cell_type1 from my cell_types info as below:
get_earliest_principal_node <- function(cds, whatever_you_name_it="cell_type1"){
cell_ids <- which(colData(cds)[, "cell_types"] == whatever_you_name_it)
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
}
Everything is the same as the tutorial script except for "cell_types" and "cell_type1". You may modify it to get what you want (e.g. "infected" and whatever colname you use from your metadata, in my case it was "cell_types").
Hi
Thank you for your suggestion, I tried to use the code but it gives me this error
However, I previously use this code and it is working
## this function is working; change the root bits from here - https://github.com/statOmics/tradeSeq/issues/38
get_earliest_principal_node_1 <- function(cds_try, time_bin="state"){
cell_ids <- which(colData(cds_try)[,"embryo.time.bin"] == time_bin)
closest_vertex <-
cds_try@principal_graph_aux[["UMAP"]]$pr_graph_cell_proj_closest_vertex
closest_vertex <- paste0("Y_", closest_vertex)
root <- names(which(igraph::degree(principal_graph(cds_try)[["UMAP"]]) == 1))
root <- root[root %in% closest_vertex]
root
}
Maybe you have other opinion why this one is working while previously give the error.
Thank you and best regards,
Agatha
Dear Developer team,
Many thanks for building such a fantastic software, however I have some question regarding my pseudo time analysis.
Currently I am working with a Seurat object from a TNK data. There are three clusters in there, and I create the cds object using the script below:
`# Using Seurat clustering
Read thr RDS file
parsing the gene names
parsing the cell information
parsing the sparse matrix
creating the cds object
creating and assigning the made-up partition
assigning the cluster information
assigning feature loading for the downstream module analysis
allow the package to create the graph
ordering and plotting the cluster
`
However, with this script we have to manually choose the roots. Meanwhile, we aim for the program to to specify the root of the trajectory programmatically. We wonder how do we do that and replace the embryo.time.bin (as specified in here [https://cole-trapnell-lab.github.io/monocle3/docs/trajectories/])with the information of sample Group (infected and naive) from Seurat object that we have.
We would like to share our RDS file from the Seurat object if it is necessary.
Looking forward for your help and suggestion.
Best regards,
Agatha