-
Notifications
You must be signed in to change notification settings - Fork 26
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 #72 from sgibb/occurrence-list
Reduced memory requirement for filterPeaks; closes #71
- Loading branch information
Showing
9 changed files
with
191 additions
and
160 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 |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
^CRAN-RELEASE$ | ||
^cran-comments.md$ | ||
^\.github$ | ||
^.*\.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
*.o | ||
*.rds | ||
CRAN-RELEASE | ||
.Rproj.user | ||
.Rproj |
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 |
---|---|---|
@@ -1,123 +1,79 @@ | ||
## AbstractMassObject | ||
if (is.null(getGeneric("plotMsiSlice"))) { | ||
setGeneric("plotMsiSlice", function(x, ...) standardGeneric("plotMsiSlice")) | ||
} | ||
if (is.null(getGeneric(".prepareShow"))) { | ||
setGeneric(".prepareShow", function(object) standardGeneric(".prepareShow")) | ||
} | ||
if (is.null(getGeneric("transformIntensity"))) { | ||
setGeneric("transformIntensity", | ||
function(object, ...) standardGeneric("transformIntensity")) | ||
} | ||
if (is.null(getGeneric(".transformIntensity"))) { | ||
setGeneric(".transformIntensity", | ||
function(object, ...) standardGeneric(".transformIntensity")) | ||
} | ||
if (is.null(getGeneric("trim"))) { | ||
setGeneric("trim", function(object, range, ...) standardGeneric("trim")) | ||
} | ||
setGeneric("plotMsiSlice", function(x, ...) standardGeneric("plotMsiSlice")) | ||
setGeneric(".prepareShow", function(object) standardGeneric(".prepareShow")) | ||
setGeneric( | ||
"transformIntensity", | ||
function(object, ...) standardGeneric("transformIntensity") | ||
) | ||
setGeneric( | ||
".transformIntensity", | ||
function(object, ...) standardGeneric(".transformIntensity") | ||
) | ||
setGeneric("trim", function(object, range, ...) standardGeneric("trim")) | ||
|
||
## get/set slots | ||
if (is.null(getGeneric("mass"))) { | ||
setGeneric("mass", function(object, ...) standardGeneric("mass")) | ||
} | ||
if (is.null(getGeneric("mass<-"))) { | ||
setGeneric("mass<-", function(object, value) standardGeneric("mass<-")) | ||
} | ||
setGeneric("mass", function(object, ...) standardGeneric("mass")) | ||
setGeneric("mass<-", function(object, value) standardGeneric("mass<-")) | ||
|
||
# from ProtGenerics (same as mass) | ||
if (is.null(getGeneric("mz"))) { | ||
setGeneric("mz", function(object, ...) standardGeneric("mz")) | ||
} | ||
if (is.null(getGeneric("mz<-"))) { | ||
setGeneric("mz<-", function(object, value) standardGeneric("mz<-")) | ||
} | ||
if (is.null(getGeneric("intensity"))) { | ||
setGeneric("intensity", function(object, ...) standardGeneric("intensity")) | ||
} | ||
if (is.null(getGeneric("intensity<-"))) { | ||
setGeneric("intensity<-", | ||
function(object, value) standardGeneric("intensity<-")) | ||
} | ||
if (is.null(getGeneric("isEmpty"))) { | ||
setGeneric("isEmpty", function(x) standardGeneric("isEmpty")) | ||
} | ||
if (is.null(getGeneric(".isEmptyWarning"))) { | ||
setGeneric(".isEmptyWarning", function(x) standardGeneric(".isEmptyWarning")) | ||
} | ||
if (is.null(getGeneric("metaData"))) { | ||
setGeneric("metaData", function(object) standardGeneric("metaData")) | ||
} | ||
if (is.null(getGeneric("metaData<-"))) { | ||
setGeneric("metaData<-", | ||
function(object, value) standardGeneric("metaData<-")) | ||
} | ||
if (is.null(getGeneric("coordinates"))) { | ||
setGeneric("coordinates", | ||
function(object, ...) standardGeneric("coordinates")) | ||
} | ||
if (is.null(getGeneric("coordinates<-"))) { | ||
setGeneric("coordinates<-", | ||
function(object, value) standardGeneric("coordinates<-")) | ||
} | ||
setGeneric("mz", function(object, ...) standardGeneric("mz")) | ||
setGeneric("mz<-", function(object, value) standardGeneric("mz<-")) | ||
|
||
setGeneric("intensity", function(object, ...) standardGeneric("intensity")) | ||
setGeneric( | ||
"intensity<-", | ||
function(object, value) standardGeneric("intensity<-") | ||
) | ||
setGeneric("isEmpty", function(x) standardGeneric("isEmpty")) | ||
setGeneric(".isEmptyWarning", function(x) standardGeneric(".isEmptyWarning")) | ||
setGeneric("metaData", function(object) standardGeneric("metaData")) | ||
setGeneric("metaData<-", function(object, value) standardGeneric("metaData<-")) | ||
setGeneric("coordinates", function(object, ...) standardGeneric("coordinates")) | ||
setGeneric( | ||
"coordinates<-", | ||
function(object, value) standardGeneric("coordinates<-") | ||
) | ||
## end of AbstractMassObject | ||
|
||
## MassSpectrum | ||
if (is.null(getGeneric("calibrateIntensity"))) { | ||
setGeneric("calibrateIntensity", | ||
function(object, ...) standardGeneric("calibrateIntensity")) | ||
} | ||
if (is.null(getGeneric("detectPeaks"))) { | ||
setGeneric("detectPeaks", | ||
function(object, ...) standardGeneric("detectPeaks")) | ||
} | ||
if (is.null(getGeneric("estimateBaseline"))) { | ||
setGeneric("estimateBaseline", | ||
function(object, method=c("SNIP", "ConvexHull", "Median"), ...) | ||
standardGeneric("estimateBaseline")) | ||
} | ||
if (is.null(getGeneric("estimateNoise"))) { | ||
setGeneric("estimateNoise", | ||
function(object, ...) standardGeneric("estimateNoise")) | ||
} | ||
if (is.null(getGeneric(".findLocalMaxima"))) { | ||
setGeneric(".findLocalMaxima", | ||
function(object, halfWindowSize=20L) | ||
standardGeneric(".findLocalMaxima")) | ||
} | ||
if (is.null(getGeneric(".findLocalMaximaLogical"))) { | ||
setGeneric(".findLocalMaximaLogical", | ||
function(object, halfWindowSize=20L) | ||
standardGeneric(".findLocalMaximaLogical")) | ||
} | ||
if (is.null(getGeneric("isRegular"))) { | ||
setGeneric("isRegular", | ||
function(object, ...) standardGeneric("isRegular")) | ||
} | ||
if (is.null(getGeneric("removeBaseline"))) { | ||
setGeneric("removeBaseline", | ||
function(object, ...) standardGeneric("removeBaseline")) | ||
} | ||
if (is.null(getGeneric("smoothIntensity"))) { | ||
setGeneric("smoothIntensity", | ||
function(object, ...) | ||
standardGeneric("smoothIntensity")) | ||
} | ||
if (is.null(getGeneric("totalIonCurrent"))) { | ||
setGeneric("totalIonCurrent", | ||
function(object) standardGeneric("totalIonCurrent")) | ||
} | ||
setGeneric( | ||
"calibrateIntensity", | ||
function(object, ...) standardGeneric("calibrateIntensity") | ||
) | ||
setGeneric("detectPeaks", function(object, ...) standardGeneric("detectPeaks")) | ||
setGeneric( | ||
"estimateBaseline", | ||
function(object, method=c("SNIP", "ConvexHull", "Median"), ...) | ||
standardGeneric("estimateBaseline")) | ||
setGeneric( | ||
"estimateNoise", function(object, ...) standardGeneric("estimateNoise") | ||
) | ||
setGeneric( | ||
".findLocalMaxima", | ||
function(object, halfWindowSize=20L) standardGeneric(".findLocalMaxima") | ||
) | ||
setGeneric( | ||
".findLocalMaximaLogical", | ||
function(object, halfWindowSize=20L) | ||
standardGeneric(".findLocalMaximaLogical") | ||
) | ||
setGeneric("isRegular", function(object, ...) standardGeneric("isRegular")) | ||
setGeneric( | ||
"removeBaseline", function(object, ...) standardGeneric("removeBaseline") | ||
) | ||
setGeneric( | ||
"smoothIntensity", function(object, ...) standardGeneric("smoothIntensity") | ||
) | ||
setGeneric( | ||
"totalIonCurrent", function(object) standardGeneric("totalIonCurrent") | ||
) | ||
## end of MassSpectrum | ||
|
||
## MassPeaks | ||
if (is.null(getGeneric("labelPeaks"))) { | ||
setGeneric("labelPeaks", function(object, ...) standardGeneric("labelPeaks")) | ||
} | ||
if (is.null(getGeneric("monoisotopicPeaks"))) { | ||
setGeneric("monoisotopicPeaks", | ||
function(object, ...) standardGeneric("monoisotopicPeaks")) | ||
} | ||
if (is.null(getGeneric("snr"))) { | ||
setGeneric("snr", function(object) standardGeneric("snr")) | ||
} | ||
setGeneric("labelPeaks", function(object, ...) standardGeneric("labelPeaks")) | ||
setGeneric( | ||
"monoisotopicPeaks", | ||
function(object, ...) standardGeneric("monoisotopicPeaks") | ||
) | ||
setGeneric("snr", function(object) standardGeneric("snr")) | ||
## end of MassPeaks |
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,22 @@ | ||
## .as.occurrence.list | ||
## internal function to create a list of peaks occurrence | ||
## | ||
## params: | ||
## l: list of AbstractMassObject objects | ||
## | ||
## returns: | ||
## a list, where sample is the sample id, i is the index of the uniqueMass, | ||
## and mass is the unique mass vector | ||
.as.occurrence.list.MassObjectList <- function(l) { | ||
.stopIfNotIsMassObjectList(l) | ||
|
||
mass <- .unlist(lapply(l, function(x)x@mass)) | ||
uniqueMass <- sort.int(unique(mass)) | ||
n <- lengths(l) | ||
|
||
list( | ||
sample = rep.int(seq_along(l), lengths(l)), | ||
i = findInterval(mass, uniqueMass), | ||
mass = uniqueMass | ||
) | ||
} |
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
Oops, something went wrong.