meanNormalization {neuroSCC} | R Documentation |
Mean Normalization for Matrix Data
Description
Normalizes each row of a matrix by dividing its elements by the row mean, ignoring NA
values.
This step is commonly used to adjust for global intensity differences across subjects before
applying statistical comparisons or functional data analysis.
Usage
meanNormalization(
matrixData,
handleInvalidRows = c("warn", "error", "omit"),
returnDetails = FALSE,
quiet = FALSE
)
Arguments
matrixData |
A |
handleInvalidRows |
|
returnDetails |
|
quiet |
|
Details
The function performs the following steps
Computes the row means of the input matrix, ignoring
NA
s.Divides each row by its corresponding mean.
Replaces
NaN
values (from division by 0) with0
if applicable.Handles problematic rows according to the selected
handleInvalidRows
option:"warn"
(default) issues a warning,"error"
stops execution, and"omit"
removes the affected rows from the result.
This step is often used prior to applying SCC methods to ensure comparability across subjects.
Value
A normalized matrix, or a list if returnDetails = TRUE
.
-
normalizedMatrix
– The normalized matrix. -
problemRows
– Indices of rows that had zero orNA
means.
See Also
matrixCreator
for building the matrix input to normalize.
Examples
# Generate a minimal database and create a matrix (1 control subject)
dataDir <- system.file("extdata", package = "neuroSCC")
controlPattern <- "^syntheticControl1\\.nii\\.gz$"
databaseControls <- databaseCreator(pattern = controlPattern,
control = TRUE,
quiet = TRUE)
matrixControls <- matrixCreator(databaseControls, paramZ = 35, quiet = TRUE)
# Normalize the matrix (with diagnostics)
normalizationResult <- meanNormalization(matrixControls,
returnDetails = TRUE,
quiet = FALSE)