Calculate Correlation Statistics Between Module Eigennodes and Traits
Source:R/Explore_Module_Trait_Correlations.R
getMEtraitCor.Rd
getMEtraitCor()
calculates correlation coefficients and p-values
between eigennode values for all modules and all sample traits and saves it
as a .txt file. Correlations are performed using either pearson
or
bicor
methods.
Usage
getMEtraitCor(
MEs,
colData,
corType = c("bicor", "pearson"),
maxPOutliers = 0.1,
robustY = FALSE,
save = TRUE,
file = "ME_Trait_Correlation_Stats.txt",
verbose = TRUE
)
Arguments
- MEs
A
data.frame
of module eigennode values, where rows are samples and columns are modules. The row names ofMEs
must include the same set of values as the row names ofcolData
.- colData
A
data.frame
whose row names specify samples and whose columns are sample traits with numeric values.- corType
A
character(1)
indicating which correlation statistic to use in the calculation. Potential values includepearson
andbicor
.- maxPOutliers
A
numeric(1)
specifying the maximum percentile that can be considered outliers on each side of the median for thebicor
statistic.- robustY
A
logical(1)
indicating whether to use robust calculation fory
for thebicor
statistic.FALSE
is recommended ify
is a binary variable.- save
A
logical(1)
indicating whether to save thedata.frame
.- file
A
character(1)
giving the file name (.txt) for the saveddata.frame
.- verbose
A
logical(1)
indicating whether messages should be printed.
Details
getMEtraitCor()
is designed to be used in combination with
getModules()
. The correlation calculations are performed by
WGCNA::corAndPvalue()
and WGCNA::bicorAndPvalue()
. getMEtraitCor()
can also be used to calculate pairwise correlation coefficients and p-values
between module eigennode values, or between top adjusted PCs and sample
traits (see examples).
See also
getModules()
to build a comethylation network and identify modules of comethylated regions.getCor()
to calculate correlation coefficients.getDendro()
andplotDendro()
to generate and visualize dendrograms.plotMEtraitCor()
to visualize ME-trait correlations.
Examples
if (FALSE) {
# Get Comethylation Modules
modules <- getModules(methAdj, power = sft$powerEstimate, regions = regions,
corType = "pearson", file = "Modules.rds")
# Test Correlations between Module Eigennodes and Sample Traits
MEs <- modules$MEs
MEtraitCor <- getMEtraitCor(MEs, colData = colData, corType = "bicor",
file = "ME_Trait_Correlation_Stats.txt")
# Examine Correlations between Modules
moduleCorStats <- getMEtraitCor(MEs, colData = MEs, corType = "bicor",
robustY = TRUE,
file = "Module_Correlation_Stats.txt")
# 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")
# Examine Correlations between Sample Traits
traitDendro <- getCor(MEs, y = colData, corType = "bicor",
robustY = FALSE) %>%
getDendro(transpose = TRUE)
plotDendro(traitDendro, labelSize = 3.5, expandY = c(0.65,0.08),
file = "Trait_Dendrogram.pdf")
# Visualize Correlations between Module Eigennodes and Sample Traits
moduleDendro <- getDendro(MEs, distance = "bicor")
plotMEtraitCor(MEtraitCor, moduleOrder = moduleDendro$order,
traitOrder = traitDendro$order,
file = "ME_Trait_Correlation_Heatmap.pdf")
plotMEtraitCor(MEtraitCor, moduleOrder = moduleDendro$order,
traitOrder = traitDendro$order, topOnly = TRUE,
label.type = "p", label.size = 4, label.nudge_y = 0,
legend.position = c(1.11, 0.795),
colColorMargins = c(-1,4.75,0.5,10.1),
file = "Top_ME_Trait_Correlation_Heatmap.pdf", width = 8.5,
height = 4.25)
}