Description Usage Arguments Details
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 reshape2::melt
), with variable and value columns identifying observations.
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)
At each step of the normalization the table is grouped using the variable.var
, subject.col
and all the columns
in names(norm.template)
. After this grouping, for every group, there can be only one row for the value of the current grouping
variable that has been selected as a basis for normalization. In other words the function will not allow you to normalize a vector of values
by another vector of values, it will only allow normalization of a vector by an individual number. This is done to prevent the result to depend
on the ordering of the table.
1 2 3 4 5 6 7 8 | multistep_normalize(
tab,
norm.template,
subject.col,
variable.var = "variable",
value.var = "value",
remove.normalization.baseline = TRUE
)
|
tab |
The input |
norm.template |
A named list identifying 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.) |
remove.normalization.baseline |
If |
subject.var |
The name of the column that identifies different subjects in |
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
variable
: identifies the variable
value
: the corresponding value of the variable
timepoint
: categorical variable that identifies the timepoint
condition
: categorical variable that identified the condition
subject
: categorical variable that identifies data belonging to the same subject (all the normalization is done within subject)
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.