clonalCluster: Clustering adaptive receptor sequences by edit distance

View source: R/clonalCluster.R

clonalClusterR Documentation

Clustering adaptive receptor sequences by edit distance

Description

This function uses edit distances of either the nucleotide or amino acid sequences of the CDR3 and V genes to cluster similar TCR/BCRs together. As a default, the function takes the input from combineTCR, combineBCR or combineExpression and amends a cluster to the data frame or meta data. If exportGraph is set to TRUE, the function returns an igraph object of the connected sequences.

Usage

clonalCluster(
  input.data,
  chain = "TRB",
  sequence = "aa",
  samples = NULL,
  threshold = 0.85,
  group.by = NULL,
  exportGraph = FALSE
)

Arguments

input.data

The product of combineTCR, combineBCR or combineExpression.

chain

Indicate if both or a specific chain should be used - e.g. "both", "TRA", "TRG", "IGH", "IGL".

sequence

Clustering based on either "aa" or "nt".

samples

The specific samples to isolate for visualization.

threshold

The normalized edit distance to consider. The higher the number the more similarity of sequence will be used for clustering.

group.by

The column header used for to group contigs. If (NULL), clusters will be calculated across samples.

exportGraph

Return an igraph object of connected sequences (TRUE) or the amended input with a new cluster-based variable (FALSE).

Value

Either amended input with edit-distanced clusters added or igraph object of connect sequences

Examples

# Getting the combined contigs
combined <- combineTCR(contig_list, 
                        samples = c("P17B", "P17L", "P18B", "P18L", 
                                    "P19B","P19L", "P20B", "P20L"))

sub_combined <- clonalCluster(combined[c(1,2)], 
                              chain = "TRA", 
                              sequence = "aa")


ncborcherding/scRepertoire documentation built on April 27, 2024, 8:34 p.m.