subsampleDb - Subsample repertoire
Description¶
subsampleDb will sample the same number of sequences for each gene, family
or allele (specified with mode) in data. Samples or subjects can
be subsampled independent by setting group.
Usage¶
subsampleDb(
data,
gene = "v_call",
mode = c("gene", "allele", "family"),
min_n = 1,
max_n = NULL,
group = NULL
)
Arguments¶
- data
data.framecontaining repertoire data.- gene
- name of the column in
datawith allele calls. Default isv_call. - mode
- one of
c("gene", "family", "allele")defining the degree of specificity regarding allele calls when subsetting sequences. Determines howdatawill be split into subsets from which the same number of sequences will be subsampled. See alsogroup. - min_n
- minimum number of observations to sample from each group. A group with less observations than the minimum is excluded.
- max_n
- maximum number of observations to sample for all
modegroups. IfNULL, it will be set automatically to the size of the smallest group. Ifmax_nis larger than the available number of sequences for anymodegroup, it will be automatically adjusted and the effectivemax_nused will be the size of the smallestmodegroup. - group
- columns containing additional grouping variables, e.g. sample_id.
These groups will be subsampled independently. If
max_nisNULL, amax_nwill be automatically set for eachgroup.
Value¶
Subsampled version of the input data.
Details¶
data will be split into gene, allele or family subsets (mode) from
which the same number of sequences will be subsampled. If mode=gene,
for each gene in the field gene from data, a maximum of
max_n sequences will be subsampled. Input sequences
that have multiple gene calls (ties), can be subsampled from any of their calls,
but these duplicated samplings will be removed, and the final
subsampled data will contain unique rows.
Examples¶
set.seed(1)
subsampleDb(AIRRDb)
# A tibble: 140 x 26
sequence_id sequence rev_comp productive v_call d_call j_call
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr>
1 162366_1230_1356_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD5~ IGHJ3~
2 053163_2319_0521_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD1~ IGHJ5~
3 175431_1170_2788_length=45~ NNNNNNN~ NA TRUE IGHV1~ IGHD2~ IGHJ3~
4 151778_3269_0501_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD5~ IGHJ6~
5 112230_0840_0227_length=45~ NNNNNNN~ NA TRUE IGHV1~ IGHD3~ IGHJ6~
6 176024_3740_2255_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD2~ IGHJ6~
7 070090_2629_3436_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD6~ IGHJ6~
8 007556_2294_3485_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD3~ IGHJ4~
9 240300_1635_0534_length=45~ NNNNNNN~ NA TRUE IGHV1~ IGHD2~ IGHJ6~
10 038750_0415_2078_length=44~ NNNNNNN~ NA TRUE IGHV1~ IGHD3~ IGHJ4~
# i 130 more rows
# i 19 more variables: sequence_alignment <chr>, germline_alignment <lgl>,
# junction <chr>, junction_aa <lgl>, v_cigar <lgl>, d_cigar <lgl>,
# j_cigar <lgl>, vj_in_frame <lgl>, stop_codon <lgl>, v_germline_end <lgl>,
# np1_length <dbl>, np2_length <dbl>, j_germline_end <lgl>,
# junction_length <dbl>, mutated_invariant <lgl>, indels <lgl>,
# d_5_trim <dbl>, d_3_trim <dbl>, j_5_trim <dbl>