Skip to content
Snippets Groups Projects
Commit e6df5a81 authored by ermueller's avatar ermueller
Browse files

Forgot to commit RAW reader function

parent fefec965
Branches bioc2014
No related tags found
No related merge requests found
......@@ -380,9 +380,9 @@ findMsMsHRperxcms <- function(fileName, cpdID, mode="pH", findPeaksArgs = NULL,
P <- lapply(1:length(spectra), function(i){
sp <- toRMB(spectra[[i]], cpdID[i], mode)
sp@id <- as.character(as.integer(cpdID))
sp@name <- findName(cpdID)
sp@formula <- findFormula(cpdID)
sp@id <- as.character(as.integer(cpdID[i]))
sp@name <- findName(cpdID[i])
sp@formula <- findFormula(cpdID[i])
sp@mode <- mode
return(sp)
})
......@@ -436,17 +436,11 @@ findMsMsHRperxcms.direct <- function(fileName, cpdID, mode="pH", findPeaksArgs =
xrs[[1]] <- xrmsms
}
# Fake s simplistic xcmsSet
# Fake a simplistic xcmsSet
suppressWarnings(setReplicate <- xcms::xcmsSet(files=fileName, method="MS1"))
xsmsms <- as.list(replicate(length(xrs),setReplicate))
mzabs <- 0.1
# Where is the wanted isolation ?
# precursorrange <- range(which(xrmsms@msnPrecursorMz == parentMass)) ## TODO: add ppm one day
mzabs <- 0.1
# Definitions
whichmissing <- vector()
......
......@@ -304,35 +304,51 @@ msmsRead.RAW <- function(w, xRAW = NULL, cpdids = NULL, mode, findPeaksArgs = NU
devnull <- capture.output(anmsms[[i]] <- CAMERA::xsAnnotate(xsmsms[[i]]))
devnull <- capture.output(anmsms[[i]] <- CAMERA::groupFWHM(anmsms[[i]]))
if(length(candidates[[i]]) > 0){
if(length(candidates[[i]]) > 0){
closestCandidate <- which.min (abs( RT - pl[candidates[[i]], "rt", drop=FALSE]))
psp[[i]] <- which(sapply(anmsms[[i]]@pspectra, function(x) {candidates[[i]][closestCandidate] %in% x}))
} else{psp[[i]] <- which.min( abs(getRT(anmsms[[i]]) - RT) )}
## Now find the pspec for compound
} else{
psp[[i]] <- which.min( abs(getRT(anmsms[[i]]) - RT) )
}
## Now find the pspec for compound
## 2nd best: Spectrum closest to MS1
##psp <- which.min( abs(getRT(anmsms) - actualRT))
## 2nd best: Spectrum closest to MS1
##psp <- which.min( abs(getRT(anmsms) - actualRT))
## 3rd Best: find pspec closest to RT from spreadsheet
##psp <- which.min( abs(getRT(anmsms) - RT) )
if((plots == TRUE) && (length(psp[[i]]) > 0)){
CAMERA::plotPsSpectrum(anmsms[[i]], psp[[i]], log=TRUE, mzrange=c(0, findMz(cpdids[1])[[3]]), maxlabel=10)
}
if(length(psp[[i]]) != 0){
spectra[[i]] <- CAMERA::getpspectra(anmsms[[i]], psp[[i]])
} else {whichmissing <- c(whichmissing,i)}
## 3rd Best: find pspec closest to RT from spreadsheet
##psp <- which.min( abs(getRT(anmsms) - RT) )
if((plots == TRUE) && (length(psp[[i]]) > 0)){
CAMERA::plotPsSpectrum(anmsms[[i]], psp[[i]], log=TRUE, mzrange=c(0, findMz(cpdids[1])[[3]]), maxlabel=10)
}
}
if(length(spectra) != 0){
for(i in whichmissing){
spectra[[i]] <- matrix(0,2,7)
if(length(psp[[i]]) != 0){
spectra[[i]] <- CAMERA::getpspectra(anmsms[[i]], psp[[i]])
} else {
whichmissing <- c(whichmissing,i)
}
}
if(length(w@specs) != 0){
w@specs <- c(w@specs,list(toRMB(spectra,cpdids[1],mode)))
} else {
w@specs[[1]] <- toRMB(spectra,cpdids[1],mode)
}
if(length(spectra) != 0){
for(i in whichmissing){
spectra[[i]] <- matrix(0,2,7)
}
}
sp <- toRMB(spectra,cpdids,"mH")
sp@id <- as.character(as.integer(cpdids))
sp@name <- findName(cpdids)
sp@formula <- findFormula(cpdids)
sp@mode <- mode
if(length(w@spectra) != 0){
IDindex <- sapply(w@spectra,function(s) s@id == cpdids)
if(length(IDindex)){
spectraNum <- length(w@spectra[[which(IDindex)]]@children)
w@spectra[[which(IDindex)]]@children[[spectraNum+1]] <- sp@children[[1]]
} else {
w@spectra[[length(www@spectra)+1]] <- sp
}
} else{
w@spectra[[1]] <- sp
}
if(all(w@files != xRAW[[1]]@filepath)){
......@@ -346,6 +362,7 @@ msmsRead.RAW <- function(w, xRAW = NULL, cpdids = NULL, mode, findPeaksArgs = NU
}
}
}
names(w@specs)[length(w@specs)] <- basename(w@files[length(w@files)])
return(w)
}
\ No newline at end of file
}
......@@ -3,9 +3,11 @@ NULL
.checkMbSettings <- function()
{
o <- getOption("RMassBank", NULL)
if(is.null(o))
stop("Please load your settings before using the RMassBank workflow.")
o <- getOption("RMassBank", NULL)
if(is.null(o)){
stop("Please load your settings before using the RMassBank workflow.")
}
}
......
......@@ -4,7 +4,7 @@
\alias{checkIsotopes}
\title{Checks for isotopes in a \code{msmsWorkspace}}
\usage{
checkIsotopes(w, mode = "pH", intensity_cutoff = 5000,
checkIsotopes(w, mode = "pH", intensity_cutoff = 1000,
intensity_precision = "low", conflict = "dppm", isolationWindow = 4,
evalMode = "complete", plotSpectrum = TRUE,
settings = getOption("RMassBank"))
......@@ -22,9 +22,9 @@ checkIsotopes(w, mode = "pH", intensity_cutoff = 5000,
\item{conflict}{Either "isotopic"(Peak formulas are always chosen if they fit the requirements for an isotopic peak)
or "strict"(Peaks are only marked as isotopic when there hasn't been a formula assigned before.)}
\item{isolationWindow}{The width of the isolation window in Da}
\item{isolationWindow}{Half of the width of the isolation window in Da}
\item{evalMode}{Currently no function yet, but planned}
\item{evalMode}{Currently no function yet, but planned. Currently must be "complete"}
\item{plotSpectrum}{A boolean specifiying whether the spectrumshould be plotted}
......
......@@ -56,7 +56,7 @@ for further processing with \code{\link{mbWorkflow}}.
\examples{
\dontrun{
refilteredRcSpecs <- filterMultiplicity(
reanalyzedRcSpecs, "myarchive", "pH")
w, "myarchive", "pH")
}
}
\author{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment