Lun2_simulation: Simulate Datasets by Lun2

View source: R/06-Lun2.R

Lun2_simulationR Documentation

Simulate Datasets by Lun2

Description

This function is used to simulate datasets from learned parameters by lun2Simulate function in Splatter package.

Usage

Lun2_simulation(
  parameters,
  other_prior = NULL,
  return_format,
  verbose = FALSE,
  seed
)

Arguments

parameters

A object generated by splatter::lun2Estimate()

other_prior

A list with names of certain parameters. Some methods need extra parameters to execute the estimation step, so you must input them. In simulation step, the number of cells, genes, groups, batches, the percent of DEGs are usually customed, so before simulating a dataset you must point it out. See Details below for more information.

return_format

A character. Alternatives choices: list, SingleCellExperiment, Seurat, h5ad. If you select h5ad, you will get a path where the .h5ad file saves to.

verbose

Logical. Whether to return messages or not.

seed

A random seed.

Details

In addtion to simulate datasets with default parameters, users want to simulate other kinds of datasets, e.g. a counts matrix with 2 or more cell groups. In Lun2, you can set extra parameters to simulate datasets.

The customed parameters you can set are below:

  1. nCells. In Lun2, you can not set nCells directly and should set cell.plates instead. For example, if you want to simulate 1000 cells, you can type other_prior = list(cell.plates = sample(1:3, 1000, replace = TRUE)) and you will get three plates or groups of cells. If you only want to simulate one plate or group, just type other_prior = list(cell.plates = rep(1, 1000))

  2. nGenes. You can directly set other_prior = list(nGenes = 5000) to simulate 5000 genes.

For more customed parameters in Lun2, please check splatter::Lun2Params().

References

Zappia L, Phipson B, Oshlack A. Splatter: simulation of single-cell RNA sequencing data. Genome biology, 2017, 18(1): 1-15. https://doi.org/10.1186/s13059-017-1305-0

Bioconductor URL: https://bioconductor.org/packages/release/bioc/html/splatter.html

Github URL: https://github.com/Oshlack/splatter

Examples

## Not run: 
ref_data <- simmethods::data
group_condition <- simmethods::group_condition
## group_condition must be a numeric vector
other_prior <- list(batch.condition = as.numeric(group_condition))
## Estimation
estimate_result <- simmethods::Lun2_estimation(ref_data = ref_data,
                                               other_prior = other_prior,
                                               verbose = TRUE,
                                               seed = 10)


# (1) Simulate 500 cells (Since we can not set nCells directly, so we can set
# cell.plates (a numeric vector)) and 2000 genes
simulate_result <- simmethods::Lun2_simulation(
  parameters = estimate_result[["estimate_result"]],
  other_prior = list(cell.plates = sample(1:2, 500, replace = TRUE),
                     nGenes = 2000),
  return_format = "list",
  verbose = TRUE,
  seed = 111
)
count_data <- simulate_result[["simulate_result"]][["count_data"]]
dim(count_data)
## col_data
col_data <- simulate_result[["simulate_result"]][["col_meta"]]
head(col_data)
## row_data
row_data <- simulate_result[["simulate_result"]][["row_meta"]]
head(row_data)

## End(Not run)


duohongrui/simmethods documentation built on June 17, 2024, 10:49 a.m.