Here phenopath method will be demonstrated clearly and hope that this document can help you.
Before simulating datasets, it is important to estimate some essential parameters from a real dataset in order to make the simulated data more real.
library(simmethods)
library(SingleCellExperiment)
# Load data
ref_data <- simmethods::data
MAF can only simulate datasets with bifurcation trajectory, so the estimation step may fail due to the intrinsic characteristics of real data.
estimate_result <- simmethods::phenopath_estimation(
ref_data = ref_data,
verbose = T,
seed = 10
)
# Estimating parameters using phenopath
After estimating parameter from a real dataset, we will simulate a dataset based on the learned parameters with different scenarios.
The reference data contains 160 cells and 4000 genes, if we simulate datasets with default parameters and then we will obtain a new data which has the same size as the reference data.
simulate_result <- simmethods::phenopath_simulation(
parameters = estimate_result[["estimate_result"]],
other_prior = NULL,
return_format = "SCE",
seed = 111
)
# nCells: 160
# nGenes: 4000
SCE_result <- simulate_result[["simulate_result"]]
dim(SCE_result)
# [1] 4000 160
In phenopath, we can set nCells
and nGenes
to specify the number of cells and genes.
Here, we simulate a new dataset with 2000 cells and 2000 genes:
simulate_result <- simmethods::phenopath_simulation(
parameters = estimate_result[["estimate_result"]],
return_format = "list",
other_prior = list(nCells = 2000,
nGenes = 2000),
seed = 11
)
# nCells: 2000
# nGenes: 2000
result <- simulate_result[["simulate_result"]][["count_data"]]
dim(result)
# [1] 2000 2000
Make sure that you have already installed several R packages:
if(!requireNamespace("dynwrap", quietly = TRUE)){install.packages("dynwrap")}
if(!requireNamespace("dyndimred", quietly = TRUE)){install.packages("dyndimred")}
if(!requireNamespace("dynplot", quietly = TRUE)){install.packages("dynplot")}
if(!requireNamespace("tislingshot", quietly = TRUE)){devtools::install_github("dynverse/ti_slingshot/package/")}
First we should wrap the data into a standard object:
dyn_object <- dynwrap::wrap_expression(counts = t(result),
expression = log2(t(result) + 1))
Next, we infer the trajectory using SlingShot which has been proved to be the most best method to do this:
model <- dynwrap::infer_trajectory(dataset = dyn_object,
method = tislingshot::ti_slingshot(),
parameters = NULL,
give_priors = NULL,
seed = 111,
verbose = TRUE)
However, the trajectory inference failed because of the inference method itself and we can choose MST method to try again.
Open your Docker Desktop and check your Docker execution status. If you do not install Docker, please turn to Docker homepage.
dynwrap::test_docker_installation(detailed = TRUE)
# ✔ Docker is installed
# ✔ Docker daemon is running
# ✔ Docker is at correct version (>1.0): 1.41
# ✔ Docker is in linux mode
# ✔ Docker can pull images
# ✔ Docker can run image
# ✔ Docker can mount temporary volumes
# ✔ Docker test successful -----------------------------------------------------------------
# [1] TRUE
model <- dynwrap::infer_trajectory(dataset = dyn_object,
method = "mst",
parameters = NULL,
give_priors = NULL,
seed = 111,
verbose = FALSE)
# Loading required namespace: dynmethods
Finally, we can plot the trajectory after performing dimensionality reduction:
dimred <- dyndimred::dimred_umap(dyn_object$expression)
dynplot::plot_dimred(model, dimred = dimred)
# Coloring by milestone
# Using milestone_percentages from trajectory
For more details about trajectory inference and visualization, please check dynverse.