View source: R/calc-similarity.R
| calc_similarity | R Documentation | 
Calculate repertoire similarity
calc_similarity(
  input,
  data_col,
  cluster_col,
  method = abdiv::jaccard,
  chain = NULL,
  chain_col = global$chain_col,
  prefix = NULL,
  return_mat = FALSE,
  sep = global$sep
)
| 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, possible values 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_mat | Return a matrix with similarity values. 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 | 
Single cell object or data.frame with similarity values
plot_similarity(), calc_mds(), plot_mds()
# Calculate repertoire overlap
res <- calc_similarity(
  vdj_sce,
  data_col    = "clonotype_id",
  cluster_col = "orig.ident",
  method      = abdiv::jaccard
)
head(slot(res, "colData"), 1)
# Add a prefix to the new columns
# this is useful if multiple calculations are stored in the meta.data
res <- calc_similarity(
  vdj_sce,
  data_col    = "clonotype_id",
  cluster_col = "orig.ident",
  prefix      = "bcr_"
)
head(slot(res, "colData"), 1)
# Return a matrix instead of adding the results to the input object
calc_similarity(
  vdj_sce,
  data_col    = "clonotype_id",
  cluster_col = "orig.ident",
  return_mat  = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.