plotHeatmap()
takes a numeric matrix
and two dendrograms, plots
them, and then saves it all as a .pdf. The row names and column names of
x
must include the same set of values as the labels of rowDendro
and colDendro
, respectively.
Usage
plotHeatmap(
x,
rowDendro,
colDendro,
colors = blueWhiteRed(100, gamma = 0.3),
limit = max(abs(x)),
axis.text.size = 8,
legend.title = "Bicor",
legend.title.size = 16,
legend.text.size = 12,
legend.position = c(0.3, 0.905),
rowDendroMargins = c(-1.55, 1, -0.1, -1.1),
colDendroMargins = c(1, -0.5, -1, 0.8),
rowColorMargins = c(-1.85, -1.5, 0.55, 1.7),
colColorMargins = c(-1.6, -0.85, 1.8, 0.55),
save = TRUE,
file = "Heatmap.pdf",
width = 11,
height = 9.5,
verbose = TRUE
)
Arguments
- x
A
numeric matrix
. The row names and column names ofx
must include the same set of values as the labels ofrowDendro
andcolDendro
, respectively.- rowDendro
An stats::hclust object generated by
getDendro()
.- colDendro
An stats::hclust object generated by
getDendro()
.- colors
A
character
giving a vector of colors to use for the gradient on the heatmap. The default usesWGCNA::blueWhiteRed()
to generate these colors.- limit
A
numeric(1)
giving the maximum value (symmetric) for the heatmap color scale.- axis.text.size
A
numeric(1)
specifying the size of the text for both axes.- legend.title
A
character(1)
with the title of the legend.- legend.title.size
A
numeric(1)
giving the size of the text for the legend title.- legend.text.size
A
numeric(1)
specifying the size of the text for the legend axis.- legend.position
A
numeric(2)
with the position of the legend, as x-axis, y-axis. May also be acharacter(1)
indicating "none", "left", "right", "bottom", or "top".- rowDendroMargins
A
numeric(4)
giving the width of the margins for the row (vertical) dendrogram as top, right, bottom, and left.- colDendroMargins
A
numeric(4)
giving the width of the margins for the column (horizontal) dendrogram as top, right, bottom, and left.- rowColorMargins
A
numeric(4)
giving the width of the margins for the row (vertical) color bar as top, right, bottom, and left.- colColorMargins
A
numeric(4)
giving the width of the margins for the column (horizontal) color bar as top, right, bottom, and left.- save
A
logical(1)
indicating whether to save the plot.- file
A
character(1)
giving the file name (.pdf) for the saved plot.- width
A
numeric(1)
specifying the width in inches of the saved plot.- height
A
numeric(1)
specifying the height in inches of the saved plot.- verbose
A
logical(1)
indicating whether messages should be printed.
Details
plotHeatmap()
is designed to be used in combination with getCor()
and getDendro()
. The function will check to see if module color names are
in the row and column names and then plot a color bar with the module colors.
A ggplot
object is produced and can be edited outside of this function
if desired.
See also
getModules()
to build a comethylation network and identify modules of comethylated regions.getDendro()
andplotDendro()
to generate and visualize dendrograms.getCor()
to calculate correlation coefficients.
Examples
if (FALSE) {
# Get Comethylation Modules
modules <- getModules(methAdj, power = sft$powerEstimate, regions = regions,
corType = "pearson", file = "Modules.rds")
# Examine Correlations between Modules
MEs <- modules$MEs
moduleDendro <- getDendro(MEs, distance = "bicor")
plotDendro(moduleDendro, labelSize = 4, nBreaks = 5,
file = "Module_ME_Dendrogram.pdf")
moduleCor <- getCor(MEs, corType = "bicor")
plotHeatmap(moduleCor, rowDendro = moduleDendro, colDendro = moduleDendro,
file = "Module_Correlation_Heatmap.pdf")
# Examine Correlations between Samples
sampleDendro <- getDendro(MEs, transpose = TRUE, distance = "bicor")
plotDendro(sampleDendro, labelSize = 3, nBreaks = 5,
file = "Sample_ME_Dendrogram.pdf")
sampleCor <- getCor(MEs, transpose = TRUE, corType = "bicor")
plotHeatmap(sampleCor, rowDendro = sampleDendro, colDendro = sampleDendro,
file = "Sample_Correlation_Heatmap.pdf")
# Visualize Module Eigennode Values
plotHeatmap(MEs, rowDendro = sampleDendro, colDendro = moduleDendro,
legend.title = "Module\nEigennode",
legend.position = c(0.37,0.89),
file = "Sample_ME_Heatmap.pdf")
}