-
Notifications
You must be signed in to change notification settings - Fork 1
/
molecules.Rmd
84 lines (73 loc) · 3.4 KB
/
molecules.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
---
title: "Metabolite Cards"
output: html_document
---
```{r setupx, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r libraries, message=FALSE}
library(CompoundDb)
library(MetaboCoreUtils)
```
```{r nl}
nl <- data.frame(rbind(
c("[M+H-H2O]+", calculateMass("H2O"), 1),
c("[M+H-2(H2O)]+", calculateMass("H2OH2O"), 1),
c("[M+H-H2O-NH3]+", calculateMass("H2ONH3"), 1),
c("[M+H-H2O-CO]+", calculateMass("H2OCO"), 1),
c("[M+H-NH3]+", calculateMass("NH3"), 1),
c("[M+H-C3H9N]+", calculateMass("C3H9N"), 1),
c("[M+H-Glu]+", calculateMass(subtractElements("C5H9NO4", "H2O")), 1),
c("[M+H-Gly]+", calculateMass(subtractElements("C2H5NO2", "H2O")), 1),
c("[M+H-Gly-H2O]+", calculateMass("C2H5NO2"), 1),
c("[M-H-NH3]-", calculateMass("NH3"), 0),
c("[M-H-H2O]-", calculateMass("H2O"), 0),
c("[M-H-CO2]-", calculateMass("CO2"), 0),
c("[M-H-C2H2O]-", calculateMass("C2H2O"), 0),
c("[M-H-C2H4O]-", calculateMass("C2H4O"), 0),
c("[M-H-C2H4O2]-", calculateMass("C2H4O2"), 0),
c("[M-H-CONH]-", calculateMass("CONH"), 0),
c("[M-H-C3H9N]-", calculateMass("C3H9N"), 0)
))
ions <- data.frame(rbind(
c("[Asp+H]+", mass2mz(calculateMass("C4H7NO4"), "[M+H]+"), 1),
c("[Glu+H]+", mass2mz(calculateMass("C5H10N2O3"), "[M+H]+"), 1),
c("[Glu+H-NH3]+", mass2mz(calculateMass(subtractElements("C5H10N2O3", "NH3")), "[M+H]+"), 1),
c("[(i)Leu+H]+", mass2mz(calculateMass("C6H13NO2"), "[M+H]+"), 1),
c("[(i)Leu+H-H2O-CO]+", mass2mz(calculateMass(subtractElements("C6H13NO2", "H2OCO")), "[M+H]+"), 1),
c("[Phe+H]+", mass2mz(calculateMass("C9H11NO2"), "[M+H]+"), 1),
c("[Phe+H-H2O-CO]+", mass2mz(calculateMass(subtractElements("C9H11NO2", "H2OCO")), "[M+H]+"), 1),
c("[Pro+H]+", mass2mz(calculateMass("C5H9NO2"), "[M+H]+"), 1),
c("[Tyr+H]+", mass2mz(calculateMass("C9H11NO3"), "[M+H]+"), 1),
c("[Tyr+H-H2O-CO]+", mass2mz(calculateMass(subtractElements("C9H11NO3", "H2OCO")), "[M+H]+"), 1),
c("[Val+H-H2O-CO]+", mass2mz(calculateMass(subtractElements("C5H11NO2", "H2OCO")), "[M+H]+"), 1),
c("Flavonoid 1,3A+", mass2mz(calculateMass("C7H4O4"), "[M+H]+"), 1),
c("[Ala-H]-", mass2mz(calculateMass("C3H7NO2"), "[M-H]-"), 0),
c("[Glu-H-NH3]-", mass2mz(calculateMass(subtractElements("C5H10N2O3", "NH3")), "[M-H]-"), 0),
c("[Leu-H]-", mass2mz(calculateMass("C6H13NO2"), "[M-H]-"), 0),
c("[Phe-H]-", mass2mz(calculateMass("C9H11NO2"), "[M-H]-"), 0),
c("[Phe-H-NH3]-", mass2mz(calculateMass(subtractElements("C9H11NO2", "NH3")), "[M-H]-"), 0),
c("[Pro-H]-", mass2mz(calculateMass("C5H9NO2"), "[M-H]-"), 0),
c("[Pro-H-H2O]-", mass2mz(calculateMass(subtractElements("C5H9NO2", "H2O")), "[M-H]-"), 0),
c("[Tyr-H]-", mass2mz(calculateMass("C9H11NO3"), "[M-H]-"), 0),
c("[Tyr-H-NH3]-", mass2mz(calculateMass(subtractElements("C9H11NO3", "NH3")), "[M-H]-"), 0),
c("[Val-H]-", mass2mz(calculateMass("C5H11NO2"), "[M-H]-"), 0)
))
colnames(nl) <- colnames(ions) <- c("name", "mass", "polarity")
nl$mass <- as.numeric(nl$mass)
ions$mass <- as.numeric(ions$mass)
```
```{r x}
cdb <- CompDb("CompDb_inhouse_0.sqlite", flags = RSQLite::SQLITE_RW)
sps <- Spectra::Spectra(cdb)
cmps <- compounds(cdb, c("compound_id", "name", "formula", "exactmass"))
m <- unique(sps$compound_id)
i <- which(m == "M0047")
#for(i in seq(length(m))){
# if(!any(grepl(m[i], list.files("molecule/")))){
rmarkdown::render("M0000.Rmd",
params = list(metabolite = m[i]),
output_file = paste0("molecule/", m[i]))
# }
#}
```