Scatter_Density: Principal Component Analysis (PCA) with Density Plots per...

View source: R/batch_detection.R

Scatter_DensityR Documentation

Principal Component Analysis (PCA) with Density Plots per Component

Description

This function draws a PCA sample plot with density plots per principal component.

Usage

Scatter_Density(
    object,
    batch = NULL,
    trt = NULL,
    xlim = NULL,
    ylim = NULL,
    color.set = NULL,
    batch.legend.title = "Batch",
    trt.legend.title = "Treatment",
    density.lwd = 0.2,
    title = NULL,
    title.cex = 1.5,
    legend.cex = 0.7,
    legend.title.cex = 0.75
)

Arguments

object

The object of class PCA.

batch

A factor or a class vector for the batch grouping information (categorical outcome variable).

trt

A factor or a class vector for the treatment grouping information (categorical outcome variable).

xlim

A numeric vector of length 2, indicating the x coordinate ranges.

ylim

A numeric vector of length 2, indicating the y coordinate ranges.

color.set

A vector of character, indicating the set of colors to use. The colors are represented by hexadecimal color code.

batch.legend.title

Character, the legend title of batches.

trt.legend.title

Character, the legend title of treatments.

density.lwd

Numeric, the thickness of density lines.

title

Character, the plot title.

title.cex

Numeric, the size of plot title.

legend.cex

Numeric, the size of legends.

legend.title.cex

Numeric, the size of legend title.

Value

None.

Author(s)

Yiwen Wang, Kim-Anh LĂȘ Cao

See Also

box_plot, density_plot, alignment_score and partVar_plot as the other methods for batch effect detection and batch effect removal assessment.

Examples

# The first example
library(mixOmics) # for function pca()
library(TreeSummarizedExperiment) # for functions assays(),rowData()
data('AD_data')
# centered log ratio transformed data
ad.clr <- assays(AD_data$EgData)$Clr_value
ad.pca.before <- pca(ad.clr, ncomp = 3, scale = TRUE)
ad.batch <- rowData(AD_data$EgData)$Y.bat # batch information
ad.trt <- rowData(AD_data$EgData)$Y.trt # treatment information
names(ad.batch) <- names(ad.trt) <- rownames(AD_data$EgData)
Scatter_Density(object = ad.pca.before, batch = ad.batch, trt = ad.trt)

# The second example
colorlist <- rainbow(10)
Scatter_Density(object = ad.pca.before, batch = ad.batch, trt = ad.trt,
                color.set = colorlist)


EvaYiwenWang/PLSDAbatch documentation built on Sept. 25, 2024, 8:54 p.m.