Collapses multiple samples into a single sample by group

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

Value

An scMethrix object

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.

Examples

data('scMethrix_data') colData(scMethrix_data)["Cluster"] = c("X","X","Y","Y") collapse_samples(scMethrix_data, colname = "Cluster")
#> Starting to collapse experiment...
#> Collapsing samples for the score assay...
#> Collapsing samples for the counts assay...
#> Rebuilding experiment...
#> Experiment collapsed into 2 sample groups in 0.35s
#> An object of class scMethrix #> n_CpGs: 286 #> n_samples: 2 #> assays: score, counts #> reduced dims: #> is_h5: FALSE #> Reference: hg19 #> Physical size: 42.1 Kb