View source: R/Examine_Region_Methylation.R
getPCs | R Documentation |
getPCs()
calculates the top principal components for region
methylation data, and then saves it as a .rds file.
getPCs(
meth,
mod = matrix(1, nrow = ncol(meth), ncol = 1),
save = TRUE,
file = "Top_Principal_Components.rds",
verbose = TRUE
)
meth |
A |
mod |
A |
save |
A |
file |
A |
verbose |
A |
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.
A numeric matrix
, where each row is a sample and each column
is a principal component.
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()
and plotDendro()
to generate and visualize
dendrograms.
getSoftPower()
and plotSoftPower()
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.
## Not run:
# 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")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.