POWSC_simulation: Simulate Datasets by POWSC

View source: R/09-POWSC.R

POWSC_simulationR Documentation

Simulate Datasets by POWSC

Description

This function is used to simulate datasets from learned parameters by Simulate2SCE function in POWSC package.

Usage

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

Arguments

parameters

A object generated by POWSC::Est2Phase()

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 and other variables are usually customed, so before simulating a dataset you must point it out.

return_format

A character. Alternative 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 POWSC, you can set extra parameters to simulate datasets.

The customed parameters you can set are below:

  1. nCells. In POWSC, you can set nCells directly by other_prior = list(nCells = 1000).

  2. nGroups. POWSC can only simulate two groups.

  3. de.prob. You can directly set other_prior = list(de.prob = 0.2) to simulate DEGs that account for 20 percent of all genes.

Examples

## Not run: 
ref_data <- SingleCellExperiment::counts(scater::mockSCE())

## estimation
estimate_result <- simmethods::POWSC_estimation(ref_data = ref_data,
                                                other_prior = NULL,
                                                verbose = TRUE,
                                                seed = 111)

## default setting
simulate_result <- simmethods::POWSC_simulation(
  parameters = estimate_result[["estimate_result"]],
  other_prior = NULL,
  return_format = "list",
  verbose = TRUE,
  seed = 111
)
## counts
counts <- simulate_result[["simulate_result"]][["count_data"]]
dim(counts)
## cell information
col_data <- simulate_result[["simulate_result"]][["col_meta"]]
table(col_data$group)
## gene information
row_data <- simulate_result[["simulate_result"]][["row_meta"]]
table(row_data$de_gene)


## Simulate 1000 cells (de.prob = 0.2)
simulate_result <- simmethods::POWSC_simulation(
  parameters = estimate_result[["estimate_result"]],
  other_prior = list(nCells = 1000,
                     de.prob = 0.2),
  return_format = "list",
  verbose = TRUE,
  seed = 111
)
## counts
counts <- simulate_result[["simulate_result"]][["count_data"]]
dim(counts)
## cell information
col_data <- simulate_result[["simulate_result"]][["col_meta"]]
table(col_data$group)
## gene information
row_data <- simulate_result[["simulate_result"]][["row_meta"]]
table(row_data$de_gene)

## End(Not run)


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