The position x residue frequency table a sequence logo draws, returned as data
instead of a plot — the numeric complement to ggseqlogo_bylength() and the
generalisation of anchor_information_content(), which collapses this same
table to Shannon bits.
Usage
aa_position_frequency(
sequences,
length = NULL,
positions = NULL,
groups = NULL,
min_n = 10
)Arguments
- sequences
Character vector of peptide sequences.
- length
Peptide length to restrict to, or
NULL(default) for the modal length whenpositionsis alsoNULL, and for "all lengths" whenpositionsis given.- positions
Integer vector of positions to profile, or
NULL(default) for all positions of the fixedlength.- groups
Optional grouping vector, the same length as
sequences.- min_n
Minimum number of usable sequences per group; a group below this is dropped, since its frequencies would be noise. Default
10.
Value
A long data frame with Group, Position (integer, as supplied, so
negatives are preserved), PositionLabel (an ordered factor), AA,
Count, n_Sequences and Frequency. Zero rows when nothing is usable.
Details
Two modes:
lengthgiven (or bothlengthandpositionsNULL, which picks the modal length): only peptides of that length are used and every position1..lengthis profiled. This is the mode for an anchor-motif heatmap.positionsgiven withlength = NULL: peptides of all lengths are used and each position is resolved against that peptide's own length, soc(1, 2, -2, -1)profiles the two N-terminal and two C-terminal residues across a mixed-length set.
Negative positions count from the C-terminus (-1 is the last residue).
Examples
if (FALSE) { # \dontrun{
aa_position_frequency(pep_short$Sequence, groups = pep_short$Condition)
aa_position_frequency(pep_short$Sequence, positions = c(1, 2, -2, -1))
} # }