Defines the best principle component to use for downstream analysis.

DefineBestPC(mat, IDs, filter_thresh, return.plot)

Arguments

mat

Bismark2Matrix.R output file, or data frame object

IDs

A character vector of IDs containing the common names for compared conditions. E.g., for samples trt1, trt2 vs. ctl1, ctl2, IDs=c("trt", "ctl")

filter_thresh

A coverage threshold for filtering, where CpG coverage of all samples must be larger than this value

return.plot

T/F, whether to return a PCA plot or a numeric representing the best principle component for downstream analysis

Value

If return.plot=T, a grob plotting a PCA of percent methylation of all samples is returned. Otherwise, a numeric representing the best principal component to use for PCBS analysis is returned.

Examples

DefineBestPC(eigen, IDs = c("trt", "ctl"))
#> 
#> Best PC to use is PC1 with a sample distance of 45.4, representing 29.81% of the total variance.