Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: PSMatch
Title: Handling and Managing Peptide Spectrum Matches
Version: 1.15.3
Version: 1.17.1
Authors@R:
c(person(given = "Laurent", family = "Gatto",
email = "laurent.gatto@uclouvain.be",
Expand Down Expand Up @@ -61,8 +61,9 @@ Suggests:
License: Artistic-2.0
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
VignetteBuilder: knitr
BugReports: https://github.com/RforMassSpectrometry/PSM/issues
URL: https://github.com/RforMassSpectrometry/PSM
biocViews: Infrastructure, Proteomics, MassSpectrometry
Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ importFrom(ProtGenerics,adjacencyMatrix)
importFrom(ProtGenerics,calculateFragments)
importFrom(QFeatures,reduceDataFrame)
importFrom(Spectra,peaksData)
importFrom(Spectra,precursorCharge)
importFrom(Spectra,spectraData)
importFrom(Spectra,spectraVariables)
importFrom(grDevices,n2mfrow)
Expand Down
11 changes: 10 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# PSMatch 1.15

## PSMatch 1.17.1

- Added parameter `z` in `plotSpectraPTM()` and set it to `1:precursorCharge(x)`
by default when it used to only display charge 1 before.

## PSMatch 1.17.0

- New Bioconductor devel.

## PSMatch 1.15.3

- Adjusted documentation on `addCarbamidomethyl = TRUE` in
Expand Down Expand Up @@ -166,4 +175,4 @@

## Changes in 0.99.0

- Prepare package for Bioconductor submission.
- Prepare package for Bioconductor submission.
12 changes: 9 additions & 3 deletions R/fragments-label.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
##' whether labels should be fragment ions, , or their m/z values. If the
##' latter, then the m/z values are named with the ion labels.
##'
##' @param z `numeric()` or `list()`. Charge states passed to
##' [calculateFragments()]. A plain vector is applied uniformly to all
##' spectra; a list of the same length as `x` applies per-spectrum charge
##' states. Default is `1L`.
##'
##' @param ... additional parameters (except `verbose`) passed to
##' [calculateFragments()] to calculate fragment m/z values to be
##' added to the spectra in `x`.
Expand Down Expand Up @@ -87,7 +92,7 @@
##' ## By default used in `plotSpectraPTM()`.
##' plotSpectraPTM(sp)
labelFragments <- function(x, tolerance = 0, ppm = 20,
what = c("ion", "mz"), ...) {
what = c("ion", "mz"), z = 1L, ...) {
stopifnot(requireNamespace("Spectra"))
stopifnot(inherits(x, "Spectra"))
what <- match.arg(what)
Expand All @@ -99,7 +104,8 @@ labelFragments <- function(x, tolerance = 0, ppm = 20,
stopifnot("sequence" %in% Spectra::spectraVariables(x[j]))
y <- Spectra::spectraData(x[j])[["sequence"]]
x_data <- v[[j]]
y_data <- calculateFragments(y, verbose = FALSE, ...)
z_j <- if (is.list(z)) z[[j]] else z
Comment thread
guideflandre marked this conversation as resolved.
Outdated
y_data <- calculateFragments(y, verbose = FALSE, z = z_j, ...)

y_data <- split(y_data, y_data$peptide)

Expand Down Expand Up @@ -129,4 +135,4 @@ labelFragments <- function(x, tolerance = 0, ppm = 20,
super_labels <- unlist(super_labels, recursive = FALSE)
attr(super_labels, "group") <- k
super_labels
}
}
30 changes: 26 additions & 4 deletions R/plotSpectra-PTM.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,20 @@
##' details on this, see the appropriate vignette by running
##' `vignette("Fragments", package = "PSMatch")
##'
##' @param z `numeric()` or `list()` passed to `calculateFragments()` via
##' `labelFragments()`. A plain vector is applied uniformly to all spectra;
##' a list of the same length as `x` applies per-spectrum charge states.
##' When `NULL` (default), each spectrum uses `1:precursorCharge` for that
##' spectrum, falling back to `1L` when the precursor charge is missing.
##'
##' @param ... additional parameters to be passed to the `labelFragments()`
##' and `calculateFragments()` functions.
##'
##' @importFrom graphics layout par
##'
##' @importFrom grDevices n2mfrow
##'
##' @importFrom Spectra spectraVariables
##' @importFrom Spectra spectraVariables precursorCharge
##'
##' @author Johannes Rainer, Sebastian Gibb, Guillaume Deflandre, Laurent Gatto
##'
Expand Down Expand Up @@ -172,6 +178,7 @@ plotSpectraPTM <- function(x, deltaMz = TRUE, ppm = 20,
fixedModifications = NULL,
variableModifications = NULL,
addCarbamidomethyl = TRUE,
z = NULL,
...) {
if (!("sequence" %in% Spectra::spectraVariables(x))) {
stop("Missing 'sequence' in Spectra::spectraVariables(x)")
Expand All @@ -196,21 +203,36 @@ plotSpectraPTM <- function(x, deltaMz = TRUE, ppm = 20,
xi
})
})
## in case spectrum-specific charges states are given
if (is.list(z) && length(z) == length(x)) {
Comment thread
guideflandre marked this conversation as resolved.
Outdated
expansion_counts <- lengths(parts)
z <- rep(z, times = expansion_counts)
}

x <- do.call(c, unlist(parts, recursive = FALSE))
}

## Build per-spectrum charge state list when z is not provided.
## Done after modifications for correct length if variable mods used.
if (is.null(z)) {
charges <- Spectra::precursorCharge(x)
z <- lapply(charges, function(ch) {
if (!is.na(ch) && ch > 0L) seq_len(ch) else 1L
})
}

nsp <- length(x)
old_par <- par(no.readonly = TRUE)
on.exit(par(old_par))

if (length(main) != nsp) main <- rep(main[1], nsp)

labels <- labelFragments(x, ppm = ppm, what = "ion",
addCarbamidomethyl = addCarbamidomethyl, ...)
addCarbamidomethyl = addCarbamidomethyl, z = z, ...)

if (deltaMz) { ## Generate deltaMzData labels for .plot_single_spectrum_PTM
deltaMzData <- labelFragments(x, ppm = ppm, what = "mz",
addCarbamidomethyl = addCarbamidomethyl, ...)
addCarbamidomethyl = addCarbamidomethyl, z = z, ...)
layout_matrix <- .make_layout_matrix(length(labels))
layout(layout_matrix,
heights = rep(c(5, 1), length.out = nrow(layout_matrix)))
Expand Down Expand Up @@ -353,7 +375,7 @@ plotSpectraPTM <- function(x, deltaMz = TRUE, ppm = 20,
.(basename(spectraData(x)[["dataOrigin"]])) *
"/scan: " * .(spectraData(x)[["scanIndex"]]) *
"/rt: " * .(round(spectraData(x)[["rtime"]], 2L)) *
"/charge: " * .(spectraData(x)[["charge"]]) *
"/charge: " * .(spectraData(x)[["precursorCharge"]]) *
"/peptide: " * bold(.(peptide_sequence))
)

Expand Down
2 changes: 1 addition & 1 deletion man/ConnectedComponents.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PSM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/PSMatch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions man/labelFragments.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/plotSpectraPTM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions tests/testthat/_snaps/plotSpectraPTM/deltamz-false.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions tests/testthat/_snaps/plotSpectraPTM/deltamz-true.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading