getPCs()
calculates the top principal components for region
methylation data, and then saves it as a .rds file.
Arguments
- meth
A
numeric matrix
, where each row is a region and each column is a sample. This is typically obtained fromgetRegionMeth()
.- mod
A
matrix
giving the model matrix being used to fit the data. See below for an example.- save
A
logical(1)
indicating whether to save thematrix
.- file
A
character(1)
giving the file name (.rds) for the savedmatrix
.- verbose
A
logical(1)
indicating whether messages should be printed.
Details
getPCs()
uses sva::num.sv()
to identify the number of top
principal components and then svd()
to calculate them, after centering
methylation values within each gene. This is the same approach used by
sva::sva_network()
. More information on the function and approach is
given in the documentation and publications related to the sva
package.
See also
getRegionMeth()
to extract region methylation values.adjustRegionMeth()
to adjust region methylation values using these top PCs.getMEtraitCor()
to compare these top PCs to sample traits.getDendro()
andplotDendro()
to generate and visualize dendrograms.getSoftPower()
andplotSoftPower()
to estimate the best soft-thresholding power and visualize scale-free topology fit and connectivity.getModules()
to build a comethylation network and identify modules of comethylated regions.
Examples
if (FALSE) {
# Get Methylation Data
meth <- getRegionMeth(regions, bs = bs, file = "Region_Methylation.rds")
# Adjust Methylation Data for Top PCs
mod <- model.matrix(~1, data = pData(bs))
PCs <- getPCs(meth, mod = mod, file = "Top_Principal_Components.rds")
methAdj <- adjustRegionMeth(meth, PCs = PCs,
file = "Adjusted_Region_Methylation.rds")
# Compare Top PCs to Sample Traits
MEtraitCor <- getMEtraitCor(PCs, colData = colData, corType = "bicor",
file = "PC_Trait_Correlation_Stats.txt")
PCdendro <- getDendro(PCs, distance = "bicor")
PCtraitDendro <- getCor(PCs, y = colData, corType = "bicor", robustY = FALSE) %>%
getDendro(transpose = TRUE)
plotMEtraitCor(PCtraitCor, moduleOrder = PCdendro$order,
traitOrder = PCtraitDendro$order,
file = "PC_Trait_Correlation_Heatmap.pdf")
# Assess Sample Similarity
getDendro(methAdj, distance = "euclidean") %>%
plotDendro(file = "Sample_Dendrogram.pdf", expandY = c(0.25,0.08))
# Select Soft Power Threshold
sft <- getSoftPower(methAdj, corType = "pearson", file = "Soft_Power.rds")
plotSoftPower(sft, file = "Soft_Power_Plots.pdf")
# Get Comethylation Modules
modules <- getModules(methAdj, power = sft$powerEstimate, regions = regions,
corType = "pearson", file = "Modules.rds")
}