-
Notifications
You must be signed in to change notification settings - Fork 0
/
match-standards-serum-mix01.Rmd
executable file
·2702 lines (2001 loc) · 92.9 KB
/
match-standards-serum-mix01.Rmd
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Identifying mix01 standards in serum"
author: "Andrea Vicini, Vinicius Verri Hernandes, Johannes Rainer"
output:
rmarkdown::html_document:
highlight: pygments
toc: true
toc_float: true
toc_depth: 3
fig_width: 5
---
```{r, include = FALSE, cached = FALSE}
knitr::read_chunk("R/match-standards-chunks.R")
MIX <- 1
MATRIX <- "Serum"
POLARITY <- "POS"
## settings to find MS2 spectra for features. Be rather inclusive here.
FEATURE_MS2_PPM <- 20
FEATURE_MS2_TOLERANCE <- 0.05
```
```{r, libraries, echo = FALSE, message = FALSE}
```
```{r, general-settings, echo = FALSE, message = FALSE}
```
**Current version: 0.10.0, 2022-05-05.**
# Introduction
Mixes of standards have been solved in water or added to human serum sample
pools in two different concentration and these samples were measured with the
LC-MS setup from Eurac (used also to generate the CHRIS untargeted metabolomics
data). Assignment of retention time and observed ion can be performed for each
standard based on MS1 information such as expected m/z but also based on the
expected difference in signal between samples with low and high concentration of
the standards. Finally, experimental fragment spectra provide the third level of
evidence. Thus, the present data set allows to annotate features to standards
based on 3 levels of evidence: expected m/z, difference in measured intensity
and MS2-based annotation.
A detailed description of the approach is given in
[match-standards-introduction.Rmd](match-standards-introduction.Rmd).
The list of standards that constitute the present sample mix are listed below
along with the expected retention time and the most abundant adduct for positive
and negative polarity as defined manually in a previous analysis by Mar
Garcia-Aloy.
```{r, standards-table, echo = FALSE, results = "asis"}
```
# Data import
We next load the data and split it according to matrix and polarity.
```{r, data-import}
```
We next also load the reference databases we will use to compare the
experimental MS2 spectra against. Below we thus load HMDB and MassBank data. We
create in addition *neutral loss* versions of the databases. Since HMDB does not
provide precusor m/z values we assume the fragment spectra to represent `[M+H]+`
ions (respectively `[M-H]-` ions for negative polarity) and add the m/z for
these adducts as *precursor m/z*.
```{r, load-reference-databases, message = FALSE}
```
```{r, setup-ion-db, message = FALSE, echo = FALSE}
```
# Initial evaluation of available MS2 data
Before performing the actual analysis that involves chromatographic peak
detection and evaluation of feature abundances, we compare all experimental MS2
spectra against the reference libraries. This provides already a first hint for
which standards a valid MS2 spectrum was recorded (and hence would allow
annotation based on evidence 3) and what related retention time might be.
We first extract all MS2 spectra from the respective data files and process them
by first removing all peaks with an intensity below 5% of the highest peak
signal, then scaling all intensities to a value range between 0 and 100 and
finally remove all MS2 spectra with less than 2 peaks.
```{r prepare-all-ms2}
fls <- fileNames(data_all)[data_all$polarity == "POS"]
```
```{r, all-ms2}
```
We next match these spectra against all reference spectra from HMDB for the
standards in `r MIX_NAME`.
The settings for the matching are defined below. These will be used for all MS2
spectra similarity calculations. All matching spectra with a similarity larger
0.7 are identified.
```{r, compare-spectra-param}
```
Standards for which no MS2 spectrum in HMDB is present are listed in
the table below.
```{r, echo = FALSE, results = "asis"}
tmp <- std_dilution[!(std_dilution$HMDB %in% hmdb_std$compound_id), ]
pandoc.table(tmp[, c("name", "HMDB", "formula")], style = "rmarkdown",
caption = "Standards for which no reference spectrum is available")
```
The table below lists all standards and the number of matching reference spectra
(along with their retention times).
```{r, table-all-ms2-hmdb, echo = FALSE, results = "asis"}
```
We repeat the same analysis for the negative polarity data (code not shown
again).
```{r, echo = FALSE}
fls <- fileNames(data_all)[data_all$polarity == "NEG"]
```
```{r, all-ms2, echo = FALSE}
```
```{r, table-all-ms2-hmdb, echo = FALSE, results = "asis"}
```
We next perform the full analysis of the data set involving MS1 and MS2 data.
# Serum, positive polarity
We now perform the analysis on the samples with the standards solved in
serum acquired in positive polarity mode.
```{r}
POLARITY <- "POS"
data <- filterFile(data_all, which(data_all$polarity == POLARITY))
hmdb <- hmdb_pos
hmdb_nl <- hmdb_pos_nl
```
## Data pre-processing
We perform the pre-processing of our data set which consists of the
chromatographic peak detection followed by a peak refinement step to reduce peak
detection artifacts, the correspondence analysis to group peaks across samples
and finally the gap-filling to fill in missing peak data from samples in which
no chromatographic peak was detected.
Some notes on the settings for the pre-processing:
- The `bw` parameter for the correspondence is larger than usual because adding
the standards in higher concentrations caused considerable retention time
shifts for some. A higher `bw` will allow to group also mis-aligned
chromatographic peaks - but will not allow to discriminate between closely
eluting ions.
- The `binSize` was also slightly increased to avoid splitting of features with
similar m/z values.
```{r, preprocessing, eval = !file.exists(paste0(RDATA_PATH, "processed_data_", POLARITY, ".RData")), message = FALSE}
```
```{r, echo = FALSE}
load(paste0(RDATA_PATH, paste0("processed_data_", POLARITY, ".RData")))
data_FS <- filterFile(data, which(data$mode == "FS"),
keepFeatures = TRUE)
```
## Signal intensity difference
We compute the difference in (log2) signals between samples with high and low
concentration of the standards and calculate the p-value for this difference
using the Student's t-test.
```{r, abundance-difference}
```
## Identification of features matching standards
We now identify all features matching the any of the pre-defined set of adducts
for the standards of mix `r MIX`. Matching features are further subsetted to
those that show an at least twice as high signal in samples with high
concentration compared to those with low concentrations. Also, features with a
signal in low concentration but no detectable signal in high concentration are
removed.
```{r, define-adducts-pos}
```
```{r, match-features}
```
For most of the standards (`r length(unique(mD$target_name))` out of
`r nrow(std_dilution)`) in mix `r MIX` at least one feature was found
matching the standards adducts' m/z.
```{r, table-standard-no-feature, results = "asis", echo = FALSE}
```
In the next sections we investigate for each standard which assignment would be
the correct one or, for those for which no signal was detected, why that was the
case.
## Standards with matching features
While for some standards a matching feature was found we still need to evaluate
whether this matching is correct. For each standard we thus first evaluate the
EICs for all matching features, then we match their MS2 spectra (if available)
against reference libraries. To ensure correct assignment of a feature, its
retention time and eventually related MS2 spectra, we consider the following
criteria to determine the annotation confidence:
- feature(s) was/were found with m/z matching those of adduct(s) of the
standard.
- signal is higher for samples with higher concentration.
- MS2 spectra matches reference spectra for the standard (if available).
- MS2 spectra don't match MS2 spectra of other compounds.
### 3-Phosphoglyceric Acid
```{r, echo = FALSE}
std <- "3-Phosphoglyceric Acid"
```
```{r, table-feature-matches, results = "asis", echo = FALSE, message = FALSE}
```
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
A considerable number of features has been assigned to this standard based on
m/z matching. Based on their retention times, these seem however to represent
ions from different compounds.
The cleaned MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r mix01-serum-pos-3-phosphoglyceric-acid-ms2, echo = FALSE}
plot_spectra(std_ms2)
```
We next match the extracted MS2 spectra against the reference spectra for
`r std` from HMDB.
```{r mix01-serum-pos-3-phosphoglyceric-acid-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
It seems that no extracted MS2 spectra matches well the reference ones from
3-Phosphoglyceric Acid. The maximum score is around 0.08 and is attained by a
spectrum from FT02219. The only two matches with score greater than 0.07 are
shown below.
```{r mix01-serum-pos-3-phosphoglyceric-acid-mirror-hmdb, echo = FALSE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2, std_hmdb, 0.07,
ppm = csp@ppm, tolerance = csp@tolerance)
```
The spectra don't seem to match well.
In addition we compare all spectra against reference spectra from MassBank for
the selected standard.
```{r mix01-serum-pos-3-phosphoglyceric-acid-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
Since all the extracted MS2 spectra are associated to ions different from
[M+H]+ we also perform a comparison between the neutral loss spectra from HMDB
and MassBank.
```{r mix01-serum-pos-3-phosphoglyceric-acid-ms2-hmdb_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_hmdb_nl <- hmdb_nl[hmdb_nl$compound_id == hmdb_id]
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_hmdb_nl, csp_nl)
```
```{r mix01-serum-pos-3-phosphoglyceric-acid-mirror-hmdb_nl, echo = FALSE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2_nl, std_hmdb_nl, 0.03,
ppm = csp_nl@ppm, tolerance = csp_nl@tolerance)
```
The matches are not that good.
```{r mix01-serum-pos-3-phosphoglyceric-acid-ms2-mbank_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank_nl <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey), nl = TRUE)
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_mbank_nl, csp_nl)
```
```{r mix01-serum-pos-3-phosphoglyceric-acid-mirror-mbank_nl, echo = FALSE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2_nl, std_mbank_nl, 0.03,
ppm = csp_nl@ppm, tolerance = csp_nl@tolerance)
```
No good matches were found. In addition we match (**all**) the MS2 spectra for
the matched features against all spectra from HMDB or MassBank identifying
reference spectra with a similarity larger than 0.7. The results (if any spectra
matched) are shown in the two following tables.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, hmdb, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, mbank, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
For completeness, we also perform a neutral loss spectra comparison with HMDB
and MassBank.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2_nl, hmdb_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
```{r, echo = FALSE, message = FALSE, results = "asis", eval = ALL_NL_MATCH}
perform_match(std_ms2_nl, mbank_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
#### Summary
- From water and negative polarity, the expected retention time is 250 seconds:
- FT01851 (RT=267.4, `[M+H]+` ion): confidence level **D**.
- FT02127 (RT=253.2, `[M+NH4]+` ion): confidence level **D**.
### Acetylhistidine
```{r, echo = FALSE}
std <- "Acetylhistidine"
```
The table below lists all features that were matched to one of the adducts of
`r print(std)` that have in addition also on average a twice as high signal in
samples with higher concentrations than in those with lower concentrations.
```{r, table-feature-matches, results = "asis", echo = FALSE}
```
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
The cleaned MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r mix01-serum-pos-acetylhistidine-ms2, echo = FALSE}
plot_spectra(std_ms2)
```
Next we compare them against the reference spectra for `r std` from HMDB.
The results are shown in the heatmap below.
```{r mix01-serum-pos-acetylhistidine-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
Some of the MS2 spectra for FT02020 and FT02023 have a high similarity against
MS2 spectra from `r std`. Mirror plots for the best matching spectra are shown
below.
```{r mix01-serum-pos-acetylhistidine-mirror-hmdb, echo = TRUE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2, std_hmdb, 0.5,
ppm = csp@ppm, tolerance = csp@tolerance)
```
These matches are very nice. In addition we perform also the match against
reference spectra for that standard from MassBank.
```{r mix01-serum-pos-acetylhistidine-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
Surprisingly no spectrum matches MassBank.
FT02730 and FT02372 correspond to `[M+2Na-H]+` and `[M+Na]+` ions of `r std`.
We check if matches beetween neutral loss spectra would be found.
```{r mix01-serum-pos-acetylhistidine-ms2-hmdb_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_hmdb_nl <- hmdb_nl[hmdb_nl$compound_id == hmdb_id]
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_hmdb_nl, csp_nl)
```
The same spectra match also with their neutral loss versions.
```{r mix01-serum-pos-acetylhistidine-ms2-mbank_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank_nl <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey), nl = TRUE)
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_mbank_nl, csp_nl)
```
For Massbank we don't get any additional matches.
In addition we match (**all**) the MS2 spectra for the matched features against
all spectra from HMDB or MassBank identifying reference spectra with a
similarity larger than 0.7. The results (if any spectra matched) are shown in
the two following tables.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, hmdb, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, mbank, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
For completeness, we also perform a neutral loss spectra comparison with HMDB
and MassBank.
```{r, echo = FALSE, message = FALSE, results = "asis", eval = ALL_NL_MATCH}
perform_match(std_ms2_nl, hmdb_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
```{r, echo = FALSE, message = FALSE, results = "asis", eval = ALL_NL_MATCH}
perform_match(std_ms2_nl, mbank_nl,
sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
#### Summary
- FT02020 (RT=182.5, `[M+H]+` ion) matches MS2 spectra of `r std`. High
similarity matches against other compounds are from related compounds, but
differ in their precursor m/z. Confidence **A**.
- FT02372 (RT=180.5, `[M+Na]+` ion). Confidence **A-**.
- FT02730 (RT=175.3, `[M+2Na-H]+` ion). Confidence **A-**.
- Reference MS2: `[M+H]+` (FT02020): F08.S0632, F07.S0638; high
confidence. `[M+Na]+` (FT02372): F08.S0622; low confidence. `[M+2Na-H]+`
(FT02730): F07.S0623, F08.S0623; low confidence.
```{r, echo = FALSE}
## Get MS2 spectra:
ms2 <- std_ms2[c("FT02020_F08.S0632", "FT02020_F07.S0638",
"FT02372_F08.S0622",
"FT02730_F07.S0623", "FT02730_F08.S0623")]
ms2$confidence <- c("high", "high",
"low",
"low", "low")
```
```{r, add-ms2-spectra, echo = FALSE}
```
### Betaine
```{r, echo = FALSE}
std <- "Betaine"
```
The table below lists all features that were matched to one of the adducts of
`r print(std)` that have in addition also on average a twice as high signal in
samples with higher concentrations than in those with lower concentrations.
```{r, table-feature-matches, results = "asis", echo = FALSE}
```
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
The cleaned MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r mix01-serum-pos-betaine-ms2, echo = FALSE}
plot_spectra(std_ms2)
```
Next we compare them against the reference spectra for `r std` from HMDB.
The results are shown in the heatmap below.
```{r mix01-serum-pos-betaine-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
MS2 spectra for FT00644 (F07.S0573, F07.S0602, F08.S0601) match the reference
spectra from Betaine with high scores.
```{r mix01-serum-pos-betaine-mirror-hmdb, echo = TRUE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2, std_hmdb, 0.7,
ppm = csp@ppm, tolerance = csp@tolerance)
```
In addition we compare against MassBank spectra.
```{r mix01-serum-pos-betaine-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
The same MS2 spectra match, albeit with a lower similarity.
We check in addition if matches between neutral loss spectra would be found.
```{r mix01-serum-pos-betaine-ms2-hmdb_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_hmdb_nl <- hmdb_nl[hmdb_nl$compound_id == hmdb_id]
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_hmdb_nl, csp_nl)
```
Neutral loss spectra don't match because there seems to be an offset (by 1.008)
in the precursor m/z values.
```{r mix01-serum-pos-betaine-ms2-mbank_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank_nl <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey), nl = TRUE)
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_mbank_nl, csp_nl)
```
Note however that neutral loss spectra for the `[M+H]+` feature FT00644 and the
`[M+Na]+` feature FT01012 do match to some degree:
```{r}
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
plotSpectraMirror(std_ms2_nl["FT01012_F07.S0563"],
std_ms2_nl["FT00644_F07.S0573"], tolerance = 0.1)
```
In addition we match (**all**) the MS2 spectra for the matched features against
all spectra from HMDB or MassBank identifying reference spectra with a
similarity larger than 0.7. The results (if any spectra matched) are shown in
the two following tables.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, hmdb, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, mbank, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
For completeness, we also perform a neutral loss spectra comparison with HMDB
and MassBank (requiring a high similarity).
```{r, echo = FALSE, message = FALSE, results = "asis", eval = TRUE}
std_ms2_nl <- neutralLoss(std_ms2, PrecursorMzParam())
perform_match(std_ms2_nl, hmdb_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl, similarity = 0.9)
```
```{r, echo = FALSE, message = FALSE, results = "asis", eval = TRUE}
perform_match(std_ms2_nl, mbank_nl, similarity = 0.9,
sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
#### Summary
- MS2 spectra for FT00644 (RT=163.4, `[M+H]+` ion) matches Betaine with
confidence **B**.
- FT01012 (RT=161.3, `[M+Na]+` ion). Confidence level **B-**.
- Reference MS2: `[M+H]+` (FT00644): F07.S0573, F07.S0602, F08.S0601; high
confidence. `[M+Na]+` (FT01012): F07.S0563, F07.S0596, F08.S0576; low
confidence.
```{r, echo = FALSE}
## Get MS2 spectra:
ms2 <- std_ms2[c("FT00644_F07.S0573", "FT00644_F07.S0602", "FT00644_F08.S0601",
"FT01012_F07.S0563", "FT01012_F07.S0596", "FT01012_F08.S0576")]
ms2$confidence <- c("high", "high", "high",
"low", "low", "low")
```
```{r, add-ms2-spectra, echo = FALSE}
```
### C3 Carnitine
```{r, echo = FALSE}
std <- "C3 Carnitine"
```
The table below lists all features that were matched to one of the adducts of
`r print(std)` that have in addition also on average a twice as high signal in
samples with higher concentrations than in those with lower concentrations.
```{r, table-feature-matches, results = "asis", echo = FALSE}
```
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
The cleaned MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r , echo = FALSE}
plot_spectra(std_ms2)
```
Next we compare them against the reference spectra for `r std` from HMDB.
The results are shown in the heatmap below.
```{r mix01-serum-pos-c3-carnitine-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
```{r mix01-serum-pos-c3-carnitine-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
No reference spectrum is available in HMDB or MassBank.
In addition we match (**all**) the MS2 spectra for the matched features against
all spectra from HMDB or MassBank identifying reference spectra with a
similarity larger than 0.7. The results (if any spectra matched) are shown in
the two following tables.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, hmdb, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, mbank, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
For completeness, we also perform a neutral loss spectra comparison with HMDB
and MassBank.
```{r, echo = FALSE, message = FALSE, results = "asis", eval = TRUE}
std_ms2_nl <- neutralLoss(std_ms2, PrecursorMzParam())
perform_match(std_ms2_nl, hmdb_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl, similarity = 0.7)
```
```{r, echo = FALSE, message = FALSE, results = "asis", eval = TRUE}
perform_match(std_ms2_nl, mbank_nl, similarity = 0.7,
sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
#### Summary
- FT02651 (RT=163.8, `[M+NH4]+`): confidence level **D**.
### CDP
```{r, echo = FALSE}
std <- "CDP"
```
The table below lists all features that were matched to one of the adducts of
`r print(std)` that have in addition also on average a twice as high signal in
samples with higher concentrations than in those with lower concentrations.
```{r, table-feature-matches, results = "asis", echo = FALSE}
```
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
The cleaned MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r mix01-serum-pos-cdp-ms2, echo = FALSE}
plot_spectra(std_ms2)
```
Next we compare them against the reference spectra for `r std` from HMDB.
The results are shown in the heatmap below.
```{r mix01-serum-pos-cdp-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
Both spectra (F07.S0864 and F07.S0892) of feature FT06282 match to one
reference spectrum of CDP with high similarity.
```{r mix01-serum-pos-cdp-mirror-hmdb, echo = TRUE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2, std_hmdb, 0.7,
ppm = csp@ppm, tolerance = csp@tolerance)
```
Unfortunately, the match based on a single peak (note however that the precursor
peaks are also very close).
In addition we compare against MassBank spectra.
```{r mix01-serum-pos-cdp-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
No match against MassBank can be found.
We check in addition if matches between neutral loss spectra would be found.
```{r mix01-serum-pos-cdp-ms2-hmdb_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_hmdb_nl <- hmdb_nl[hmdb_nl$compound_id == hmdb_id]
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_hmdb_nl, csp_nl)
```
Not unexpectedly, the same spectra match also with their neutral losses.
```{r mix01-serum-pos-cdp-ms2-mbank_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank_nl <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey), nl = TRUE)
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_mbank_nl, csp_nl)
```
We don't have a good match against MassBank.
In addition we match (**all**) the MS2 spectra for the matched features against
all spectra from HMDB or MassBank identifying reference spectra with a
similarity larger than 0.7. The results (if any spectra matched) are shown in
the two following tables.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, hmdb, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, mbank, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
For completeness, we also perform a neutral loss spectra comparison with HMDB
and MassBank (requiring a high similarity).
```{r, echo = FALSE, message = FALSE, results = "asis", eval = TRUE}
std_ms2_nl <- neutralLoss(std_ms2, PrecursorMzParam())
perform_match(std_ms2_nl, hmdb_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl, similarity = 0.9)
```
```{r, echo = FALSE, message = FALSE, results = "asis", eval = TRUE}
perform_match(std_ms2_nl, mbank_nl, similarity = 0.9,
sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
#### Summary
- FT06282 (RT=260.8, `[M+H]+`): confidence level **B** (could be A, but match is
based on a single peak).
- Reference spectra: `[M+H]+` (FT06282): F07.S0892, F07.S0864; low confidence.
```{r, echo = FALSE}
## Define the feature (ion) and MS2 spectra to insert
fts <- data.frame(feature_id = c("FT06282"),
confidence_level = c("B"))
## Get MS2 spectra:
ms2 <- std_ms2[c("FT06282_F07.S0892", "FT06282_F07.S0864")]
ms2$confidence <- "low"
```
```{r, add-ions, echo = FALSE}
```
```{r, add-ms2-spectra, echo = FALSE}
```
### Creatine
```{r, echo = FALSE}
std <- "Creatine"
```
The table below lists all features that were matched to one of the adducts of
`r print(std)` that have in addition also on average a twice as high signal in
samples with higher concentrations than in those with lower concentrations.
```{r, table-feature-matches, results = "asis", echo = FALSE}
```
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
The cleaned MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r mix01-serum-pos-creatine-ms2, echo = FALSE}
plot_spectra(std_ms2)
```
Next we compare them against the reference spectra for `r std` from HMDB.
The results are shown in the heatmap below.
```{r mix01-serum-pos-creatine-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
MS2 spectra for FT00872 (F07.S0633 and F08.S0630) match with a low similarity
against reference spectra from HMDB. Mirror plots for these are shown below.
```{r mix01-serum-pos-creatine-mirror-hmdb, echo = TRUE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2, std_hmdb, 0.2,
ppm = csp@ppm, tolerance = csp@tolerance)
```
In addition we compare against MassBank spectra.
```{r mix01-serum-pos-creatine-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
Also here there is a single match with a low similarity.
We check in addition if matches between neutral loss spectra would be found.
```{r mix01-serum-pos-creatine-ms2-hmdb_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_hmdb_nl <- hmdb_nl[hmdb_nl$compound_id == hmdb_id]
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_hmdb_nl, csp_nl)
```
Neutral loss version of MS2 spectrum F07.S0621 for feature FT01669 matches the
(neutral loss) reference spectrum for creatine from HMDB - even better than the
MS2 spectra for FT00872.
```{r mix01-serum-pos-creatine-mirror-hmdb-nl, echo = TRUE, fig.cap = "Mirror plots"}
tmp_sel <- plot_select_ms2(std_ms2_nl, std_hmdb_nl, 0.5,
ppm = csp_nl@ppm, tolerance = csp_nl@tolerance)
```
Thus, FT01669 is truly an `[M+2Na-H]+` ion of `r std`.
```{r mix01-serum-pos-creatine-ms2-mbank_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank_nl <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey), nl = TRUE)
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_mbank_nl, csp_nl)
```
In addition we match (**all**) the MS2 spectra for the matched features against
all spectra from HMDB or MassBank identifying reference spectra with a
similarity larger than 0.7. The results (if any spectra matched) are shown in
the two following tables.
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, hmdb, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
```{r, echo = FALSE, message = FALSE, results = "asis"}
perform_match(std_ms2, mbank, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp)
```
For completeness, we also perform a neutral loss spectra comparison with HMDB
and MassBank (requiring a high similarity).
```{r, echo = FALSE, message = FALSE, results = "asis", eval = ALL_NL_MATCH}
std_ms2_nl <- neutralLoss(std_ms2, PrecursorMzParam())
perform_match(std_ms2_nl, hmdb_nl, sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl, similarity = 0.9)
```
```{r, echo = FALSE, message = FALSE, results = "asis", eval = ALL_NL_MATCH}
perform_match(std_ms2_nl, mbank_nl, similarity = 0.9,
sv = c("rtime", "target_name", "score"),
name = "target_name", param = csp_nl)
```
#### Summary
- MS2 spectra for FT00577, FT00579 and FT00580 match neutral loss spectra from
creatine, but their retention times are very different. Also, their MS2
spectra match those of creatinine.
- FT00872 (RT=176, `[M+H]+` ion): confidence **B-**: the MS2 spectrum F07.S0633
matches only `r std` with a low similarity.
- FT01669 (RT=173.3, `[M+2Na-H]+` ion): neutral loss spectrum of F07.S0621
matches reference spectrum with high simlarity. Confidence **B**.
- FT01309 (RT=175.4, `[M+Na]+` ion) inherit confidence from above - or drop
because the MS2 spectrum does not match any other?
- Reference spectra: `[M+H]+` (FT00872): F08.S0630 and F07.S0633; low
confidence. `[M+2Na-H]+` (FT01669): F07.S0621, F08.S0620; high
confidence. `[M+Na]+` (FT01309): F08.S0618; low confidence.
```{r, echo = FALSE}
## Get MS2 spectra:
ms2 <- std_ms2[c("FT00872_F08.S0630", "FT00872_F07.S0633",
"FT01669_F07.S0621", "FT01669_F08.S0620",
"FT01309_F08.S0618")]
ms2$confidence <- c("low", "low",
"high", "high",
"low")
```
```{r, add-ms2-spectra, echo = FALSE}
```
### Dimethylglycine
```{r, echo = FALSE}
std <- "Dimethylglycine"
```
The table below lists all features that were matched to one of the adducts of
`r print(std)` that have in addition also on average a twice as high signal in
samples with higher concentrations than in those with lower concentrations.
```{r, table-feature-matches, results = "asis", echo = FALSE}
```
Based on their retention time, it seems that these features represent signal
from several different compounds.
We next plot the EIC for the assigned feature and visually inspect these.
```{r, echo = FALSE}
plot_eics(data, std, feature_table, "SP", std_ms2)
```
The only MS2 spectra for the features matched to `r std` are shown below
(peaks with an intensity below 5% of the maximum peak and spectra with less
than 2 peaks were removed).
```{r mix01-serum-pos-dimethylglycine-ms2, echo = FALSE}
plot_spectra(std_ms2)
```
We next match the extracted MS2 spectrum against the reference spectra for
`r std` from HMDB.
```{r mix01-serum-pos-dimethylglycine-ms2-hmdb, echo = FALSE, fig.width = 5, fig.height = 5}
hmdb_id <- std_dilution$HMDB[std_dilution$name == std]
std_hmdb <- Spectra(cdb, filter = ~ compound_id == hmdb_id)
sim <- plot_ms2_similarity_heatmap(std_ms2, std_hmdb, csp)
```
One of the spectra matches the reference with a low similarity. Below we plot
this.
```{r mix01-water-pos-dimethylglycine-mirror-hmdb, echo = TRUE, fig.cap = "Mirror plots"}
std_ms2_sel <- plot_select_ms2(std_ms2, std_hmdb, 0.3, ppm = csp@ppm,
tolerance = csp@tolerance)
```
In addition
we compare it aginst the reference spectra from MassBank for the selected
standard.
```{r mix01-serum-pos-dimethylglycine-ms2-mbank, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey))
sim <- plot_ms2_similarity_heatmap(std_ms2, std_mbank, csp)
```
We don't obtain any better match. Since the extracted spectrum is associated to
an ion different from `[M+H]+` (`[M+2Na-H]+`) we also perform a comparison
between the neutral loss spectra from HMDB and MassBank.
```{r mix01-serum-pos-dimethylglycine-ms2-hmdb_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_hmdb_nl <- hmdb_nl[hmdb_nl$compound_id == hmdb_id]
std_ms2_nl <- neutralLoss(std_ms2, nl_param)
sim <- plot_ms2_similarity_heatmap(std_ms2_nl, std_hmdb_nl, csp_nl)
```
```{r mix01-serum-pos-dimethylglycine-ms2-mbank_nl, echo = FALSE, fig.width = 5, fig.height = 5}
std_mbank_nl <- get_mbank(mbank, inchikey = unique(std_hmdb$inchikey), nl = TRUE)
std_ms2_nl <- neutralLoss(std_ms2, nl_param)