Title: | Mass Spectrometry Tools |
---|---|
Description: | Common mass spectrometry tools described in John Roboz (2013) <doi:10.1201/b15436>. It allows checking element isotopes, calculating (isotope labelled) exact monoisitopic mass, m/z values and mass accuracy, and inspecting possible contaminant mass peaks, examining possible adducts in electrospray ionization (ESI) and matrix-assisted laser desorption ionization (MALDI) ion sources. |
Authors: | Yonghui Dong |
Maintainer: | Yonghui Dong <[email protected]> |
License: | GPL-2 |
Version: | 1.4.8 |
Built: | 2024-10-29 03:00:13 UTC |
Source: | https://github.com/yonghuidong/msbox |
calculate common adduct ions in positive or negative ion mode
adduct(F, mode = c("+", "-"))
adduct(F, mode = c("+", "-"))
F |
chemical formula, case insensitive |
mode |
ionization mode, either positive '+' or negative '-' |
Yonghui Dong
adduct('C1H4', mode = '-') adduct('C1h4', mode = '+')
adduct('C1H4', mode = '-') adduct('C1h4', mode = '+')
check the possible contaminants
contam(mz, mode = NULL, ppm = 10)
contam(mz, mode = NULL, ppm = 10)
mz |
suspected m/z value |
mode |
ionization mode, either positive '+' or negative '-' |
ppm |
mass tolerance, default value = 10 |
Yonghui Dong
contam(33.0335, ppm = 10, mode = '+') contam(44.998, ppm = 10, mode = '-')
contam(33.0335, ppm = 10, mode = '+') contam(44.998, ppm = 10, mode = '-')
get compound formula and structure from https://cactus.nci.nih.gov/chemical/structure
describe(chem, representation = "formula", info = FALSE)
describe(chem, representation = "formula", info = FALSE)
chem |
chemical name of the compound |
representation |
representation methods, formula is default |
info |
extra molecular information that users can query |
Yonghui Dong
## Not run: describe('malic acid', "formula") describe(c('malic acid', 'citric acid', 'tartaric acid'), "smiles") ## End(Not run)
## Not run: describe('malic acid', "formula") describe(c('malic acid', 'citric acid', 'tartaric acid'), "smiles") ## End(Not run)
performing statistics, including calculating fold change, p-values and VIP values
doStat(x, Group = NULL)
doStat(x, Group = NULL)
x |
sample ion intensity matrix, row sample, column feature. |
Group |
sample group information |
a dataframe with statistical information
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) rownames(dat) <- 1:dim(dat)[1] myGroup <- rep_len(LETTERS[1:3], 300) ret <- doStat(dat, Group = myGroup)
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) rownames(dat) <- 1:dim(dat)[1] myGroup <- rep_len(LETTERS[1:3], 300) ret <- doStat(dat, Group = myGroup)
check element isotope information
E_iso(S)
E_iso(S)
S |
element, can be element symbol (i.e. C) or full name (i.e. Carbon). Both Element symbol and full name are case insensitive. |
Yonghui Dong
E_iso('Na') # element symbol E_iso('nA') # element symbol, case insensitive E_iso('Carbon') # element full name E_iso('carBon') # element full name, case insensitive
E_iso('Na') # element symbol E_iso('nA') # element symbol, case insensitive E_iso('Carbon') # element full name E_iso('carBon') # element full name, case insensitive
Calculate coefficient of variation (CV), also known as relative standard deviation (RSD) among different sample groups
getCV(x, Group = NULL)
getCV(x, Group = NULL)
x |
sample ion intensity matrix, row sample, column feature. |
Group |
sample group information |
a dataframe with mean values and cv
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) myGroup <- rep_len(LETTERS[1:2], 300) ret <- getCV(dat, Group = myGroup)
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) myGroup <- rep_len(LETTERS[1:2], 300) ret <- getCV(dat, Group = myGroup)
calculate fold change among different samples.
getFC(x, Group = NULL)
getFC(x, Group = NULL)
x |
sample ion intensity matrix, row sample, column feature. |
Group |
sample group information |
a dataframe with mean values and fold changes
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) myGroup <- rep_len(LETTERS[1:2], 300) ret <- getFC(dat, Group = myGroup)
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) myGroup <- rep_len(LETTERS[1:2], 300) ret <- getFC(dat, Group = myGroup)
get the sample name which has the max ion intensity
getMax(x)
getMax(x)
x |
sample ion intensity matrix, row sample, column feature. |
a data frame
dat <- cbind.data.frame(mz = c(100, 101, 300), mz2 = c(0, 0 , 1), mz3 = c(1, 9, 1)) rownames(dat) <- c("A", "B", "C") out <- getMax(dat)
dat <- cbind.data.frame(mz = c(100, 101, 300), mz2 = c(0, 0 , 1), mz3 = c(1, 9, 1)) rownames(dat) <- c("A", "B", "C") out <- getMax(dat)
get p-values from Post Hoc analysis
getP(x, Group = NULL)
getP(x, Group = NULL)
x |
sample ion intensity matrix, row sample, column feature. |
Group |
sample group information |
a data frame
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) myGroup <- rep_len(LETTERS[1:3], 300) out <- getP(dat, Group = myGroup)
dat <- matrix(runif(2*300), ncol = 2, nrow = 300) myGroup <- rep_len(LETTERS[1:3], 300) out <- getP(dat, Group = myGroup)
Calculate isotope labelled molecular mass
Iso_mass(F, iso)
Iso_mass(F, iso)
F |
chemical formula, case insensitive |
iso |
labelled elements, case insensitive |
Yonghui Dong
Iso_mass(F = 'C7H6O4', iso = '[13]C2[2]H3') # Two 13C and three 2H are labled
Iso_mass(F = 'C7H6O4', iso = '[13]C2[2]H3') # Two 13C and three 2H are labled
Calculate isotope labelled m/z
Iso_mz(F, iso, z)
Iso_mz(F, iso, z)
F |
chemical formula, case insensitive |
iso |
labelled elements, case insensitive |
z |
charge |
Yonghui Dong
Iso_mz(F = 'C7H6O4', iso = '[13]C2[2]H3', z = -1) # Two 13C and three 2H are labled
Iso_mz(F = 'C7H6O4', iso = '[13]C2[2]H3', z = -1) # Two 13C and three 2H are labled
calculate accurate molecular mass
mass(F, caseSensitive = FALSE)
mass(F, caseSensitive = FALSE)
F |
chemical formula, case insensitive |
caseSensitive |
if case sensitive is 'FALSE' (default), the elements are seperated by numbers. for instance, Carbon dioxyde can be written as 'c1o2' or any combination of the two elements in lower or upper cases. However, the number of elements should be clearly stated in the chemical formula. if case sensitive is 'TRUE', the elements are seperated by upper case letters. For instance, Carbon dioxyde must be written as 'C1O2' or ‘CO2'. You don’t meed to write the number of the element if it is 1. |
Yonghui Dong
mass('C7h7o1') mass('C7H7O', caseSensitive = TRUE) mass(c('C7H7O4', 'C'), caseSensitive = TRUE) # vector input mass(c('c7h7O4', 'c1'))
mass('C7h7o1') mass('C7H7O', caseSensitive = TRUE) mass(c('C7H7O4', 'C'), caseSensitive = TRUE) # vector input mass(c('c7h7O4', 'c1'))
Calculate accurate mass-to-charge ratio (m/z)
mz(m, z, caseSensitive = FALSE)
mz(m, z, caseSensitive = FALSE)
m |
chemical formula of an ion, case insensitive |
z |
charge |
caseSensitive |
if case sensitive is 'FALSE' (default), the elements are seperated by numbers. for instance, Carbon dioxyde can be written as 'c1o2' or any combination of the two elements in lower or upper cases. However, the number of elements should be clearly stated in the chemical formula. if case sensitive is 'TRUE', the elements are seperated by upper case letters. For instance, Carbon dioxyde must be written as 'C1O2' or ‘CO2'. You don’t meed to write the number of the element if it is 1. |
Yonghui Dong
mz('C7h7o1', z = 1) mz('C7H7O', z = 1, caseSensitive = TRUE) mz(c('C7H7O4', 'C'), z = -1, caseSensitive = TRUE) # vector input mz(c('c7h7O4', 'c1'), z = -1)
mz('C7h7o1', z = 1) mz('C7H7O', z = 1, caseSensitive = TRUE) mz(c('C7H7O4', 'C'), z = -1, caseSensitive = TRUE) # vector input mz(c('c7h7O4', 'c1'), z = -1)
calculate the mass accuracy of measured m/z. lazy input allowed
ppm(m, t, lazy = TRUE)
ppm(m, t, lazy = TRUE)
m |
measured m/z |
t |
theoretical m/z |
lazy |
if lazy input is allowed |
Yonghui Dong
ppm(155.03383, 155.03388) # with m/z value ppm(155.03383, .03388) # lazy input when the integer parts of m and t are the same ppm(155.03384, mz('C7H7O4', z = 1)) # with ion formula
ppm(155.03383, 155.03388) # with m/z value ppm(155.03383, .03388) # lazy input when the integer parts of m and t are the same ppm(155.03384, mz('C7H7O4', z = 1)) # with ion formula
search in customized database based on accurate m/z and RT
searchDB(DF, DB, ppm = 5, RT = 0.2, useRT = FALSE)
searchDB(DF, DB, ppm = 5, RT = 0.2, useRT = FALSE)
DF |
input file, should contain at least a column named mz |
DB |
database, should contain at least a column named mz |
ppm |
mass tolerance, default 5ppm |
RT |
retention time tolerance, default 0.2min |
useRT |
should RT be considered during database search? |
Yonghui Dong
DF <- cbind.data.frame(mz = c(100.001, 100.1), RT = c(10, 11)) DB <- cbind.data.frame(mz = c(100.001, 100.1), RT = c(10, 12.1)) searchDB(DF, DB, ppm = 5, RT = 0.2, useRT = TRUE)
DF <- cbind.data.frame(mz = c(100.001, 100.1), RT = c(10, 11)) DB <- cbind.data.frame(mz = c(100.001, 100.1), RT = c(10, 12.1)) searchDB(DF, DB, ppm = 5, RT = 0.2, useRT = TRUE)
tentative metabolite identification based on m/z value search
what(myMZ, mode = NULL, ppm = 5, useDB = "HMDB")
what(myMZ, mode = NULL, ppm = 5, useDB = "HMDB")
myMZ |
m/z values |
mode |
ionization mode, either positive '+' or negative '-' |
ppm |
mass tolerance, default value = 10 |
useDB |
which database to use, HMDB or KEGG? default is HMDB |
Yonghui Dong
a = what(133.014, mode = '-', ppm = 10)
a = what(133.014, mode = '-', ppm = 10)