Skip to contents

plot_mz_distribution() draws overlapping density fills for precursor m/z values at charge states \(z = +2\) and \(z = +3\), overlaid on a shaded instrument scan window. It adds a scan-window view alongside the package's length, GRAVY, and pI summaries.

Usage

plot_mz_distribution(
  result,
  scan_range = c(350, 1500),
  charge_states = 2:3,
  length_range = c(7L, 25L),
  show_rug = TRUE,
  title = NULL
)

Arguments

result

Accepted inputs:

  • A named list returned by evaluate_digest(). Valid peptides are extracted automatically using length_range, and m/z values are computed via calculate_peptide_mass().

  • A named list of evaluate_digest() results (multi-input mode). Produces a faceted plot with one panel per result.

  • A data.frame / tibble with a peptide column. m/z values are computed from sequences.

  • A data.frame / tibble with mz and charge_state columns (pre- computed m/z values; charge_states argument is ignored). If NULL or an unrecognised type, raises an error.

scan_range

Numeric vector of length 2 giving the instrument's MS1 scan window boundaries in m/z. Defaults to c(350, 1500) (typical DDA on Orbitrap / Q-TOF instruments). Use c(400, 1000) for targeted methods. If NULL or malformed, raises an error.

charge_states

Integer vector of charge states to compute. Defaults to 2:3. Ignored when result already contains an mz column.

length_range

Integer vector of length 2. Valid peptide length window used to filter input peptides. Defaults to c(7L, 25L). Read from result$params when a full evaluate_digest() result is supplied.

show_rug

Logical. When TRUE (default) a rug of individual peptide m/z values is added below the density fills at alpha = 0.30. If NULL, treated as FALSE.

title

Optional character string for the plot title. Auto-generated when NULL (default).

Value

A ggplot object showing overlapping density fills of precursor m/z values at each charge state, with shaded instrument scan window and per-charge-state window-coverage annotations.

Details

Peptides inside the active length window can still fall outside a selected MS1 scan window at the displayed charge states. The plot shows those values against the user-supplied window.

The function accepts four input types with the following precedence: (1) named list of evaluate_digest() results (multi-input mode, produces a faceted panel per result), (2) single evaluate_digest() result, (3) data.frame with a peptide column (m/z computed from sequences), (4) data.frame with pre-computed mz and charge_state columns.

See also

evaluate_digest() for the upstream digestion step, calculate_peptide_mass() for the underlying m/z calculation.

Other plot-distribution: plot_gravy_landscape(), plot_length_distribution(), plot_missed_cleavage_impact(), plot_pI_distribution()

Examples

if (requireNamespace("ggplot2", quietly = TRUE)) {
  bsa_path <- system.file("extdata", "P02769.fasta", package = "pepVet")
  res <- evaluate_digest(bsa_path, enzyme = "trypsin")
  p <- plot_mz_distribution(res)
  print(p)
}