Contents

Compiled date: 2024-03-13

Last edited: 2023-12-14

License: GPL-3

1 Installation

Run the following code to install the Bioconductor version of package.

# install.packages("BiocManager")
BiocManager::install("POMA")

2 Load Packages

library(POMA)
library(ggtext)
library(patchwork)

3 Load Data and Imputation

Let’s create a cleaned SummarizedExperiment object from the sample data st000336 to explore the normalization effects.

example_data <- st000336 %>% 
  PomaImpute() # KNN imputation
Loading required package: SummarizedExperiment
Loading required package: MatrixGenerics
Loading required package: matrixStats

Attaching package: 'MatrixGenerics'
The following objects are masked from 'package:matrixStats':

    colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
    colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
    colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
    colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
    colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
    colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
    colWeightedMeans, colWeightedMedians, colWeightedSds,
    colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
    rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
    rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
    rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
    rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
    rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
    rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
    rowWeightedSds, rowWeightedVars
Loading required package: GenomicRanges
Loading required package: stats4
Loading required package: BiocGenerics

Attaching package: 'BiocGenerics'
The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
    as.data.frame, basename, cbind, colnames, dirname, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin,
    pmin.int, rank, rbind, rownames, sapply, setdiff, table, tapply,
    union, unique, unsplit, which.max, which.min
Loading required package: S4Vectors

Attaching package: 'S4Vectors'
The following object is masked from 'package:utils':

    findMatches
The following objects are masked from 'package:base':

    I, expand.grid, unname
Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Attaching package: 'Biobase'
The following object is masked from 'package:MatrixGenerics':

    rowMedians
The following objects are masked from 'package:matrixStats':

    anyMissing, rowMedians
method argument is empty. KNN will be used

example_data
class: SummarizedExperiment 
dim: 30 57 
metadata(0):
assays(1): ''
rownames(30): x1_methylhistidine x3_methylhistidine ... pyruvate
  succinate
rowData names(0):
colnames(57): 1 2 ... 56 57
colData names(2): group steroids

4 Normalization

Here we will evaluate the normalization methods that POMA offers on the same SummarizedExperiment object to compare them (Berg et al. 2006).

none <- PomaNorm(example_data, method = "none")
auto_scaling <- PomaNorm(example_data, method = "auto_scaling")
level_scaling <- PomaNorm(example_data, method = "level_scaling")
log_scaling <- PomaNorm(example_data, method = "log_scaling")
log_transformation <- PomaNorm(example_data, method = "log_transform")
vast_scaling <- PomaNorm(example_data, method = "vast_scaling")
log_pareto <- PomaNorm(example_data, method = "log_pareto")

4.1 Normalization effect on data dimensions

When we check for the dimension of the data after normalization we can see that all methods have the same effect on data dimension. PomaNorm only modifies the data dimension when the dataset contains only-zero features or zero-variance features.

dim(SummarizedExperiment::assay(none))
> [1] 30 57
dim(SummarizedExperiment::assay(auto_scaling))
> [1] 30 57
dim(SummarizedExperiment::assay(level_scaling))
> [1] 30 57
dim(SummarizedExperiment::assay(log_scaling))
> [1] 30 57
dim(SummarizedExperiment::assay(log_transformation))
> [1] 30 57
dim(SummarizedExperiment::assay(vast_scaling))
> [1] 30 57
dim(SummarizedExperiment::assay(log_pareto))
> [1] 30 57

4.2 Normalization effect on samples

Here we can evaluate the normalization effects on samples (Berg et al. 2006).

a <- PomaBoxplots(none, 
                  x = "samples") +
  ggplot2::ggtitle("Not Normalized")

