Skip to content

Commit

Permalink
version 1.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
YonghuiDong authored and cran-robot committed Apr 9, 2021
1 parent b2dcff0 commit 236477a
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 155 deletions.
11 changes: 5 additions & 6 deletions DESCRIPTION
@@ -1,23 +1,22 @@
Package: MSbox
Type: Package
Title: Mass Spectrometry Tools
Version: 1.3.8
Version: 1.3.9
Author: Yonghui Dong
Maintainer: Yonghui Dong <yonghui.dong@gmail.com>
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.
Depends: R (>= 3.5.0)
Imports: stringr, crayon, xml2, magrittr, ropls, stats, reshape2,
ggplot2, ggfortify, plotly
Imports: stringr, crayon, xml2, stats, reshape2, ggplot2, ggfortify,
plotly
License: GPL-2
URL: https://github.com/YonghuiDong/MSbox
BugReports: https://github.com/YonghuiDong/MSbox/issues/new
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
NeedsCompilation: no
Packaged: 2021-02-08 15:06:42 UTC; Dong
Packaged: 2021-04-09 14:55:10 UTC; dong
Repository: CRAN
Date/Publication: 2021-02-10 11:30:08 UTC
Date/Publication: 2021-04-09 15:10:02 UTC
16 changes: 7 additions & 9 deletions MD5
@@ -1,27 +1,26 @@
c8b5a29f1df1a25af6e50ab51a6bbd6a *DESCRIPTION
4b8f1ed5a2062558b7b0b302e97874d1 *NAMESPACE
4a93fd83f64916f6703b6326a1a266f4 *DESCRIPTION
a1fa52a0b9ac7cfa53d9cd440579a6b4 *NAMESPACE
dd6f462af5280c88c49e5437d1872826 *R/Element_Isotope.R
7f8005ea5e2498d555abc9066cd74995 *R/Iso_mass.R
81231efaa80ce13745719e4c85e1880c *R/Iso_mz.R
5c0dbd00d55acae6aada659f111f77d1 *R/adduct.R
3b6bd62f3d708f7e40ce92ec65b4fba1 *R/contaminant.R
7bc59a9d51f548edb044ad6eb7f2da6b *R/describe.R
ee1363c07d3bf95b52e8bc54ec59d415 *R/doNormalization.R
6086b4de998a6af0562c75713e6789e1 *R/doStat.R
7e1ef28c951ec5ed7149d6955644dd57 *R/doStat.R
2349f586c35473dfa077232eca3b3115 *R/getCV.R
9a25b2a88620a8c0f7c5cab41f75280d *R/getFC.R
cca54ace3482160b01adc39457d645d5 *R/getMax.R
296786c1bd8a4b57c8dc7e0a809a7343 *R/getOPLSDA.R
bf56ede1b9d89202df6ec10b78e6b0c6 *R/getP.R
72f8c457375674d7b8daa9df24d54338 *R/mass.R
f29db2e954006f2f12ca9b0ddbdea6b8 *R/mz.R
7586801da2902d202d6e1ae7cc97a003 *R/ppm.R
9e9409f3d5665ffbab95c3ef9caf36f1 *R/sysdata.rda
6dc65c2f26eb80593f30058c7cc55f43 *R/sysdata.rda
bdc7b3c0da5d61093e584ad5610e0f07 *R/viewPCA.R
b35b5f30586d7b1a8042470571636c30 *R/viewTIC.R
2d3a7e9defb55dbc8df0bd349c39f805 *R/viewVolcano.R
d604940d011f99f17f8f376656e45b0c *R/what.R
04615fc58c3056283c754584d1dbde4a *README.md
de023c2c507818142e856afb056b9978 *R/what.R
cd76a3ffdfff99d3bfa2ff0e4d0a9234 *README.md
a0069cdaeddc173ad9a7d90e55eecb68 *man/E_iso.Rd
e03a09d8c41a05c2726d7841faf22838 *man/Iso_mass.Rd
f2a5856f3ed1c70700591b297aa600d7 *man/Iso_mz.Rd
Expand All @@ -33,12 +32,11 @@ d8e5041ee73275ea19e7c24aaaa6387e *man/doNormalization.Rd
609d97ae982c036edcf07e15ad642de7 *man/getCV.Rd
7b6127013196452c0fb4792a94bf81c6 *man/getFC.Rd
88c526a2085fa02d197a7f3cae9b7840 *man/getMax.Rd
c8acd1b064e39ebbdde4eaaef9d8dcca *man/getOPLSDA.Rd
bdcf6e0f02c011276168bb7baf7eae7e *man/getP.Rd
9c086deded6fafb501488f014871880c *man/mass.Rd
b083603e4e5014c8aedc6f4e9d1c7fa5 *man/mz.Rd
bee1ce66e6f3e562965ceb87a7bb46db *man/ppm.Rd
ea473bf790b483a411bf6410d603f337 *man/viewPCA.Rd
69aa6a2b4a66d4b07f29fdc1bd7c3815 *man/viewTIC.Rd
4c67a5c83ac5de6027c47485a3ffd6f2 *man/viewVolcano.Rd
6ed72880d43d25cebfef5105e0645da5 *man/what.Rd
11ddbd95c2504fdc16c92e5cec3652ea *man/what.Rd
2 changes: 0 additions & 2 deletions NAMESPACE
Expand Up @@ -11,7 +11,6 @@ export(doStat)
export(getCV)
export(getFC)
export(getMax)
export(getOPLSDA)
export(getP)
export(mass)
export(mz)
Expand All @@ -38,7 +37,6 @@ importFrom(plotly,ggplotly)
importFrom(plotly,layout)
importFrom(plotly,plot_ly)
importFrom(reshape2,melt)
importFrom(ropls,opls)
importFrom(stats,TukeyHSD)
importFrom(stats,aggregate)
importFrom(stats,as.formula)
Expand Down
3 changes: 1 addition & 2 deletions R/doStat.R
Expand Up @@ -16,8 +16,7 @@ doStat <- function(x, Group = NULL){
myCV <- getCV(x, Group = Group)
myFC <- getFC(x, Group = Group)
myP <- getP(x, Group = Group)
myOPLSDA <- getOPLSDA(x, Group = Group)
myStat <- cbind(maxSample, myCV, myFC, myP, myOPLSDA)
myStat <- cbind(maxSample, myCV, myFC, myP)
cat("\nStatistical analysis done. \n")
rownames(myStat) <- colnames(x)
return(myStat)
Expand Down
44 changes: 0 additions & 44 deletions R/getOPLSDA.R

This file was deleted.

Binary file modified R/sysdata.rda
Binary file not shown.
63 changes: 26 additions & 37 deletions R/what.R
Expand Up @@ -4,57 +4,46 @@
#' @param mz m/z values
#' @param ppm mass tolerance, default value = 10
#' @param mode ionization mode, either positive '+' or negative '-'
#' @param useDB which database to use, HMDB or KEGG? default is HMDB
#' @export
#' @examples
#' what(133.014, ppm = 10, mode = '-')
#' what(c(133.014, 191.020), ppm = 10, mode = '-')
#' a = what(133.014, mode = '-', ppm = 10)

what <- function (mz, mode = NULL, ppm = 5) {
what <- function (mz, mode = NULL, ppm = 5, useDB = "HMDB") {

##(1) input check
if(is.numeric(mz) == FALSE) {stop("warning: mass to charge ratio mz shoule be numeric!")}
if(mode != "+" & mode !="-") {stop("warning: ion mode invalid. Choose '+' or '-'.\n")}
if(mode != "+" & mode !="-") {stop("warning: ion mode invalid. Choose '+' or '-'.")}
if(!(toupper(useDB) %in% c("HMDB", "KEGG"))) {stop("warning: selected database does not exist")}

##(2) search in database
expand.grid.df <- function(...) Reduce(function(...) merge(..., by = NULL), list(...))
Result <- vector("list", length(mz))
## select DB
if(mode == '-' & toupper(useDB) == "HMDB") {DB <- as.data.frame(sysdata$HMDB_neg)}
if(mode == '+' & toupper(useDB) == "HMDB") {DB <- as.data.frame(sysdata$HMDB_pos)}
if(mode == '-' & toupper(useDB) == "KEGG") {DB <- as.data.frame(sysdata$KEGG_neg)}
if(mode == '+' & toupper(useDB) == "KEGG") {DB <- as.data.frame(sysdata$KEGG_pos)}

if(mode == '-') {
DB <- as.data.frame(sysdata$HMDB_neg)
for (i in 1:length(mz)) {
width <- options()$width * 0.3
cat(paste0(rep(c(intToUtf8(0x2698), "="), i / length(mz) * width), collapse = ''))
cat(paste0(round(i / length(mz) * 100), '% completed'))
DB.list <- expand.grid.df(i, mz[i], DB)
colnames(DB.list)[c(1, 2)] <- c("QueryID", "Search")
cal_ppm <- with(DB.list, (DB.list$mz - Search) * 10^6 / DB.list$mz)
cal_ppm <- round(cal_ppm, digits = 2)
DB.list <- cbind(DB.list, ppm = cal_ppm)
Result[[i]] = DB.list[(abs(cal_ppm) <= ppm), ]
row.names(Result[[i]]) <- NULL
if (i == length(mz)) cat(': Searching Done.')
else cat('\014')
}
} else {
DB <- as.data.frame(sysdata$HMDB_pos)
for (i in 1:length(mz)) {
width <- options()$width * 0.3
cat(paste0(rep(c(intToUtf8(0x2698), "="), i / length(mz) * width), collapse = ''))
cat(paste0(round(i / length(mz) * 100), '% completed'))
DB.list <- expand.grid.df(i, mz[i], DB)
colnames(DB.list)[c(1, 2)] <- c("QueryID", "Search")
cal_ppm <- with(DB.list, (DB.list$mz - Search) * 10^6 / DB.list$mz)
cal_ppm <- round(cal_ppm, digits = 2)
DB.list <- cbind(DB.list, ppm = cal_ppm)
Result[[i]] = DB.list[(abs(cal_ppm) <= ppm), ]
row.names(Result[[i]]) <- NULL
if (i == length(mz)) cat(': Searching Done.')
else cat('\014')
}
for (i in 1:length(mz)) {
width <- options()$width * 0.3
cat(paste0(rep(c(intToUtf8(0x2698), "="), i / length(mz) * width), collapse = ''))
cat(paste0(round(i / length(mz) * 100), '% completed'))
DB.list <- expand.grid.df(i, mz[i], DB)
colnames(DB.list)[c(1, 2)] <- c("QueryID", "Search")
cal_ppm <- with(DB.list, (DB.list$mz - Search) * 10^6 / DB.list$mz)
cal_ppm <- round(cal_ppm, digits = 2)
DB.list <- cbind(DB.list, ppm = cal_ppm)
Result[[i]] = DB.list[(abs(cal_ppm) <= ppm), ]
row.names(Result[[i]]) <- NULL
if (i == length(mz)) cat(': Searching Done.')
else cat('\014')
}
search_result <- do.call(rbind.data.frame, Result)
## rm columns with all NAs, this is specially for KEGG database
search_result <- search_result[, !apply(is.na(search_result), 2, all)]

##(3) check if Result is empty, and return result
##(3) check if Result is empty, and return result
if(nrow(search_result) == 0) {
message('Not Found, Unknown')
} else {
Expand Down

0 comments on commit 236477a

Please sign in to comment.