calc_diversity: Calculate repertoire diversity

View source: R/calc-diversity.R

calc_diversityR Documentation

Calculate repertoire diversity

Description

Calculate repertoire diversity

Usage

calc_diversity(
  input,
  data_col,
  cluster_col = NULL,
  method = abdiv::simpson,
  downsample = FALSE,
  n_boots = 0,
  chain = NULL,
  chain_col = global$chain_col,
  prefix = paste0(data_col, "_"),
  return_df = FALSE,
  sep = global$sep
)

Arguments

input

Single cell object or data.frame containing V(D)J data. If a data.frame is provided, the cell barcodes should be stored as row names.

data_col

meta.data column containing values to use for calculating diversity, e.g. 'clonotype_id'

cluster_col

meta.data column containing cluster IDs to use for grouping cells when calculating diversity. If cluster_col is omitted, diversity index will be calculated using all cells.

method

Method to use for calculating diversity. A named list can also be passed to use multiple methods. The names should specify names for the output columns.

downsample

Downsample clusters to the same size when calculating diversity metrics

n_boots

Number of bootstrap replicates for calculating standard error, if n_boots is 0 this will be skipped.

chain

Chain to use for calculating diversity. To calculate diversity for a single chain, the column passed to the data_col argument must contain per-chain data such as CDR3 sequences. Set to NULL to include all chains.

chain_col

meta.data column containing chains for each cell

prefix

Prefix to add to new columns

return_df

Return results as a data.frame. If FALSE, results will be added to the input object.

sep

Separator used for storing per-chain V(D)J data for each cell

Value

Single cell object or data.frame with diversity metrics

See Also

plot_diversity()

Examples

# Calculate diversity for each cell cluster
res <- calc_diversity(
  vdj_sce,
  data_col    = "clonotype_id",
  cluster_col = "orig.ident",
  method      = abdiv::simpson
)

head(slot(res, "colData"), 1)


rnabioco/AVIDtools documentation built on Oct. 28, 2023, 10:23 a.m.