Skip to contents

Performs min-max scaling on SpatialMap data, i.e. sets the minimum value to zero and the maximum value to 1. Options to perform scaling biomarker- or cell-wise with the MARGIN param and to trim outliers before scaling with the trim param.

Usage

minmax_scale_region(
  region,
  to = "NormalizedData",
  from = "Data",
  MARGIN = 1,
  trim = c(0.01, 0.99),
  na.rm = TRUE
)

Arguments

region

A Region object, or concatenated data generated by .smapply.

to

Which data slot to assign the normalized data to.

from

Which data slot to pull data from.

MARGIN

Whether to apply the function within each biomarker (1) or across all biomarkers in each cell (2).

trim

Two-element numeric vector describing the extent of outlier trimming that will be performed. For instance, c(0.01, 0.99), the default, will trim the 1st and 99th percentiles of the data prior to min-max normalization. Trimming is performed biomarker- or cell-wise, following the MARGIN param.

na.rm

Whether to remove NA or not. Defaults to TRUE and may cause problems if FALSE.

Value

An updated Region object with normalized data added to the slot specified in to

See also

Scroll to top