summarizeClonotypes: Get sample-level clonotype counts

summarizeClonotypesR Documentation

Get sample-level clonotype counts

Description

Takes a matrix of cell-level clonotype counts and sums them within groups (typically samples).

Usage

summarizeClonotypes(x, by, ...)

## S4 method for signature 'Matrix'
summarizeClonotypes(
  x,
  by,
  mode = c("sum", "tab"),
  lang = c("r", "cpp"),
  BPPARAM = SerialParam()
)

## S4 method for signature 'SingleCellExperiment'
summarizeClonotypes(
  x,
  by = "sample",
  contigs = "contigs",
  clonoStats = "clonoStats",
  ...
)

## S4 method for signature 'matrix'
summarizeClonotypes(x, by, ...)

## S4 method for signature 'clonoStats'
summarizeClonotypes(x, by, ...)

Arguments

x

A (usually sparse) matrix of cell-level clonotype counts (cells are rows and clonotypes are columns). Alternatively, a SingleCellExperiment with such a matrix stored in the colData.

by

A character vector or factor by which to summarize the clonotype counts. If x is a SingleCellExperiment object, this can also be a character, giving the name of the column from the colData to use as this variable. Similar to the group argument for clonoStats.

...

additional arguments.

mode

Type of summarization to perform. Default is 'sum', which sums clonotype abundances within each sample (or level of 'by'). Alternative is 'tab', which constructs a table of clonotype frequencies (ie. singletons, doubletons, etc.) by sample.

lang

Indicates which implementation of the "tab" summarization to use. Options are 'r' (default) or 'cpp'. Only used if non-integer clonotype abundances are present and mode = "tab".

BPPARAM

A BiocParallelParam object specifying the parallel backend for distributed clonotype assignment operations (split by group). Default is BiocParallel::SerialParam().

contigs

character. If x is a SingleCellExperiment, the name of the SplitDataFrameList in the colData of x containing contig information.

clonoStats

character. If x is a SingleCellExperiment, the name of the element in the metadata of x that contains the output of clonoStats. Must include cell-level clonotype assignments (ie. assignment = TRUE).

Value

If mode = 'sum', returns a matrix clonotype abundances where each row corresponds to a clonotype and each column a value of by (if by denotes sample labels, this is a matrix of sample-level clonotype counts). If mode = 'tab', returns a matrix of clonotype frequencies, where each row corresponds to a frequency (singletons, doubletons, etc.) and each column a value of by.

Examples

example(addVDJtoSCE)
x <- clonoStats(contigs, assignment = TRUE)
summarizeClonotypes(x, by = sce$sample)


kstreet13/VDJdive documentation built on May 27, 2023, 8:08 a.m.