dynverse / dyngen

Simulating single-cell data using gene regulatory networks 📠
https://dyngen.dynverse.org
Other
73 stars 6 forks source link

making datasets for trajectory alignment #20

Closed Rsugihara01 closed 3 years ago

Rsugihara01 commented 4 years ago

Hello, I read your paper in biorxiv and I found that dyngen can simulate datasets for evaluating trajectory alignment as in Figure 6. I got interested in trying that, but I might have overlooked, I couldn't find how to make two datasets for trajectory alignment.

I tried to make these datasets by doing something like this below. I made one config from initialise_model() and apply generate_dataset() twice from same config.

set.seed(1) config <- initialise_model( ) data1 <- generate_dataset( config ) data2<- generate_dataset( config )

I could make two datasets, but I wasn't sure this is ok because this is using same set.seed(). Is this ok? or the paper did it differently?

Thank you,

rcannood commented 4 years ago

Hello @Rsugihara01,

Sorry for getting back to you only now.

The following code should do what you want:

Code ```r library(dyngen) # create the config object init_config <- initialise_model( backbone = backbone_linear(), num_cells = 500, num_targets = 250, num_hks = 50, gold_standard_params = gold_standard_default(census_interval = 1, tau = 0.05), simulation_params = simulation_default( # burn_time = 10, # total_time = 10, census_interval = 1, ssa_algorithm = ssa_etl(tau = 0.05), experiment_params = simulation_type_wild_type(num_simulations = 40) ), # set this to the number of cores in your system num_cores = 8, # set this to a directory where dyngen can cache some files download_cache_dir = "~/.cache/dyngen" ) # generate the genes and their kinetics model_common <- init_config %>% generate_tf_network() %>% generate_feature_network() plot_feature_network(model_common) # run the simulation once model_a <- model_common %>% generate_kinetics() %>% generate_gold_standard() %>% generate_cells() # run the simulation once more model_b <- model_common %>% generate_kinetics() %>% generate_gold_standard() %>% generate_cells() # if you don't have this package installed, install it with: # remotes::install_github("dynverse/dyngen_manuscript/package") # or else just copy paste the function from here: # https://github.com/dynverse/dyngen_manuscript/blob/ece4ea7d2781c2ab8b66529df6a5c4fa16f0087d/package/R/combine_models.R#L63 model_ab <- dyngen.manuscript::combine_models(list("left" = model_a, "right" = model_b)) %>% generate_experiment() # show a dimensionality reduction plot_simulations(model_ab) plot_gold_mappings(model_ab, do_facet = FALSE) # create a dynwrap dataset dataset <- wrap_dataset(model_ab) dynplot::plot_dimred(dataset) dynplot::plot_heatmap(dataset, features_oi = 25) ```

These are the last two plots: plot_dimred plot_heatmap

Does this answer your question?

Kind regards, Robrecht

Rsugihara01 commented 4 years ago

Thank you for your answer, @rcannood

The code worked and gave me back two trajectory exactly the way I wanted. I really appreciate your help.

Kind regards, RSugihara01

rcannood commented 3 years ago

I've summarised this information in a vignette which will be included in viash as of the next release.

Feel free to let me know if you have any further questions.

Kind regards, Robrecht