dynverse / dyno

Inferring, interpreting and visualising trajectories using a streamlined set of packages 🦕
https://dynverse.github.io/dyno
Other
163 stars 32 forks source link

ti_slingshot not accepting dimred as priors #91

Closed Solyris83 closed 3 years ago

Solyris83 commented 3 years ago

Hi, I am running ti_slingshot as below

model_slingshot <- infer_trajectory(dataset, methods_selected[1], give_priors = c("start_id", "groups_id", "dimred") ,verbose=TRUE)

but the run throw this message

Warning message:
In .method_extract_priors(dataset, method$wrapper$inputs, give_priors) :
  Unknown priors requested: dimred

I am using the docker image found below.

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
dynverse/ti_slingshot   v1.0.3              02c1d9b974fb        12 months ago       3.04GB

I read the code below and it supports "dimred" as a prior just not sure if this is in the docker image. If not, is there any simple way to use the ti_slingshot.R below? https://github.com/dynverse/ti_slingshot/blob/master/package/R/ti_slingshot.R

rcannood commented 3 years ago

Hello @Solyris83 !

I should update dynmethods to use the newest version of each TI method soon. For now, you can manually pick the version of slingshot you would like using:

library(tidyverse)
library(dyno)

dataset <- example_dataset

# obtain priors
dimred <- prcomp(dataset$expression)$x[,1:2]
grouping <- kmeans(dimred, centers = 4)$cluster
start_id <- rownames(dimred)[[which.min(dimred[,1])]]

# add priors to dataset
dataset_with_prior <- dataset %>% add_prior_information(
  dimred = dimred,
  start_id = start_id,
  groups_id = grouping
)

# fetch newest version of slingshot
method <- create_ti_method_container("dynverse/ti_slingshot:v2.0.1")

# run slingshot
model_slingshot <- infer_trajectory(
  dataset = dataset_with_prior, 
  method = method(),
  give_priors = c("start_id", "groups_id", "dimred"), 
  verbose = TRUE
)

dynplot::plot_dimred(model_slingshot, dimred = dimred)

Has this solved your problem?

Kind regards, Robrecht

Solyris83 commented 3 years ago

HI Robrecht,

Yes, that did the trick! It made the warning message go away assumedly using the dimred now.

But the trajectory produced is not better, as in my criteria is that the trajectory should start from a cluster from a priori analysis, but now it starts further away from that. This probably should be a new question.

Just to be sure, the default space to infer trajectory from are the PCAs calculated from expression data, am I right? Reading the Slingshot Github issues messages I think this is the prefered space to work on for Slingshot at least. Probably I will stick to the previous one while I continue to stalk around in the Slingshot Github issue panel.

Thanks! Solyris

rcannood commented 3 years ago

Just to be sure, the default space to infer trajectory from are the PCAs calculated from expression data, am I right?

PCA is the default dimred for Slingshot in dyno, but in the paper Slingshot is presented in a DR-agnostic way -- that is, it is up to the user to choose a good DR method prior to running Slingshot, according to the author.

In my opinion, choosing your own DR prior to running Slingshot will strongly bias your results. However, there is not really a golden bullet of DR for performing TI either, so some finetuning definitely is needed. It would be nice if this could be done in a data-driven way, but alas, this doesn't exist yet. For now, the tweaking is left up to the user :).