b <- PomaBoxplots(auto_scaling, 
                  x = "samples", 
                  theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Auto Scaling") +
  ggplot2::theme(axis.text.x = ggplot2::element_blank())

c <- PomaBoxplots(level_scaling, 
                  x = "samples", 
                  theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Level Scaling") +
  ggplot2::theme(axis.text.x = ggplot2::element_blank())

d <- PomaBoxplots(log_scaling, 
                  x = "samples", 
                  theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Log Scaling") +
  ggplot2::theme(axis.text.x = ggplot2::element_blank())

e <- PomaBoxplots(log_transformation, 
                  x = "samples", 
                  theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Log Transformation") +
  ggplot2::theme(axis.text.x = ggplot2::element_blank())

f <- PomaBoxplots(vast_scaling, 
                  x = "samples", 
                  theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Vast Scaling") +
  ggplot2::theme(axis.text.x = ggplot2::element_blank())

g <- PomaBoxplots(log_pareto, 
                  x = "samples", 
                  theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Log Pareto") +
  ggplot2::theme(axis.text.x = ggplot2::element_blank())

a  

(b + c + d) / (e + f + g)

4.3 Normalization effect on features

Here we can evaluate the normalization effects on features.

h <- PomaDensity(none, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Not Normalized")

i <- PomaDensity(auto_scaling, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Auto Scaling") +
  ggplot2::theme(axis.title.x = ggplot2::element_blank(),
                 axis.title.y = ggplot2::element_blank())

j <- PomaDensity(level_scaling, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Level Scaling") +
  ggplot2::theme(axis.title.x = ggplot2::element_blank(),
                 axis.title.y = ggplot2::element_blank())

k <- PomaDensity(log_scaling, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Log Scaling") +
  ggplot2::theme(axis.title.x = ggplot2::element_blank(),
                 axis.title.y = ggplot2::element_blank())

l <- PomaDensity(log_transformation, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Log Transformation") +
  ggplot2::theme(axis.title.x = ggplot2::element_blank(),
                 axis.title.y = ggplot2::element_blank())

m <- PomaDensity(vast_scaling, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Vast Scaling") +
  ggplot2::theme(axis.title.x = ggplot2::element_blank(),
                 axis.title.y = ggplot2::element_blank())

n <- PomaDensity(log_pareto, 
                 x = "features", 
                 theme_params = list(legend_title = FALSE, legend_position = "none")) +
  ggplot2::ggtitle("Log Pareto") +
  ggplot2::theme(axis.title.x = ggplot2::element_blank(),
                 axis.title.y = ggplot2::element_blank())

h  

(i + j + k) / (l + m + n)

5 Session Information

sessionInfo()
> R Under development (unstable) (2024-03-06 r86056)
> Platform: x86_64-pc-linux-gnu
> Running under: Ubuntu 22.04.4 LTS
> 
> Matrix products: default
> BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
> 
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
>  [3] LC_TIME=en_GB              LC_COLLATE=C              
>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
> 
> time zone: America/New_York
> tzcode source: system (glibc)
> 
> attached base packages:
> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
> [8] base     
> 
> other attached packages:
>  [1] SummarizedExperiment_1.33.3 Biobase_2.63.0             
>  [3] GenomicRanges_1.55.3        GenomeInfoDb_1.39.9        
>  [5] IRanges_2.37.1              S4Vectors_0.41.4           
>  [7] BiocGenerics_0.49.1         MatrixGenerics_1.15.0      
>  [9] matrixStats_1.2.0           patchwork_1.2.0            
> [11] ggtext_0.1.2                POMA_1.13.26               
> [13] BiocStyle_2.31.0           
> 
> loaded via a namespace (and not attached):
>  [1] gtable_0.3.4            impute_1.77.0           xfun_0.42              
>  [4] bslib_0.6.1             ggplot2_3.5.0           lattice_0.22-5         
>  [7] vctrs_0.6.5             tools_4.4.0             generics_0.1.3         
> [10] tibble_3.2.1            fansi_1.0.6             highr_0.10             
> [13] pkgconfig_2.0.3         Matrix_1.6-5            lifecycle_1.0.4        
> [16] GenomeInfoDbData_1.2.11 stringr_1.5.1           compiler_4.4.0         
> [19] farver_2.1.1            munsell_0.5.0           htmltools_0.5.7        
> [22] sass_0.4.8              yaml_2.3.8              pillar_1.9.0           
> [25] crayon_1.5.2            jquerylib_0.1.4         tidyr_1.3.1            
> [28] cachem_1.0.8            DelayedArray_0.29.9     magick_2.8.3           
> [31] abind_1.4-5             commonmark_1.9.1        tidyselect_1.2.1       
> [34] digest_0.6.35           stringi_1.8.3           dplyr_1.1.4            
> [37] purrr_1.0.2             bookdown_0.38           labeling_0.4.3         
> [40] fastmap_1.1.1           grid_4.4.0              colorspace_2.1-0       
> [43] cli_3.6.2               SparseArray_1.3.4       magrittr_2.0.3         
> [46] S4Arrays_1.3.6          utf8_1.2.4              withr_3.0.0            
> [49] scales_1.3.0            rmarkdown_2.26          XVector_0.43.1         
> [52] evaluate_0.23           knitr_1.45              viridisLite_0.4.2      
> [55] markdown_1.12           rlang_1.1.3             gridtext_0.1.5         
> [58] Rcpp_1.0.12             glue_1.7.0              BiocManager_1.30.22    
> [61] xml2_1.3.6              jsonlite_1.8.8          R6_2.5.1               
> [64] zlibbioc_1.49.3

References

Berg, Robert A van den, Huub CJ Hoefsloot, Johan A Westerhuis, Age K Smilde, and Mariët J van der Werf. 2006. “Centering, Scaling, and Transformations: Improving the Biological Information Content of Metabolomics Data.” BMC Genomics 7 (1): 142.