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

increase plot resolution #92

Open helenhuangmath opened 3 years ago

helenhuangmath commented 3 years ago

Hi, thanks for developing dynverse/dyno package, it is very useful! I have two questions:

Q1. How could I increase resolution of the trajectory plot? How doesplot_dimred() decide the resolutions? I want to plot dot, not the hexagonal plot. I've tried to increase nbins and reduce bw, but those parameters do not work.. Are there any other parameters that I can adjust?

plot_dimred(
    model, size_cells = 0.1, label_milestones=F, 
    expression_source = dataset$expression, 
    grouping = dataset$grouping, nbins = 10000, bw=0.01 ) 
image

Q2. I tried dyno on 2 different datasets, surprisingly, both results show Slingshot is the top 1 method, stable and accurate... However, when I try different sampling subset of my data, the trajectories seem not stable enough. Do you have any general comments or suggestions how to get stable results?

Thank you very much!

rcannood commented 3 years ago

Hello @helenhuangmath !

Thanks for the kind words :)

Q1: The default behaviour of dynplot is to plot all the cells if there are less than 10000, or use 100 bins otherwise. You can see this by looking at the documentation of ?dynplot::plot_dimred:

You can override this behaviour by specifying hex_cells = 100 to always use hexagonal plots, or hex_cells = FALSE to always use dot plots.

Q2: For this question I would kindly refer you to the creator of Slingshot; Kelly @kstreet13 Street. In order to answer this question, I guess more information is needed: how many cells do you start with, how much do you subsample? How different do the results look?

Kind regards, Robrecht

kstreet13 commented 3 years ago

Hi all,

I'd be happy to help! As Robrecht said, any additional information about this instability would be useful. In general, I've found that the curve fitting process is comparatively more stable than the initial cluster-based MST. So, it might be helpful to add some manual supervision of the MST (via start.clus and end.clus) or even specify that the MST doesn't change from some baseline structure (which would require a bit more work, since it's not the intended usage, but should be doable).

Best, Kelly

helenhuangmath commented 3 years ago

Hi @rcannood and @kstreet13 , thanks again for your helpful suggestions!!

Now I get a better understanding of the algorithms and settings. But I'm still struggling with several questions... I appreciate your help.

Is it possible to increase the number of lineages? I expect more nodes in the trajectory based on our pre-identified Seurat clusters. How could I adjust number of milestones?

Is it possible to use pre-defined dimension reduction coordinates to generate trajectories? Since the default PCA dimred does work well for our data, as highlighted in the figure below. PCA may keep the global structure but we hope to keep the local structure which is more biologically meaningful.

I tried to add the dimension reduction, groups_id and known time course information in priors, but these priors seem not to affect results before and after adding them. Is it the correct way to set these prior information?

dataset <- add_prior_information(
    dataset,
    dimred = dimred_orig,
    start_id = startID,
    start_n = 1,
    end_n = NEnd, 
    groups_n = NCluster, 
    timecourse_discrete = obj$timepoint_num,
    groups_id = data.frame( cell_id=obj@meta.data$cell_ID, group_id=obj@meta.data$Clusters ) 
)

model <- infer_trajectory(dataset, method_use, verbose=T, mc_cores=2, ndim=2, 
                  give_priors=c("groups_id", "start_id","start_n", "end_n", "groups_n", "timecourse_discrete", "dimred")
 )
image

Thank you & Have a nice day! : )

kstreet13 commented 3 years ago

I'm not sure how this would be done in dyno, so I'll leave that for @rcannood, but regarding the dimensionality reduction: yes, if you use Slingshot directly, you can supply any dimensionality reduction you like (the PCA default in dyno is just a suggestion). And with as many clusters as you have, I'm fairly sure you would see more lineages, as well.