observedMutations - Calculate observed numbers of mutations
observedMutations calculates the observed number of mutations for each
sequence in the input
observedMutations(db, sequenceColumn = "SEQUENCE_IMGT", germlineColumn = "GERMLINE_IMGT_D_MASK", regionDefinition = NULL, mutationDefinition = NULL, ambiguousMode = c("eitherOr", "and"), frequency = FALSE, combine = FALSE, nproc = 1)
data.framecontaining sequence data.
charactername of the column containing input sequences. IUPAC ambiguous characters for DNA are supported.
charactername of the column containing the germline or reference sequence. IUPAC ambiguous characters for DNA are supported.
- RegionDefinition object defining the regions and boundaries of the Ig sequences. If NULL, mutations are counted for entire sequence.
- MutationDefinition object defining replacement
and silent mutation criteria. If
NULLthen replacement and silent are determined by exact amino acid identity.
- whether to consider ambiguous characters as
"and"when determining and counting the type(s) of mutations. Applicable only if
germlineColumncontain(s) ambiguous characters. One of
c("eitherOr", "and"). Default is
logicalindicating whether or not to calculate mutation frequencies. Default is
logicalindicating whether for each sequence should the mutation counts for the different regions (CDR, FWR) and mutation types be combined and return one value of count/frequency per sequence instead of multiple values. Default is
- number of cores to distribute the operation over. If the
cluster has already been set the call function with
nproc= 0 to not reset or reinitialize. Default is
data.frame with observed mutation counts for each
sequence listed. The columns names are dynamically created based on the
regions in the
regionDefinition. For example, when using the
IMGT_V definition, which defines positions for CDR and
FWR, the following columns are added:
MU_COUNT_CDR_R: number of replacement mutations in CDR1 and CDR2 of the V-segment.
MU_COUNT_CDR_S: number of silent mutations in CDR1 and CDR2 of the V-segment.
MU_COUNT_FWR_R: number of replacement mutations in FWR1, FWR2 and FWR3 of the V-segment.
MU_COUNT_FWR_S: number of silent mutations in FWR1, FWR2 and FWR3 of the V-segment.
frequency=TRUE, R and S mutation frequencies are
calculated over the number of non-N positions in the speficied regions.
MU_FREQ_CDR_R: frequency of replacement mutations in CDR1 and CDR2 of the V-segment.
MU_FREQ_CDR_S: frequency of silent mutations in CDR1 and CDR2 of the V-segment.
MU_FREQ_FWR_R: frequency of replacement mutations in FWR1, FWR2 and FWR3 of the V-segment.
MU_FREQ_FWR_S: frequency of silent mutations in FWR1, FWR2 and FWR3 of the V-segment.
combine=TRUE, the mutations and non-N positions
are aggregated and a single
MU_FREQ value is returned
MU_FREQ: frequency of replacement and silent mutations in the specified region
Mutation counts are determined by comparing the input sequences (in the column specified
sequenceColumn) to the germline sequence (in the column specified by
germlineColumn). See calcObservedMutations for more technical details,
including criteria for which sequence differences are included in the mutation
counts and which are not.
The mutations are binned as either replacement (R) or silent (S) across the different
regions of the sequences as defined by
regionDefinition. Typically, this would
be the framework (FWR) and complementarity determining (CDR) regions of IMGT-gapped
nucleotide sequences. Mutation counts are appended to the input
# Subset example data data(ExampleDb, package="alakazam") db <- subset(ExampleDb, ISOTYPE == "IgG" & SAMPLE == "+7d") # Calculate mutation frequency over the entire sequence db_obs <- observedMutations(db, sequenceColumn="SEQUENCE_IMGT", germlineColumn="GERMLINE_IMGT_D_MASK", frequency=TRUE, nproc=1) # Count of V-region mutations split by FWR and CDR # With mutations only considered replacement if charge changes db_obs <- observedMutations(db, sequenceColumn="SEQUENCE_IMGT", germlineColumn="GERMLINE_IMGT_D_MASK", regionDefinition=IMGT_V, mutationDefinition=CHARGE_MUTATIONS, nproc=1)
calcObservedMutations is called by this function to get the number of mutations in each sequence grouped by the RegionDefinition. See IMGT_SCHEMES for a set of predefined RegionDefinition objects. See expectedMutations for calculating expected mutation frequencies.