Perform additional clustering of sequences within groups

fine_clustering(
  ccdb,
  sequence_key,
  type,
  max_affinity = NULL,
  keep_clustering_details = FALSE,
  ...
)

Arguments

ccdb

A ContigCellDB() object

sequence_key

character naming column in contig_tbl with sequence

type

'AA' or 'DNA'

max_affinity

numeric naming the maximal affinity for the sparse affinity matrix that is constructed. Not currently used.

keep_clustering_details

logical -- should output of fine_cluster_seqs be kept as a list column

...

Arguments passed on to fine_cluster_seqs

big_memory_brute

attempt to cluster more than 4000 sequences? Clustering is quadratic, so this will take a long time and might exhaust memory

method

one of 'substitutionMatrix' or 'levenshtein'

substitution_matrix

a character vector naming a substitution matrix available in Biostrings, or a substitution matrix itself

Value

ContigCellDB() object with updated contig_tbl and cluster_tbl

Examples

library(dplyr)
data(ccdb_ex)
ccdb_ex_small = ccdb_ex
ccdb_ex_small$cell_tbl = ccdb_ex_small$cell_tbl[1:200,]
ccdb_ex_small = cdhit_ccdb(ccdb_ex_small,
sequence_key = 'cdr3_nt', type = 'DNA', cluster_name = 'DNA97',
identity = .965, min_length = 12, G = 1)
ccdb_ex_small = fine_clustering(ccdb_ex_small, sequence_key = 'cdr3_nt', type = 'DNA')
#> Calculating intradistances on 329 clusters.
#> Summarizing

# Canonicalize with the medoid contig is probably what is most common
ccdb_medoid = canonicalize_cluster(ccdb_ex_small)
#> Filtering `contig_tbl` by `is_medoid`, override by setting `contig_filter_args == TRUE`

# But there are other possibilities.
# To pass multiple "AND" filter arguments must use &
ccdb_umi = canonicalize_cluster(ccdb_ex_small,
contig_filter_args = chain == 'TRA' & length > 500, tie_break_keys = 'umis',
contig_fields = c('chain', 'length'))
#> Subset of `contig_tbl` has 157 rows for 329 clusters. Filling missing values and breaking ties 
#> with umis.
ccdb_umi$cluster_tbl %>% dplyr::select(chain, length) %>% summary()
#>     chain               length      
#>  Length:329         Min.   : 503.0  
#>  Class :character   1st Qu.: 558.0  
#>  Mode  :character   Median : 607.0  
#>                     Mean   : 620.0  
#>                     3rd Qu.: 665.5  
#>                     Max.   :1006.0  
#>                     NA's   :186