collapse_samples: Collapses multiple samples into a single sample by group

Description Usage Arguments Details Value Examples

View source: R/scMethrix_transforms.R

Description

Collapses multiple samples into a single sample by group

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
collapse_samples(
  scm = NULL,
  colname = NULL,
  trans = NULL,
  h5_dir = NULL,
  batch_size = 1e+05,
  n_threads = 1,
  replace = FALSE,
  verbose = TRUE
)

Arguments

scm

scMethrix; the single cell methylation experiment

colname

string; The colname from colData(scm) indicating which samples should be collapse together

trans

named vector of closures; The transforms for each assay in a named vector. Default NULL, meaning that operations for "counts" assay is sum(x, na.rm=TRUE), and for all other assays is mean(x, na.rm=TRUE)

h5_dir

string; The directory to use. Will be created if it does not exist. Default = NULL

batch_size

The number of CpGs to calculate at once. IRanges package.

n_threads

integer; Maximum number of parallel instances. Default = 1

replace

boolean; flag for whether to delete the contents of h5_dir before saving

verbose

boolean; Flag for outputting function status messages. Default = TRUE

Details

Multiple samples can be collapsed into a single meta-sample. Grouping for samples can be defined via colData. The collapse function can accept an arbitrary function for each assay on how to handle the collapsing (typically mean for scores, and sum for counts).

In the output object, colData() will contain a comma-delimited list of samples (Samples) that each group contains as well as the total number of CpGs in the group (n_Samples).

Reduced dimensionality data will be discarded.

Value

An scMethrix object

Examples

1
2
3
data('scMethrix_data')
colData(scMethrix_data)["Cluster"] = c("X","X","Y","Y")
collapse_samples(scMethrix_data, colname = "Cluster")

CompEpigen/scMethrix documentation built on Nov. 6, 2021, 3:09 p.m.