Extract an assay from a SummarizedExperiment, and for each feature subtract the average value across a set of reference/background/baseline samples, and add the average across all the baseline samples to retain information about overall abundance. Typically used to adjust for varying baselines between batches, when a reference sample is included in each batch.

getMatSubtractedBaseline(sce, assayName, baselineGroup, sceFull)

Arguments

sce

A SummarizedExperiment object. The colData of the object must have at least columns named 'group' and 'batch'.

assayName

The name of the assay to extract from sce.

baselineGroup

The value of the 'group' column of colData(sceFull) that corresponds to the baseline/reference samples.

sceFull

A SummarizedExperiment object containing at least the reference samples for each batch in sce.

Value

Matrix with baseline-subtracted abundances.

Author

Charlotte Soneson

Examples

sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
                           package = "einprot"))

## Introduce artificial batch column
sce$batch <- rep(c("B1", "B2", "B3"), 3)
SummarizedExperiment::colData(sce)
#> DataFrame with 9 rows and 5 columns
#>                      sample       group       nNA       pNA       batch
#>                 <character> <character> <numeric> <numeric> <character>
#> Adnp_IP04         Adnp_IP04        Adnp        54   23.3766          B1
#> Adnp_IP05         Adnp_IP05        Adnp        41   17.7489          B2
#> Adnp_IP06         Adnp_IP06        Adnp        50   21.6450          B3
#> Chd4BF_IP07   Chd4BF_IP0...      Chd4BF        29   12.5541          B1
#> Chd4BF_IP08   Chd4BF_IP0...      Chd4BF         9    3.8961          B2
#> Chd4BF_IP09   Chd4BF_IP0...      Chd4BF        38   16.4502          B3
#> RBC_ctrl_IP01 RBC_ctrl_I...    RBC_ctrl       107   46.3203          B1
#> RBC_ctrl_IP02 RBC_ctrl_I...    RBC_ctrl       104   45.0216          B2
#> RBC_ctrl_IP03 RBC_ctrl_I...    RBC_ctrl       105   45.4545          B3
mat <- getMatSubtractedBaseline(sce, assayName = "log2_LFQ.intensity",
                                baselineGroup = "RBC_ctrl",
                                sceFull = sce)
## After the subtraction, the baseline samples are equalized across the
## different batches
head(mat)
#>        Adnp_IP04 Adnp_IP05 Adnp_IP06 Chd4BF_IP07 Chd4BF_IP08 Chd4BF_IP09
#> Dhx9    24.18116  26.01048  24.73828    21.76343    23.27155    23.00110
#> Zmynd8  19.28486  15.91157  19.32624    22.74219    22.65350    22.62484
#> Zmym4   26.34049  24.01694  28.46780    23.83731    29.34545    23.59778
#> Rlf     24.30727  21.89682  24.68757    19.31752    26.86482    20.61771
#> Zfp600  23.04364  22.97297  23.89353    22.92493    25.23942    23.68068
#> Rpl32   17.29039  25.15371  22.00468    18.73304    24.39710    22.46536
#>        RBC_ctrl_IP01 RBC_ctrl_IP02 RBC_ctrl_IP03
#> Dhx9        15.95417      15.95417      15.95417
#> Zmynd8      16.06443      16.06443      16.06443
#> Zmym4       16.43556      16.43556      16.43556
#> Rlf         16.45595      16.45595      16.45595
#> Zfp600      22.24619      22.24619      22.24619
#> Rpl32       18.04745      18.04745      18.04745