Closed MikeDMorgan closed 4 years ago
Hmm, I didn’t really change anything in DPT in the current master version of destiny, but I can’t seem to reproduce this with it. Can you try it?
> packageVersion('destiny')
[1] ‘3.1.0’
> library(destiny)
> data(guo)
> dm <- DiffusionMap(guo)
> dpt <- DPT(dm)
> set.seed(4)
> dpt_random <- DPT(dm, tips = sample(ncol(guo), 3L))
> gridExtra::grid.arrange(plot(dpt), plot(dpt_random), ncol = 2)
Thanks, it appears to be an issue with values stored specifically in the $DPT1 slot of the DPT
object.
data(guo)
dm <- DiffusionMap(guo)
dpt <- DPT(dm)
set.seed(4)
dpt_random <- DPT(dm, tips = sample(ncol(guo), 3L))
guo.dm <- data.frame("DC1"=dm$DC1, "DC2"=dm$DC2, "DPT.Rand"=dpt_random$DPT1, "DPT.Set"=dpt$DPT1)
rand.dpt.p <- ggplot(guo.dm, aes(x=DC1, y=DC2, fill=DPT.Rand)) +
geom_point(shape=21) +
labs(title="Random tip") +
scale_fill_viridis()
set.dpt.p <- ggplot(guo.dm, aes(x=DC1, y=DC2, fill=DPT.Set)) +
geom_point(shape=21) +
labs(title="Set tip") +
scale_fill_viridis()
plot_grid(rand.dpt.p, set.dpt.p)
I see! It’s a misconception, DPTx doesn’t mean “tip x” but “cell x”, see the implementation for $.DPT
and [[.DPT
:
I need to document this better. What you want is
tips <- random_root(dm) # or c(cell_id1, cell_id2, …)
dpt <- DPT(dm, tips)
pt_vec <- dpt[tips[[1]], ]
You can also do pt_mat <- dpt[tips, ]
or pt_mat2 <- dpt[, tips]
, as you wish.
Thanks @flying-sheep - this definitely needs to be documented clearly!
Fixed in 33422f35210e75e4bb7b5cb486e80ef6c97e36e3. If you have any tips on how to make everything more discoverable, please tell me!
The current implementation of the DPT() function appears to ignore the user values of the
tips
argument. If I pass either the root cell, or even a randomly sampled index, to DPT(dm, tips=root), then I always receive exactly the same DPT ordering in theDPT
slot of the returned object.Having re-implemented the DPT code externally I can generate the "correct" ordering, therefore, I can only assume that somewhere the
tips
argument is overiden. This issue arises with destiny 3.0.0 (R 3.6.1, Bioc 3.10) as well as the previous Bioc 3.8 version in R 3.5.3.