Closed jma1991 closed 5 years ago
This is indeed not supposed to happen!
Could you give me a minimum reproducible example? I can't seem to replicate it with an example of my own.
Kind regards, Robrecht
library(dyno)
set.seed(1)
mod <- dyntoy::generate_dataset(
model = dyntoy::model_multifurcating(num_branchpoints = 1, max_degree = 4)
)
plot_dimred(
mod,
"pseudotime",
pseudotime = calculate_pseudotime(mod),
label_milestones = TRUE
)
mod2 <- mod %>% add_root(root_milestone_id = "M4")
plot_dimred(
mod2,
"pseudotime",
pseudotime = calculate_pseudotime(mod2),
label_milestones = TRUE
)
Sure, here is a link to an example dataset and script to reproduce the problem: https://www.dropbox.com/sh/1uh7ilwujfai2o5/AACJaPTR0cW8102fFSYGI94-a?dl=0
Thanks, James
Thanks for bringing this bug to light! The problem only occurred when calculating pseudotime of a trajectory where the root milestone has more than one transition. The devel branch should solve your problem. At the next release of dynwrap, the bug fix will be merged into the master branch :)
Thanks for the quick fix, many thanks!
You're welcome :)
Just a quick demonstration:
library(tidyverse)
library(dyno)
library(M3Drop)
sce <- readRDS("~/Downloads/dynverse/example.rds")
dat <- wrap_expression(
expression = t(logcounts(sce)),
counts = t(counts(sce)),
)
mod <- infer_trajectory(dat, "slingshot", seed = 1701)
before <- plot_dimred(mod, label_milestones = TRUE, pseudotime = calculate_pseudotime(mod))
mod2 <- add_root(mod, root_milestone_id = "1")
after <- plot_dimred(mod2, label_milestones = TRUE, pseudotime = calculate_pseudotime(mod))
patchwork::wrap_plots(before + labs(title = "Before rooting"), after + labs(title = "After rooting"))
ggsave("~/plot.png", width = 8, height = 4)
After calculating a trajectory and changing the root milestone I want to colour the trajectory by the pseudotime:
plot_dimred(mod, "pseudotime", pseudotime = calculate_pseudotime(mod))
However, the pseudotime scores for cells in a particular branch returned by the calculate_pseudotime function are infinite:
I assumed that pseudotime would be calculated from the root milestone in either direction?
Package versions: