multistep_normalize: Normalize numeric data in multiple steps

Description Usage Arguments Details

View source: R/features.R

Description

This function normalizes numeric data in a table in multiple steps, based on groups defined by different combinations of categorical variables. The table is assumed to be in molten format (e.g. see reshape::melt), with a single value column. This function will then proceed to normalize the data based on the value identified by a categorical variable, then normalize the normalized data again by another value etc. (see below for Details)

Usage

1
multistep_normalize(tab, norm.template, subject.var)

Arguments

tab

The input data.frame See the details for assumption about its structure

norm.template

A named list idenfying which categorical variables should be used to group data for normalization. The values in the list represent the value of the corresponding variable that identify the rows that are used as reference for normalization at each step. The data will be normalized in the same order specified by this list (i.e. data will be normalized according to the first variable, then again according to the second etc.)

subject.var

The name of the column that identifies different subjects in tab. All normalization operations are done within the subgroups identified by this variable (i.e. data will never be normalized across subsets idenfied by different values of subject.var)

Details

For this function to work the inputs need to satisfy a number of conditions

An example should help clarify the working of this function. Assume you have a dataset where different variables have been measured for multiple subjects, under different stimulation conditions, and at different timepoints. For each variable you want the data at each timepoint to be normalized by the value in the "unstim" condition. Then you want this data to be further normalized by the value at the "baseline" timepoint. Assume tab is in molten format and has the following columns

To achieve the result described above, you would invoke this function as multistep_normalize(tab, list(condition = "unstim", timepoint = "baseline"), "subject"). Note that the function would fail if you only specify a single variable (either condition or timepoint), because a single variable is not enough to identify a single value for normalization, since you have multiple conditions for each timepoint and viceversa.


ParkerICI/scfeatures documentation built on Aug. 2, 2019, 1:44 a.m.