Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 add examples to functions #3

Merged
merged 8 commits into from
Aug 19, 2024
Prev Previous commit
Next Next commit
- make output of examples shorter
  • Loading branch information
thomas-enzlein committed Aug 18, 2024
commit f30bd9c6bc432fa22ac6241f0c1935d39b72ab0a
2 changes: 1 addition & 1 deletion R/calculateCurveFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' data(Blank2022intmat)
#'
#' # for faster runtime we let it run on 5 peaks only
#' calculateCurveFit(Blank2022intmat, idx = 1:5)
#' fits <- calculateCurveFit(Blank2022intmat, idx = 1:5)
calculateCurveFit <- function(intmat, idx, ...) {
if (length(rownames(intmat)) == 0) {
stop("intmat must have concentrations as rownames!\n")
Expand Down
5 changes: 4 additions & 1 deletion R/calculatePeakstatistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#' data(Blank2022intmat)
#' fits <- calculateCurveFit(Blank2022intmat, idx = 1:5)
#'
#' calculatePeakStatistics(curveFits = fits, singlePeaks = Blank2022peaks, spec = Blank2022spec)
#' peakstats <- calculatePeakStatistics(curveFits = fits,
#' singlePeaks = Blank2022peaks,
#' spec = Blank2022spec)
#' head(peakstats)

calculatePeakStatistics <- function(curveFits, singlePeaks, spec) {
if (!is.list(curveFits)) {
Expand Down
9 changes: 5 additions & 4 deletions R/extractIntensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#' data(Blank2022peaks)
#' data(Blank2022spec)
#'
#' extractIntensity(mz = c(409, 423, 440),
#' peaks = Blank2022peaks,
#' spec = Blank2022spec,
#' tol = 0.2)
#' int <- extractIntensity(mz = c(409, 423, 440),
#' peaks = Blank2022peaks,
#' spec = Blank2022spec,
#' tol = 0.2)
#' head(int)
extractIntensity <- function(mz, peaks, spec, tol) {
if(!(length(peaks) == length(spec))) {
stop("length of peaks and spec must match.\n")
Expand Down
2 changes: 1 addition & 1 deletion R/extractSpots.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @export
#' @examples
#' data(Blank2022spec)
#' extractSpots(Blank2022spec)
#' head(extractSpots(Blank2022spec))
extractSpots <- function(spec) {
if(!isMassSpectrumList(spec)) {
if(!isMassPeaksList(spec)) {
Expand Down
27 changes: 15 additions & 12 deletions R/getters.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getConc(Blank2022res)
#' head(getConc(Blank2022res))

getConc <- function(object) {
stopIfNotIsMALDIassay(object)
Expand Down Expand Up @@ -45,7 +45,7 @@ getDirection <- function(model) {
#'
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getSingleSpecIntensity(Blank2022res, 2)
#' head(getSingleSpecIntensity(Blank2022res, 2))
getSingleSpecIntensity <- function(object, mz_idx) {
s <- getSinglePeaks(object)
mz <- mass(s[[1]]) # all single spectra have same mass axis
Expand Down Expand Up @@ -80,7 +80,7 @@ getSingleSpecIntensity <- function(object, mz_idx) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getIntensityMatrix(Blank2022res, avg = TRUE, excludeNormMz = TRUE)
#' head(getIntensityMatrix(Blank2022res, avg = TRUE, excludeNormMz = TRUE) )
getIntensityMatrix <- function(object, avg = FALSE, excludeNormMz =FALSE) {

if(avg) {
Expand Down Expand Up @@ -159,7 +159,7 @@ getSNR <- function(object) {
#'
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getAvgSpectra(Blank2022res)
#' getAvgSpectra(Blank2022res)[[1]]
getAvgSpectra <- function(object) {
stopIfNotIsMALDIassay(object)
return(object@avgSpectra)
Expand All @@ -175,7 +175,7 @@ getAvgSpectra <- function(object) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getAvgPeaks(Blank2022res)
#' getAvgPeaks(Blank2022res)[[1]]
getAvgPeaks <- function(object) {
stopIfNotIsMALDIassay(object)
return(object@avgPeaks)
Expand All @@ -191,7 +191,7 @@ getAvgPeaks <- function(object) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getSinglePeaks(Blank2022res)
#' getSinglePeaks(Blank2022res)[[1]]
getSinglePeaks <- function(object) {
stopIfNotIsMALDIassay(object)
return(object@singlePeaks)
Expand Down Expand Up @@ -239,7 +239,7 @@ getVarFilterMethod <- function(object) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getAppliedMzShift(Blank2022res)
#' head(getAppliedMzShift(Blank2022res))
getAppliedMzShift <- function(object) {
stopIfNotIsMALDIassay(object)
return(object@mzShifts)
Expand All @@ -255,7 +255,7 @@ getAppliedMzShift <- function(object) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getAppliedNormFactors(Blank2022res)
#' head(getAppliedNormFactors(Blank2022res))
getAppliedNormFactors <- function(object) {
stopIfNotIsMALDIassay(object)
return(object@normFactors)
Expand All @@ -271,7 +271,7 @@ getAppliedNormFactors <- function(object) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getCurveFits(Blank2022res)
#' fits <- getCurveFits(Blank2022res)
getCurveFits <- function(object) {
stopIfNotIsMALDIassay(object)
return(object@fits)
Expand Down Expand Up @@ -306,7 +306,7 @@ getDirectory <- function(object) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getPeakStatistics(Blank2022res, summarise = TRUE)
#' head(getPeakStatistics(Blank2022res, summarise = TRUE))
getPeakStatistics <- function(object, summarise = FALSE) {
stopIfNotIsMALDIassay(object)
stats <- object@stats
Expand Down Expand Up @@ -400,7 +400,7 @@ getMzFromMzIdx <- function(object, mzIdx) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getAllMz(Blank2022res)
#' head(getAllMz(Blank2022res))
getAllMz <- function(object, excludeNormMz = FALSE) {
stopIfNotIsMALDIassay(object)
if(!excludeNormMz) {
Expand Down Expand Up @@ -436,7 +436,10 @@ getAllMz <- function(object, excludeNormMz = FALSE) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' # spots per spectrum
#' getSpots(Blank2022res, singleSpec = TRUE)
#'
#' #spots per concentration
#' getSpots(Blank2022res, singleSpec = FALSE)
getSpots <- function(object, singleSpec = TRUE) {
stopIfNotIsMALDIassay(object)
Expand All @@ -461,7 +464,7 @@ getSpots <- function(object, singleSpec = TRUE) {
#' @examples
#' # see example for `fitCurve()` to see how this data was generated
#' data(Blank2022res)
#' getFittingParameters(Blank2022res, summarise = FALSE)
#' head(getFittingParameters(Blank2022res, summarise = FALSE))
getFittingParameters <- function(object, summarise = FALSE) {
stopIfNotIsMALDIassay(object)

Expand Down
2 changes: 1 addition & 1 deletion R/sdMassSpectrum.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ sdMassSpectraFun <- function(l, mergeMetaData = TRUE) {
#' @examples
#' data(Blank2022spec)
#'
#' sdMassSpectrum(Blank2022spec, labels = names(Blank2022spec))
#' sdMassSpectrum(Blank2022spec, labels = names(Blank2022spec))[[1]]

sdMassSpectrum <- function(l, labels, ...) {

Expand Down
2 changes: 1 addition & 1 deletion man/calculateCurveFit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/calculatePeakStatistics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions man/extractIntensity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/extractSpots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getAllMz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getAppliedMzShift.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getAppliedNormFactors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getAvgPeaks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getAvgSpectra.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getConc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getCurveFits.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getFittingParameters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getIntensityMatrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getPeakStatistics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getSinglePeaks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getSingleSpecIntensity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getSpots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/sdMassSpectrum.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.