Skip to content

Commit

Permalink
#2 label cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Oct 23, 2020
2 parents 0bdaa0e + 1d59d37 commit 08234f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
11 changes: 8 additions & 3 deletions R/rawR.R
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,21 @@ plot.rawRspectrum <- function(x, relative = TRUE, centroid = FALSE, SN = FALSE,
plot(x = x$centroid.mZ, y = x$centroid.intensity,
type = "h",
xlim = x$massRange,
ylim = c(0,1.1 * max(x$centroid.intensity)),
xlab = "Centroid m/z",
ylab = "Centroid Intensity",
frame.plot = FALSE, ...
)
# ylim = c(0, 1.1*max(x$ x$centroid.intensity))
# TODO(cp): label top 10 with z=, R=
i <- which.max(x$centroid.intensity)
text(x = x$centroid.mZ[i], y = x$centroid.intensity[i], pos = 4,
i <- order(x$centroid.intensity, decreasing = TRUE)[1:10]


text(x = x$centroid.mZ[i],
y = x$centroid.intensity[i],
pos = 3,
labels = paste(format(x$centroid.mZ[i], nsmall = 4),
"\nz = ", x$charges[i], "\nR = "), cex = 0.75)
"\nz = ", x$charges[i], "\nR = "), cex = 0.5)

}

Expand Down
31 changes: 21 additions & 10 deletions vignettes/JPR_TechnicalNote.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ scp fgcz-r-035.uzh.ch:/export/lv_iduzh06/projects/p1000/Proteomics/QEXACTIVEHF_2
-->

plotting
using biognosys iRT peptides [@Escher2012]
```{r plot.rawRspectrum, fig.cap="graphs a tandem mass spectrum of the LGGNEQVTR peptide.", error=TRUE}

using biognosys iRT peptides

```{r plot.rawRspectrum, fig.cap="graphs a tandem mass spectrum of the LGGNEQVTR peptide. The grey lines indicate the in-silico computed y-ions of the peptide sequence.", error=TRUE}
# http://fgcz-ms.uzh.ch/~cpanse/20181113_010_autoQC01.raw
# MD5 (20181113_010_autoQC01.raw) = a1f5df9627cf9e0d51ec1906776957ab
rawfile <- file.path(Sys.getenv('HOME'),
Expand All @@ -97,20 +99,25 @@ library(rawR)
S <- rawR::readSpectrum(rawfile, scan=c(9594, 11113, 11884, 12788, 12677, 13204,
13868, 14551, 16136, 17193, 17612))
plot(S[[1]])
plot(S[[1]], centroid=TRUE)
y <- c(175.1190, 276.1666, 375.2350, 503.2936, 632.3362, 746.3791, 803.4006,
# derived using https://CRAN.R-project.org/package=protViz
yion <- c(175.1190, 276.1666, 375.2350, 503.2936, 632.3362, 746.3791, 803.4006,
860.4221, 973.5061)
abline(v = yion, col='#88888888', lwd=5)
axis(3, yion, paste0("y",seq(1,length(yion))))
```

other recent application examples are descibed in [@Panse2020], [@protViz]
and [@Gehrig2020].


### Use Case II - Working with chromatograms - iRT regression
### Use Case II - iRT regression

```{r plot.rawRchromatogram, fig.cap="plots chromatograms (XIC) for a list of given target mass ranges. ", error=TRUE}
By applying linear regression one can convert observed peptide retention times (RTs) into dimensionless scores termed iRT values (iRTs) and *vice versa* [@Escher2012]. In addition, fitted iRT regression models provide highly valuable information about LC-MS run performance. In this example we show how easy it is to perform iRT regression in R by just using the raw measurement data, our package rawR, and well known base R functions supporting linear modeling. The first step is to estimate the empirical RTs of a peptide set with known iRT scores from a raw file. In the simplest case, this is achieved by computing an extracted ion chromatogram (XIC) for iRT peptide ions, given they were spiked into the sample matrix prior to data acquisition. Code chunk X demonstrates how the function `readChromatogram()` is called on the R command line to return a `rawRchromatogram` object. This object is printed for visual inspection.

```{r plot.rawRchromatogram, fig.cap="XICs iRT peptides", error=TRUE}
iRT <- c(487.2571, 547.2984, 622.8539, 636.8695, 644.8230, 669.8384, 683.8282,
683.8541, 699.3388, 726.8361, 776.9301)
Expand All @@ -119,11 +126,13 @@ names(iRT) <- c("LGGNEQVTR", "YILAGVENSK", "GTFIIDPGGVIR", "GTFIIDPAAVIR",
"TPVITGAPYEYR", "DGLDAASYYAPVR", "ADVTPADFSEWSK",
"LFLQFGAQGSPFLK")
C <- readChromatogram(rawfile, iRT, tol=10)
C <- readChromatogram(rawfile, mass = iRT, tol = 10, type = "xic", filter = "ms")
plot(C)
```


For regression, we now extract the RTs at the maximum of intensity traces stored in the chromatogram object and fit a linear model of the form $$rt = a \cdot score+b$$.

```{r iRTscoreFit, error=TRUE}
score <- c(-24.92, 19.79, 70.52, 87.23, 0, 28.71, 12.39, 33.38, 42.26, 54.62, 100)
rt <- sapply(C, function(x) x$times[which.max(x$intensities)[1]])
Expand All @@ -132,9 +141,11 @@ fit <- lm(rt ~ score )

```{r iRTscoreFitPlot, echo=FALSE, error=TRUE, fig.cap="graphs the retention time verus the retention time scores."}
plot(rt ~ score,
ylab='retention time [in min]',
pch=16,frame.plot = FALSE,asp=1); abline(fit, col='grey')
text(score, rt, substr(names(iRT),1,3),pos=3)
ylab = 'Retention time [min]',
xlab = "iRT score",
pch=16,frame.plot = FALSE)
abline(fit, col='grey')
#text(score, rt, substr(names(iRT),1,3),pos=3)
text(score, rt, iRT,pos=1,cex=0.5)
```

Expand Down

0 comments on commit 08234f8

Please sign in to comment.