doNormalization.Rd
Apply normalization to an assay in a SummarizedExperiment
object and
add a new assay containing the normalized values.
doNormalization(
sce,
method,
assayName,
normalizedAssayName,
spikeFeatures = NULL
)
A SummarizedExperiment
object (or a derivative).
Character scalar giving the normalization method. Currently,
the methods from MsCoreUtils::normalizeMethods()
are supported.
If spikeFeatures
is not NULL
, only
"center.mean"
, "center.median"
, "div.mean"
and
"div.median"
are supported.
Character scalar giving the name of the assay in sce
to be normalized.
Character scalar providing the name that will be given to the assay containing normalized values.
Character vector of feature IDs (rownames of sce)
that will be used to calculate normalization factors. If NULL
(default), all features are used.
An object of the same type as sce
with an additional assay
named normalizedAssayName
.
## Import data
sce <- importExperiment(system.file("extdata", "mq_example",
"1356_proteinGroups.txt",
package = "einprot"),
iColPattern = "^iBAQ\\.")$sce
## Log-transform iBAQ values
SummarizedExperiment::assay(sce, "log2_iBAQ") <-
log2(SummarizedExperiment::assay(sce, "iBAQ"))
## Replace non-finite values by NA
SummarizedExperiment::assay(sce, "log2_iBAQ")[!is.finite(
SummarizedExperiment::assay(sce, "log2_iBAQ"))] <- NA
## Normalize between samples using median centering
sce <- doNormalization(sce, method = "center.median",
assayName = "log2_iBAQ",
normalizedAssayName = "normalized_iBAQ")
SummarizedExperiment::assayNames(sce)
#> [1] "iBAQ" "MS.MS.Count" "LFQ.intensity"
#> [4] "Intensity" "Sequence.coverage" "Unique.peptides"
#> [7] "Razor.unique.peptides" "Peptides" "Identification.type"
#> [10] "log2_iBAQ" "normalized_iBAQ"
## Check that the median is zero for all samples in the normalized data
apply(SummarizedExperiment::assay(sce, "normalized_iBAQ"), 2, median,
na.rm = TRUE)
#> Adnp_IP04 Adnp_IP05 Adnp_IP06 Chd4BF_IP07 Chd4BF_IP08
#> 0.000000e+00 0.000000e+00 0.000000e+00 1.776357e-15 0.000000e+00
#> Chd4BF_IP09 RBC_ctrl_IP01 RBC_ctrl_IP02 RBC_ctrl_IP03
#> 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00