-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring for xcmsEIC and xcmsFragments done.
- Loading branch information
Showing
6 changed files
with
145 additions
and
114 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
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## Methods for xcmsEIC | ||
#' @include functions-xcmsEIC.R | ||
|
||
############################################################ | ||
## show | ||
setMethod("show", "xcmsEIC", function(object) { | ||
|
||
cat("An \"xcmsEIC\" object with", length(object@eic), "samples\n\n") | ||
|
||
cat("Time range: ", paste(round(range(object@rtrange), 1), collapse = "-"), | ||
" seconds (", paste(round(range(object@rtrange)/60, 1), collapse = "-"), | ||
" minutes)\n", sep = "") | ||
cat("Mass range:", paste(round(range(object@mzrange, na.rm = TRUE), 4), collapse = "-"), | ||
"m/z\n") | ||
cat("EICs per sample:", nrow(object@mzrange), "\n") | ||
cat("Retention times:", object@rt, "\n") | ||
cat("xcmsSet group names: ") | ||
if (length(object@groupnames)) | ||
cat("present") | ||
else | ||
cat("absent") | ||
cat("\n\n") | ||
memsize <- object.size(object) | ||
cat("Memory usage:", signif(memsize/2^20, 3), "MB\n") | ||
}) | ||
|
||
############################################################ | ||
## groupnames | ||
setMethod("groupnames", "xcmsEIC", function(object) { | ||
|
||
object@groupnames | ||
}) | ||
|
||
############################################################ | ||
## sampnames | ||
setMethod("sampnames", "xcmsEIC", function(object) { | ||
|
||
names(object@eic) | ||
}) | ||
|
||
############################################################ | ||
## mzrange | ||
setMethod("mzrange", "xcmsEIC", function(object) { | ||
|
||
object@mzrange | ||
}) | ||
|
||
############################################################ | ||
## rtrange | ||
setMethod("rtrange", "xcmsEIC", function(object) { | ||
|
||
object@rtrange | ||
}) |
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,79 @@ | ||
## Methods for xcmsFragments. | ||
#' @include functions-xcmsFragments.R | ||
|
||
############################################################ | ||
## show | ||
setMethod("show", "xcmsFragments", .xcmsFragments.show) | ||
|
||
############################################################ | ||
## collect | ||
setMethod("collect", "xcmsFragments", .xcmsFragments.collect) | ||
|
||
############################################################ | ||
## plotTree | ||
setMethod("plotTree", "xcmsFragments", .xcmsFragments.plotTree) | ||
|
||
############################################################ | ||
## hasMSn | ||
setMethod("hasMSn", "xcmsFragments", .xcmsFragments.hasMSn) | ||
|
||
############################################################ | ||
## findneutral | ||
setMethod("findneutral", "xcmsFragments", function(object, find, ppmE=25, print=TRUE) { | ||
find<-range(ppmDev(Mr=find, ppmE)) | ||
spectra<-unique(object@peaks[,"MSnParentPeakID"]) | ||
found<-matrix(ncol=10) | ||
|
||
for (i in 1:length(spectra)){ | ||
if(spectra[i] > 0){ | ||
losses<-diff(sort(object@peaks[object@peaks[,"MSnParentPeakID"] ==spectra[i],"mz"] )) | ||
if(length(losses) > 0){ | ||
if(length(which(losses > find[1] & losses < find[2])) > 0){ | ||
idx<-which(object@peaks[,"MSnParentPeakID"] == spectra[i]) | ||
PrecursorMZ<-object@peaks[object@peaks[idx,"MSnParentPeakID"],"mz"] | ||
CE<-object@peaks[object@peaks[idx,"MSnParentPeakID"],"CollisionEnergy"] | ||
dat<-object@peaks[idx,c("MSnParentPeakID", "msLevel", "rt", "mz", | ||
"intensity", "Sample", "GroupPeakMSn")] | ||
found<-rbind(found, cbind(NeutralLoss=c(losses,0), PrecursorMz=PrecursorMZ, | ||
dat[order(dat[,"mz"]),], CollisionEnergy=CE)) | ||
} | ||
} | ||
} | ||
} | ||
if(nrow(found) >1){ | ||
found<-found[2:nrow(found),] | ||
} else{ | ||
cat("Nothing found\n") | ||
return(0) | ||
} | ||
if (print == TRUE){ | ||
cat("We looked for", find[2], " to", find[1], "and found:\n") | ||
print(found) | ||
} | ||
return(found) | ||
}) | ||
|
||
############################################################ | ||
## findMZ | ||
setMethod("findMZ", "xcmsFragments", function(object, find, ppmE=25, print=TRUE) { | ||
find<-range(ppmDev(Mr=find, ppmE)) | ||
fragMZ<-0 | ||
|
||
found<- which(object@peaks[,"mz"] > find[1] & object@peaks[,"mz"] < find[2] & object@peaks[,"msLevel"] >1) | ||
if(length(found) <1){ | ||
cat("nothing was found\n") | ||
return(0) | ||
} | ||
|
||
PrecursorMZ<-object@peaks[object@peaks[found,"MSnParentPeakID"],"mz"] | ||
CE<-object@peaks[object@peaks[found,"MSnParentPeakID"],"CollisionEnergy"] | ||
foundFrag<-cbind(PrecursorMz=PrecursorMZ, object@peaks[found,c("MSnParentPeakID", "msLevel", | ||
"rt", "mz", "intensity", "Sample", "GroupPeakMSn")], CollisionEnergy=CE) | ||
|
||
if (print == TRUE){ | ||
cat("We looked for", find[2], " to", find[1], "and found:\n") | ||
print(foundFrag) | ||
} | ||
return(foundFrag) | ||
}) | ||
|