R/generic_funcs.R

Defines functions .remove.const.peaks .mode .scale.all

## .scaleAllVariables
.scale.all <- function(msi.data) {
  .stopIfNotValidMSIDataset(msi.data)

  x <- msi.data@matrix
  for (i in 1:ncol(x))
  {
    x[, i] <- x[, i] / max(x[, i])
  }
  msi.data@matrix <- x

  return(msi.data)
}

## Statistical mode
.mode <- function(x) {
  ux <- unique(x)
  return(ux[which.max(tabulate(match(x, ux)))])
}

## removeConstPeaks 
.remove.const.peaks = function(object) {
  .stopIfNotValidMSIDataset(object)
  const.filter <- apply(object@matrix, 2, var) == 0
  if (sum(const.filter) != 0) {
    cat(paste0("Found ", sum(const.filter), " constant peaks.\n"))
    object@matrix <- object@matrix[, !const.filter]
    object@mz <- object@mz[!const.filter]
  }
  return(object)
}

Try the SPUTNIK package in your browser

Any scripts or data that you put into this service are public.

SPUTNIK documentation built on May 29, 2024, 11:53 a.m.