forked from rformassspectrometry/PSMatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFragments.Rmd
More file actions
112 lines (85 loc) · 2.62 KB
/
Fragments.Rmd
File metadata and controls
112 lines (85 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
title: "MS2 fragment ions"
output:
BiocStyle::html_document:
toc_float: true
vignette: >
%\VignetteIndexEntry{MS2 fragment ions}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
%\VignettePackage{PSMatch}
%\VignetteDepends{mzR,mzID,BiocStyle,msdata}
---
```{r style, echo = FALSE, results = 'asis', message=FALSE}
BiocStyle::markdown()
```
**Package**: `r Biocpkg("PSMatch")`<br />
**Authors**: `r packageDescription("PSMatch")[["Author"]] `<br />
**Last modified:** `r file.info("Fragments.Rmd")$mtime`<br />
**Compiled**: `r date()`
```{r setup, message = FALSE, echo = FALSE}
library("PSMatch")
```
# Introduction
This vignette is one among several illustrating how to use the
`PSMatch` package, focusing on the calculation and visualisation of
MS2 fragment ions. For a general overview of the package, see the
`PSMatch` package manual page (`?PSMatch`) and references therein.
To illustrate this vignette, we will import and merge raw and
identification data from the `r Biocpkg("msdata")`. For details about
this section, please visit the
[Spectra](https://rformassspectrometry.github.io/Spectra/articles/Spectra.html)
package webpage.
Load the raw MS data:
```{r, message = FALSE}
(spf <- msdata::proteomics(pattern = "2014", full.names = TRUE))
library(Spectra)
sp <- Spectra(spf)
```
Load the identification data:
```{r}
(idf <- msdata::ident(pattern = "2014", full.names = TRUE))
id <- PSM(idf) |> filterPSMs()
id
```
Merge both:
```{r}
sp <- joinSpectraData(sp, id, by.x = "spectrumId", by.y = "spectrumID")
sp
```
In this example, we are going to focus the MS2 scan with index 5449
and its parent MS1 scan (index 5447, selected automatically with the
[filterPrecursorScan()](https://rformassspectrometry.github.io/Spectra/reference/MsBackend.html)
function).
```{r}
sp5449 <- filterPrecursorScan(sp, 5449)
```
```{r}
plotSpectra(sp5449[1], xlim = c(550, 1200))
abline(v = precursorMz(sp5449)[2], col = "red", lty = "dotted")
```
# Calculating fragment ions
The MS2 scan was matched to `SQILQQAGTSVLSQANQVPQTVLSLLR` (there was
obviously no match the the MS1 scan):
```{r}
sp5449$sequence
```
The `calculateFragments()` simply takes a peptide sequence as input
and returns a `data.frame` with the fragment sequences, M/Z, ion type,
charge and position.
```{r}
calculateFragments(sp5449$sequence[2])
```
# Visualising fragment ions
We can now visualise these fragments directly on the MS
spectrum. Let's first visualise the spectrum as is:
```{r}
plotSpectra(sp5449[2])
```
```{r}
plotSpectra(sp5449[2], labels = labelFragments, labelPos = 3)
```
# Session information
```{r si}
sessionInfo()
```