normalize: Normalize observation variables.

Description Usage Arguments Value Examples

View source: R/normalize.R

Description

normalize normalizes observation variables based on the specified normalization method.

Usage

1
2
3
4
5
6
7
8
normalize(
  population,
  variables,
  strata,
  sample,
  operation = "standardize",
  ...
)

Arguments

population

tbl with grouping (metadata) and observation variables.

variables

character vector specifying observation variables.

strata

character vector specifying grouping variables for grouping prior to normalization.

sample

tbl containing sample that is used by normalization methods to estimate parameters. sample has same structure as population. Typically, sample corresponds to controls in the experiment.

operation

optional character string specifying method for normalization. This must be one of the strings "standardize" (default), "robustize".

...

arguments passed to normalization operation

Value

normalized data of the same class as population.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
suppressMessages(suppressWarnings(library(magrittr)))
population <- tibble::tibble(
  Metadata_group = c(
    "control", "control", "control", "control",
    "experiment", "experiment", "experiment", "experiment"
  ),
  Metadata_batch = c("a", "a", "b", "b", "a", "a", "b", "b"),
  AreaShape_Area = c(10, 12, 15, 16, 8, 8, 7, 7)
)
variables <- c("AreaShape_Area")
strata <- c("Metadata_batch")
sample <- population %>% dplyr::filter(Metadata_group == "control")
cytominer::normalize(population, variables, strata, sample, operation = "standardize")

Example output

Attaching package: 'cytominer'

The following object is masked from 'package:stats':

    aggregate

The following object is masked from 'package:base':

    transform

# A tibble: 8 x 3
  Metadata_group Metadata_batch AreaShape_Area
  <chr>          <chr>                   <dbl>
1 control        a                      -0.707
2 control        a                       0.707
3 experiment     a                      -2.12 
4 experiment     a                      -2.12 
5 control        b                      -0.707
6 control        b                       0.707
7 experiment     b                     -12.0  
8 experiment     b                     -12.0  

cytominer documentation built on July 8, 2020, 5:08 p.m.