calc_mds: Perform multidimensional scaling

View source: R/calc-similarity.R

calc_mdsR Documentation

Perform multidimensional scaling

Description

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:

  • 'jaccard', Jaccard dissimilarity index implemented with abdiv::jaccard()

  • 'horn_morisita', Horn-Morisita index implemented with abdiv::horn_morisita()

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

See Also

plot_mds(), calc_similarity(), plot_similarity()

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"
)


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