poisson_scale: Poisson Scaling

View source: R/poisson_scale.R

poisson_scaleR Documentation

Poisson Scaling

Description

This function performs Poisson scaling on a numeric matrix or data frame. Poisson scaling scales each variable by its square root mean value, with an optional scaling offset to avoid over-scaling when a variable has a near-zero mean.

Usage

poisson_scale(
  x,
  sc = NULL,
  drop_na = TRUE,
  options = list(),
  drop.na = deprecated()
)

Arguments

x

A numeric matrix or data frame.

sc

A vector of previously calculated scales. If provided, these scales will be applied to the data.

drop_na

A logical value indicating whether to remove rows containing missing values. If TRUE (the default), such rows are removed. If FALSE, missing values are kept and ignored when computing the means.

options

A list of options for Poisson scaling. See the 'Options' section below.

drop.na

[Deprecated] Use drop_na.

Value

If sc is not provided, the function returns a list with the following components:

xs

The Poisson-scaled data.

sc

A vector of scales calculated for the given data.

If sc is provided, the function returns the Poisson-scaled data xs.

Options

The options argument is a list with the following fields:

  • offset: A numeric value representing the percentage of the maximum mean value to be used as an offset on all scales. Avoids division by near-zero means. Default is 3.

  • mode: An integer value (1 or 2) specifying the dimension of the data on which to calculate the mean value for scaling. 1 = mean over rows (to scale variables); 2 = mean over columns (to scale samples). Default is 1.

Author(s)

Christian L. Goueguel

Examples

data(forageLIBS)
spectra <- forageLIBS[-(1:14)]  # the spectral channels
res <- poisson_scale(spectra[1:300, ])
head(res$sc)
# the same scales for new spectra
poisson_scale(spectra[301:368, ], sc = res$sc)[1:3, 1:4]

specProc documentation built on Nov. 20, 2026, 5:11 p.m.