Skip to content

Commit

Permalink
Merge pull request #2 from jasenfinch/tidy
Browse files Browse the repository at this point in the history
Tidy
  • Loading branch information
jasenfinch authored Nov 16, 2016
2 parents 298201b + e9efe7a commit 76c65d8
Show file tree
Hide file tree
Showing 51 changed files with 677 additions and 1,260 deletions.
11 changes: 8 additions & 3 deletions .Rbuildignore
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$
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ warnings_are_errors: true
apt_packages:
- default-jre
- default-jdk
- libnetcdf-dev
- udunits-bin
- libudunits2-dev

r_binary_packages:
- RUnit
- testthat

bioc_packages:
- mzR
- CAMERA

- survival

r_github_packages:
- jasenfinch/binneR
- jasenfinch/mzAnnotation
- jasenfinch/cdkr/rcdk

notifications:
Expand Down
22 changes: 7 additions & 15 deletions DESCRIPTION
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
340 changes: 0 additions & 340 deletions LICENSE

This file was deleted.

46 changes: 27 additions & 19 deletions NAMESPACE
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)
52 changes: 52 additions & 0 deletions R/PIPsearch.R
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)
}
1 change: 0 additions & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @export
mfGen <- function(measured_mass, max, min, tolerance, charge, applygr) {
.Call('mzAnnotation_mfGen', PACKAGE = 'mzAnnotation', measured_mass, max, min, tolerance, charge, applygr)
}
Expand Down
41 changes: 0 additions & 41 deletions R/calcDiff.R

This file was deleted.

28 changes: 0 additions & 28 deletions R/corAnalysis.R

This file was deleted.

18 changes: 0 additions & 18 deletions R/corLists.R

This file was deleted.

14 changes: 14 additions & 0 deletions R/filterPIP.R
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-","&beta;-","-D-",
"D-","D.","&gamma;-","-n-","N-","&alpha;-","&alpha;","&beta;")
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)
}
32 changes: 32 additions & 0 deletions R/generateMF.R
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)
}
39 changes: 0 additions & 39 deletions R/getMF.R

This file was deleted.

Loading

0 comments on commit 76c65d8

Please sign in to comment.