scDesign3
Workflows
Standard Workflow
Simulate a single-cell RNA-seq dataset with a continuous developmental trajectory from a reference dataset and visualize the simulation quality.
library(scDesign3)
library(SingleCellExperiment)
library(ggplot2)
# Load example data
data("example_count", package = "scDesign3")
data("pseudotime", package = "scDesign3")
# Construct reference SingleCellExperiment
example_sce <- SingleCellExperiment(
assays = list(counts = example_count, logcounts = log1p(example_count)),
colData = DataFrame(pseudotime = pseudotime)
)
# Run simulation
set.seed(123)
example_simu <- scdesign3(
sce = example_sce,
assay_use = "counts",
celltype = NULL,
pseudotime = "pseudotime",
spatial = NULL,
other_covariates = NULL,
mu_formula = "s(pseudotime, k = 10, bs = 'cr')",
sigma_formula = "1",
family_use = "nb",
n_cores = 2,
usebam = FALSE,
corr_formula = "1",
copula = "gaussian",
DT = TRUE,
pseudo_obs = FALSE,
return_model = FALSE,
nonzerovar = FALSE
)
# Create simulated SingleCellExperiment
simu_sce <- SingleCellExperiment(
list(counts = example_simu$new_count),
colData = example_simu$new_covariate
)
logcounts(simu_sce) <- log1p(counts(simu_sce))
# Visualize and compare
compare_figure <- plot_reduceddim(
ref_sce = example_sce,
sce_list = list(simu_sce),
name_vec = c("Reference", "scDesign3"),
assay_use = "logcounts",
if_plot = TRUE,
color_by = "pseudotime",
n_pc = 20
)
plot(compare_figure$p_umap)
Input: A SingleCellExperiment reference object with pseudotime. Output: A simulated SingleCellExperiment object and a UMAP comparison plot.
When to Use
- To simulate realistic single-cell RNA-seq data with continuous developmental trajectories using
scdesign3().
- To generate synthetic count matrices that preserve the correlation structure and marginal distributions of a reference dataset.
- To visualize and compare simulated data against reference data using dimensionality reduction plots via
plot_reduceddim().
When NOT to Use
- For simple clustering or differential expression analysis without simulation, use packages like
scran or scater directly.
Data Requirements
- A
SingleCellExperiment object containing a raw count matrix in its assays (e.g., "counts").
- Cell covariates (such as cell types, pseudotime, or spatial coordinates) stored in the
colData of the SingleCellExperiment object.
Key Parameters
- sce: The input
SingleCellExperiment reference object.
- assay_use (
"counts"): The assay name in sce to use for simulation.
- pseudotime: Column name in
colData representing pseudotime.
- mu_formula: Formula for the mean parameter of the marginal distribution (e.g.,
"s(pseudotime, k = 10, bs = 'cr')").
- sigma_formula (
"1"): Formula for the dispersion/variance parameter.
- family_use (
"nb"): Distribution family to use (e.g., "nb" for negative binomial).
- copula (
"gaussian"): Copula type to model gene correlation (e.g., "gaussian" or "vine").
- n_cores (
2): Number of cores to use for parallel computation.
Best Practices
- Set a seed using
set.seed() before running scdesign3() and visualization functions to ensure reproducibility of the simulated counts and UMAP layouts.
- To model dispersion varying along pseudotime, set
sigma_formula to a spline formula (e.g., "s(pseudotime, k = 5, bs = 'cr')"), keeping in mind this increases computational cost.
Common Pitfalls
- High computational cost when modeling complex dispersion: Setting a complex
sigma_formula along pseudotime can significantly increase runtime. Fix: Keep sigma_formula = "1" unless variable dispersion is critical.
Alternatives
scater: For basic single-cell visualization and QC, but does not perform parametric simulation.
scran: For normalization and variance modeling, but not for generating synthetic datasets.
Citations
- Song, Dongyuan, and Qingyang Wang. 2026. "scDesign3: A unified probabilistic framework for single-cell and spatial omics simulation."
References
1---2name: scdesign33description: scDesign34---56# scDesign378## Workflows910### Standard Workflow1112Simulate a single-cell RNA-seq dataset with a continuous developmental trajectory from a reference dataset and visualize the simulation quality.1314```r15library(scDesign3)16library(SingleCellExperiment)17library(ggplot2)1819# Load example data20data("example_count", package = "scDesign3")21data("pseudotime", package = "scDesign3")2223# Construct reference SingleCellExperiment24example_sce <- SingleCellExperiment(25 assays = list(counts = example_count, logcounts = log1p(example_count)),26 colData = DataFrame(pseudotime = pseudotime)27)2829# Run simulation30set.seed(123)31example_simu <- scdesign3(32 sce = example_sce,33 assay_use = "counts",34 celltype = NULL,35 pseudotime = "pseudotime",36 spatial = NULL,37 other_covariates = NULL,38 mu_formula = "s(pseudotime, k = 10, bs = 'cr')",39 sigma_formula = "1",40 family_use = "nb",41 n_cores = 2,42 usebam = FALSE,43 corr_formula = "1",44 copula = "gaussian",45 DT = TRUE,46 pseudo_obs = FALSE,47 return_model = FALSE,48 nonzerovar = FALSE49)5051# Create simulated SingleCellExperiment52simu_sce <- SingleCellExperiment(53 list(counts = example_simu$new_count), 54 colData = example_simu$new_covariate55)56logcounts(simu_sce) <- log1p(counts(simu_sce))5758# Visualize and compare59compare_figure <- plot_reduceddim(60 ref_sce = example_sce, 61 sce_list = list(simu_sce), 62 name_vec = c("Reference", "scDesign3"),63 assay_use = "logcounts", 64 if_plot = TRUE, 65 color_by = "pseudotime", 66 n_pc = 2067)68plot(compare_figure$p_umap)69```70*Input: A SingleCellExperiment reference object with pseudotime. Output: A simulated SingleCellExperiment object and a UMAP comparison plot.*7172## When to Use73- To simulate realistic single-cell RNA-seq data with continuous developmental trajectories using `scdesign3()`.74- To generate synthetic count matrices that preserve the correlation structure and marginal distributions of a reference dataset.75- To visualize and compare simulated data against reference data using dimensionality reduction plots via `plot_reduceddim()`.7677## When NOT to Use78- For simple clustering or differential expression analysis without simulation, use packages like `scran` or `scater` directly.7980## Data Requirements81- A `SingleCellExperiment` object containing a raw count matrix in its assays (e.g., `"counts"`).82- Cell covariates (such as cell types, pseudotime, or spatial coordinates) stored in the `colData` of the `SingleCellExperiment` object.8384## Key Parameters85- **sce**: The input `SingleCellExperiment` reference object.86- **assay_use** (`"counts"`): The assay name in `sce` to use for simulation.87- **pseudotime**: Column name in `colData` representing pseudotime.88- **mu_formula**: Formula for the mean parameter of the marginal distribution (e.g., `"s(pseudotime, k = 10, bs = 'cr')"`).89- **sigma_formula** (`"1"`): Formula for the dispersion/variance parameter.90- **family_use** (`"nb"`): Distribution family to use (e.g., `"nb"` for negative binomial).91- **copula** (`"gaussian"`): Copula type to model gene correlation (e.g., `"gaussian"` or `"vine"`).92- **n_cores** (`2`): Number of cores to use for parallel computation.9394## Best Practices95- Set a seed using `set.seed()` before running `scdesign3()` and visualization functions to ensure reproducibility of the simulated counts and UMAP layouts.96- To model dispersion varying along pseudotime, set `sigma_formula` to a spline formula (e.g., `"s(pseudotime, k = 5, bs = 'cr')"`), keeping in mind this increases computational cost.9798## Common Pitfalls99- High computational cost when modeling complex dispersion: Setting a complex `sigma_formula` along pseudotime can significantly increase runtime. Fix: Keep `sigma_formula = "1"` unless variable dispersion is critical.100101## Alternatives102- `scater`: For basic single-cell visualization and QC, but does not perform parametric simulation.103- `scran`: For normalization and variance modeling, but not for generating synthetic datasets.104105## Citations106- Song, Dongyuan, and Qingyang Wang. 2026. "scDesign3: A unified probabilistic framework for single-cell and spatial omics simulation."107108## References109- Homepage: bioconductor.org/packages/scDesign3110- Vignette: https://bioconductor.org/packages/release/bioc/vignettes/scDesign3/inst/doc/scDesign3-quickstart-vignette.html