Skip to content

Commit

Permalink
add LockMassCorrection plot method
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Nov 30, 2023
1 parent 6bc2478 commit e45b9c0
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rawrr
Type: Package
Title: Direct Access to Orbitrap Data and Beyond
Version: 1.11.5
Version: 1.11.6
Authors@R: c(person("Christian", "Panse",
email = "[email protected]",
role = c("aut", "cre"),
Expand All @@ -12,7 +12,7 @@ Authors@R: c(person("Christian", "Panse",
comment = c(ORCID = "0000-0002-1847-885X")))
Depends: R (>= 4.1)
Imports:
grDevices, graphics, stats, utils
grDevices, graphics, stats, utils, ggplot2
Suggests:
BiocStyle (>= 2.5),
ExperimentHub,
Expand Down
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export(scanNumber)
export(tic)
export(validate_rawrrIndex)
export(validate_rawrrSpectrum)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,facet_wrap)
importFrom(ggplot2,geom_hline)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,theme_light)
importFrom(grDevices,hcl.colors)
importFrom(graphics,legend)
importFrom(graphics,lines)
Expand Down
46 changes: 46 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#R
# contains selected rawDiag plot methods
#
#' lock mass correction plot
#' @inheritParams readFileHeader
#' @return a ggplot object
#' @author Christian Trachsel (2017), Christian Panse (2023)
#' @references rawDiag \doi{10.1021/acs.jproteome.8b00173}
#' @examples
#' rawrr::sampleFilePath() |> rawrr:::.plotLockMassCorrection()
#' @importFrom ggplot2 ggplot aes_string geom_hline geom_line labs scale_x_continuous facet_wrap theme_light
.plotLockMassCorrection <- function(rawfile){
stopifnot("LM m/z-Correction (ppm):" %in% rawrr::readTrailer(rawfile))

message("Plotting lock mass correction for ", basename(rawfile))
message("reading index for ", basename(rawfile), "...")

rawfile |>
rawrr::readIndex() -> rawrrIndex

message("reading LM m/z-Correction (ppm) ...")
rawfile |>
rawrr::readTrailer("LM m/z-Correction (ppm):") |>
as.numeric() ->
LMCorrection

rawrrIndex$LMCorrection <- LMCorrection
rawrrIndex$rawfile <- basename(rawfile)

rawrrIndex |>
base::subset(rawrrIndex$MSOrder == "Ms") |>
ggplot2::ggplot(ggplot2::aes_string(x = "StartTime" , y = "LMCorrection")) +
ggplot2::geom_hline(yintercept = c(-5, 5), colour = "red3", linetype = "longdash") +
ggplot2::geom_line(size = 0.3) +
ggplot2::geom_line(stat = "smooth",
method= "gam",
formula = y ~ s(x, bs ="cs"),
colour = "deepskyblue3", se = FALSE) +
ggplot2::labs(title = "Lock mass correction plot") +
ggplot2::labs(subtitle = "Plotting lock mass correction value versus retention time") +
ggplot2::labs(x = "Retention Time [min]", y = "Lock Mass Correction [ppm]") +
ggplot2::scale_x_continuous(breaks = base::pretty(8)) +
# scale_y_continuous(breaks = scales::pretty_breaks(8), limits = c(-10, 10)) +
ggplot2::facet_wrap(~ rawfile) +
ggplot2::theme_light()
}
26 changes: 26 additions & 0 deletions man/dot-plotLockMassCorrection.Rd

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

0 comments on commit e45b9c0

Please sign in to comment.