Skip to contents

Calculate MDS coordinates based on a beta diversity metric.

Usage

calc_mds(
  input,
  data_col,
  cluster_col,
  method = "jaccard",
  chain = NULL,
  chain_col = global$chain_col,
  prefix = "",
  return_df = FALSE,
  sep = global$sep
)

Arguments

input

Object 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 pairwise similarity between clusters, e.g. 'clonotype_id'

cluster_col

meta.data column containing cluster IDs to use for calculating repertoire overlap

method

Method to use for comparing clusters and calculating MDS coordinates, available methods include:

chain

Chain to use for comparing clusters. To perform calculations using 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 set to 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 MDS coordinates

Examples

# Calculate MDS coordinates
res <- calc_mds(
  vdj_sce,
  data_col = "clonotype_id",
  cluster_col = "isotype"
)

# Calculate MDS coordinates based on IGK CDR3 sequences
res <- calc_mds(
  vdj_sce,
  data_col    = "cdr3",
  cluster_col = "isotype",
  chain       = "IGK"
)

# Change the method used for calculating repertoire similarity
res <- calc_mds(
  vdj_sce,
  data_col    = "clonotype_id",
  cluster_col = "isotype",
  method      = "horn_morisita"
)