diff --git a/DESCRIPTION b/DESCRIPTION index bd883f5..5228a90 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "cp@fgcz.ethz.ch", role = c("aut", "cre"), @@ -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, diff --git a/NAMESPACE b/NAMESPACE index 0b41dc5..c8569f8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/plot.R b/R/plot.R new file mode 100644 index 0000000..b1f8eb1 --- /dev/null +++ b/R/plot.R @@ -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() +} diff --git a/man/dot-plotLockMassCorrection.Rd b/man/dot-plotLockMassCorrection.Rd new file mode 100644 index 0000000..d36e5ad --- /dev/null +++ b/man/dot-plotLockMassCorrection.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{.plotLockMassCorrection} +\alias{.plotLockMassCorrection} +\title{lock mass correction plot} +\usage{ +.plotLockMassCorrection(rawfile) +} +\arguments{ +\item{rawfile}{the name of the raw file containing the mass spectrometry data from the Thermo Fisher Scientific instrument.} +} +\value{ +a ggplot object +} +\description{ +lock mass correction plot +} +\examples{ +rawrr::sampleFilePath() |> rawrr:::.plotLockMassCorrection() +} +\references{ +rawDiag \doi{10.1021/acs.jproteome.8b00173} +} +\author{ +Christian Trachsel (2017), Christian Panse (2023) +}