Skip to contents

Similar approach to Z-scaling and mean centering, but the scaling is less driven by outliers. Subtracts by the median and divides by the median absolute deviation (MAD). If the MAD is zero for any parameter, divides by 1 instead. Standard Z-scaling integrates outliers more effectively, but also changes the values of points closer to the central tendency more dramatically if outliers are present.

Usage

robust_scale_region(
  region,
  to = "ScaledData",
  from = "NormalizedData",
  MARGIN = 1,
  ...
)

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).

...

Arguments passed on to robust_scale

center

Subtract median

scale

Scale by MAD

preserveScale

Equalize scales but keep magnitude more similar to the raw data. Divides MADs by the mean of the MADs before scaling, so the magnitude of the resulting IQRs is more like the mean MAD rather than (-1, 1). Doesn't do anything unless scale = TRUE since this just augments scaling.

Value

An updated Region object with normalized data added to the slot specified in to. Metadata recording information about the normalization is added to the featureInfo if MARGIN = 1, and to the cellMetadata if MARGIN = 2.

See also

Scroll to top