simulate_qcs: simulate_qcs

View source: R/simulate_qcs.R

simulate_qcsR Documentation

simulate_qcs

Description

Detailed simulation of QC metric distribution across whole experiment, assuming multiple celltypes, which are shared across different groups of samples ('sample groups'). Parameters are derived from real data and are hopefully reasonably realistic.

Usage

simulate_qcs(
  n_groups = 4,
  n_cells = 1e+05,
  cells_p_s = 2000,
  D = 3,
  K = 4,
  qc_names = c("log_counts", "log_feats", "logit_mito"),
  df = NULL,
  sel_ks = NULL
)

Arguments

n_groups

How many sample groups?

n_cells

How many cells in total to simulate

cells_p_s

Cells per sample, average value (i.e. default is that each sample has 2000 cells on average)

D

How many QC metrics do you want

K

How many mixture components should there be in total? (see Details)

qc_names

Names for QC metrics

df

Degrees of freedom to use for multivariate t-distributed data. Default is NULL, which gives multivariate distributions.

Details

Simulates QC metrics for whole experiment

The simulation first randomly generates K celltypes (= mixture components), each with its own mean and covariance matrix. It also generates parameters for n_groups, including: how many cells in each group; how many samples; which celltypes are present in that group; hyperparameters for outliers in that group.

Given these generated quantities, a set of QC metric vectors representing cells is drawn for each sample group, and combined into qc_dt. Each row in this data.table represents a cell, and has annotations showing

Value

list with multiple entries:

  • qc_ok: data.table of cell QC metrics before outlier perturbation

  • qc_out: data.table of cell QC metrics after outlier perturbation

  • x_ok, x_out: matrices of values in qc_ok, qc_out respectively

  • groups: vector of true sample groups

  • samples: vector of sample_ids

  • z: vector of true celltype / mixture component values

  • outliers: vector of outlier status (0/1)

  • group_sims: detailed list of simulation outputs for each sample group

  • expt_params: list of whole experiment-level parameters (e.g. celltype means and covariance matrices)


wmacnair/SampleQC documentation built on Nov. 18, 2022, 5 p.m.