-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jasenfinch/tidy
Tidy
- Loading branch information
Showing
51 changed files
with
677 additions
and
1,260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
mzAnnotation.Rproj | ||
.Rproj.user | ||
.travis.yml | ||
appveyor.yml | ||
README.md | ||
README.md | ||
.gitignore | ||
.git | ||
.Rhistory | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
Package: mzAnnotation | ||
Type: Package | ||
Title: Signal annotation tools for FIE-HRMS metabolomics | ||
Version: 1.0 | ||
Date: 2015-03-29 | ||
Title: Signal annotation tools for high resolution metabolomics | ||
Version: 1.1.0 | ||
Date: 2016-11-11 | ||
Author: Jasen Finch | ||
Maintainer: Jasen Finch <[email protected]> | ||
Description: More about what it does (maybe more than one line) | ||
License: What license is it under? | ||
Imports: | ||
Rcpp (>= 0.11.0) | ||
Description: Tools for the putative annotation of high resolution metabolomics data. | ||
License: GPL (>= 2) | ||
Imports: Rcpp, plyr, shiny, rcdk, graphics, DT | ||
LinkingTo: Rcpp | ||
Depends: | ||
Hmisc, | ||
plyr, | ||
shiny, | ||
rcdk, | ||
mzR, | ||
binneR, | ||
CAMERA | ||
RoxygenNote: 5.0.1 | ||
LazyData: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(annotSheet) | ||
export(annotateFIE) | ||
export(annotateLC) | ||
export(calcDiff) | ||
export(corAnalysis) | ||
export(corAnalysisLC) | ||
export(corLists) | ||
export(filterIso) | ||
export(filterMF) | ||
export(filterPIP) | ||
export(getIsoDist) | ||
export(getMF) | ||
export(getPIP) | ||
export(PIPsearch) | ||
export(generateMF) | ||
export(isoDistr) | ||
export(makeTable) | ||
export(mfGen) | ||
export(queryPIP) | ||
export(relationshipPredictor) | ||
export(shinyMZedDB) | ||
export(viewAnnotation) | ||
export(viewAnnotationLC) | ||
import(Hmisc) | ||
importFrom(DT,dataTableOutput) | ||
importFrom(DT,renderDataTable) | ||
importFrom(Rcpp,evalCpp) | ||
importFrom(graphics,par) | ||
importFrom(graphics,plot) | ||
importFrom(graphics,rasterImage) | ||
importFrom(plyr,ldply) | ||
importFrom(rcdk,parse.smiles) | ||
importFrom(rcdk,view.image.2d) | ||
importFrom(shiny,checkboxInput) | ||
importFrom(shiny,column) | ||
importFrom(shiny,fluidRow) | ||
importFrom(shiny,mainPanel) | ||
importFrom(shiny,navbarPage) | ||
importFrom(shiny,numericInput) | ||
importFrom(shiny,plotOutput) | ||
importFrom(shiny,reactive) | ||
importFrom(shiny,renderPlot) | ||
importFrom(shiny,renderTable) | ||
importFrom(shiny,shinyApp) | ||
importFrom(shiny,sidebarPanel) | ||
importFrom(shiny,tabPanel) | ||
importFrom(shiny,tableOutput) | ||
importFrom(shiny,textInput) | ||
importFrom(utils,combn) | ||
useDynLib(mzAnnotation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#' Putative Ionisation Product searching | ||
#' @param mz the accurate m/z to search | ||
#' @param mode either 'p' or 'n' specifiying the acquisition mode | ||
#' @param ppm the parts per million threshold to search | ||
#' @param add a character \code{vector} specifying the adducts to search. If \code{NULL} a default selection will be used. | ||
#' @param iso a character \code{vector} specifying the isotopes to search. If \code{NULL} isotopes will not be searched. | ||
#' @details The underlying database is that of MZedDB (\url{http://maltese.dbs.aber.ac.uk:8888/hrmet/index.html}). | ||
#' A list of available adducts can be found at \url{http://maltese.dbs.aber.ac.uk:8888/hrmet/search/disprules.php}. | ||
#' Isotopic adducts have also been added and include [2M+K41]1+, [M+K41]1+, [M+K41-2H]1- and [M+Cl37]1-. | ||
#' Available isotopes include C13, 2C13, 3C13, 4C13, O18, Cl37, K41 and S34. | ||
#' @export | ||
#' @author Jasen Finch | ||
#' @importFrom plyr ldply | ||
#' @examples | ||
#' res <- PIPsearch(133.01378,'n',5) | ||
|
||
PIPsearch <- | ||
function(mz,mode,ppm,add = NULL, iso = NULL){ | ||
if (is.null(add)) { | ||
if (mode == "p" & is.null(add)) { | ||
adducts <- c("[M+2Na]2+","[M+H+K]2+","[M+H+Na]2+","[M+H+NH4]2+","[M+2H]2+","[M+2H-H2O-NH3]2+","[2M+K]1+","[2M+K41]1+","[2M+Na]1+","[2M+NH4]1+", | ||
"[2M+H]1+","[M+2K-H]1+","[M+2Na-H]1+","[M+K]1+","[M+K41]1+","[M+K41]1+","[M+Na]1+","[M+H]1+","[M1+.]1+","[M+H-NH3]1+","[M+H-H2O]1+", | ||
"[M+H-FA]1+") | ||
} | ||
if (mode == "n" & is.null(add)) { | ||
adducts <- c("[2M+Na-2H]1-","[2M-H]1-","[M+K-2H]1-","[M+K41-2H]1-","[M+Cl]1-",'[M+Cl37]1-',"[M+Na-2H]1-","[M1-.]1-","[M-H]1-","[M-2H]2-") | ||
} | ||
if (mode == "ne") { | ||
adducts <- c("M") | ||
} | ||
} else { | ||
adducts <- add | ||
} | ||
if (!is.null(iso)) { | ||
iso <- c('',iso) | ||
} else { | ||
iso <- '' | ||
} | ||
|
||
## Loop over adducts irrespective of isotopes | ||
res <- lapply(iso,function(iso,adducts,mz,ppm,bio){ | ||
if (iso == '') { | ||
iso <- NULL | ||
} | ||
lapply(adducts,queryPIP,mz = mz,ppm = ppm,iso = iso) | ||
},adducts = adducts,mz = mz,ppm = ppm) | ||
res <- lapply(res,ldply,stringsAsFactors = F) | ||
res <- ldply(res,stringsAsFactors = F) | ||
names(res) <- c("ID","Name","MF","Accurate Mass","Smiles","Adduct",'Isotope',"Adduct m/z","PPM Error") | ||
|
||
return(res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
filterPIP <- | ||
function(res){ | ||
patterns <- c("ic acid","keto","<i>","</i>","(R)-","(S)-","-L-","L-","(+)-", | ||
"cis,","cis-","trans-","β-","-D-", | ||
"D-","D.","γ-","-n-","N-","α-","α","β") | ||
replacements <- c("ate","oxo","","","","","","","","","","","","","","","","","","","","") | ||
for (i in 1:length(patterns)) { | ||
res[,2] <- sapply(res[,2],gsub,pattern = patterns[i],replacement = replacements[i],fixed = TRUE) | ||
} | ||
res[,2] <- tolower(res[,2]) | ||
res <- res[!duplicated(res[,2]),] | ||
return(res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Molecular formula generation | ||
#' @param mz accurate m/z for MF generation | ||
#' @param ppm ppm tolerance for MF generation | ||
#' @param charge charge to apply to MF generation | ||
#' @param applygr \code{boolean} denoting whether to apply the 7 golden rules | ||
#' @param composition numeric \code{vector} of maximum elemental composition | ||
#' @details Uses the HR2 molecular formula generator available at \url{http://maltese.dbs.aber.ac.uk:8888/hrmet/supp/rhrmet.html}. | ||
#' @author Jasen Finch | ||
#' @export | ||
#' @return A \code{data.frame} containing the generated MFs, their theoretical m/z and their PPM error. | ||
#' @examples | ||
#' res <- generateMF(341.10894,ppm = 5,charge = -1, applygr = TRUE, | ||
#' composition=c(C = 12,iC = 0,H = 22,iH = 0,N = 0,iN = 0,O = 11,iO = 0,F = 0 ,Na = 0, | ||
#' Si = 0,P = 0,S = 0,Cl = 0,iCl = 0,Br = 0,iBr = 0,K = 0,iK = 0)) | ||
|
||
generateMF <- function(mz, ppm = 5, charge = 0, applygr = TRUE, composition = c(C = 12,iC = 0,H = 22,iH = 0,N = 0,iN = 0,O = 11,iO = 0, | ||
F = 0 ,Na = 0,Si = 0,P = 0,S = 0,Cl = 0,iCl = 0,Br = 0, | ||
iBr = 0,K = 0,iK = 0)){ | ||
mmu <- ppm/10^6*mz*1000 | ||
res <- mfGen(mz,composition,rep(0,19),mmu,charge,applygr) | ||
|
||
if (length(res) == 0) { | ||
res <- data.frame(matrix(nrow = 0,ncol = 3)) | ||
colnames(res) <- c("MF", "m/z", "PPM Error") | ||
} else{ | ||
res <- data.frame(matrix(unlist(res), nrow = length(res),byrow = T),stringsAsFactors = F) | ||
res <- res[,-c(1,3,5)] | ||
colnames(res) <- c("MF", "m/z","PPM Error") | ||
res[,3] <- sapply(as.numeric(as.character(res[,2])),function(x,mass){x <- as.numeric(x);x <- (x - mass)/mass*10^6; return(round(x,5))},mass = mz) | ||
} | ||
return(res) | ||
} |
Oops, something went wrong.