plotData: Plot a heatmap of the data matrix for one or more
network modules.
plotCorrelation: Plot a heatmap of the correlation structure for one
or more network modules.
plotNetwork: Plot a heatmap of the edge weights for one or more
network modules.
plotContribution: Plot a bar chart of the node contribution for
one or more network modules.
plotDegree: Plot a bar chart of the scaled weighted degree
(see details) for one or more network modules.
plotSummary: Plot bar charts of the module summary vectors of
one or more network modules.
plotData(network, data, correlation, moduleAssignments = NULL, modules = NULL, backgroundLabel = "0", discovery = NULL, test = NULL, verbose = TRUE, orderSamplesBy = NULL, orderNodesBy = NULL, orderModules = TRUE, plotNodeNames = TRUE, plotSampleNames = TRUE, plotModuleNames = NULL, main = "", main.line = 1, lwd = 1, plotLegend = TRUE, legend.main = "Data", legend.main.line = 1, naxt.line = -0.5, saxt.line = -0.5, maxt.line = 3, legend.position = 0.15, laxt.tck = 0.03, laxt.line = 3, cex.axis = 0.8, cex.lab = 1.2, cex.main = 2, dataCols = NULL, dataRange = NULL, naCol = "#bdbdbd", dryRun = FALSE)
plotCorrelation(network, data, correlation, moduleAssignments = NULL, modules = NULL, backgroundLabel = "0", discovery = NULL, test = NULL, verbose = TRUE, orderNodesBy = NULL, symmetric = FALSE, orderModules = TRUE, plotNodeNames = TRUE, plotModuleNames = NULL, main = "", main.line = 1, lwd = 1, plotLegend = TRUE, legend.main = "Correlation", legend.main.line = 1, naxt.line = -0.5, maxt.line = 3, legend.position = NULL, laxt.tck = NULL, laxt.line = NULL, cex.axis = 0.8, cex.lab = 1.2, cex.main = 2, corCols = correlation.palette(), corRange = c(-1, 1), naCol = "#bdbdbd", dryRun = FALSE)
plotNetwork(network, data, correlation, moduleAssignments = NULL, modules = NULL, backgroundLabel = "0", discovery = NULL, test = NULL, verbose = TRUE, orderNodesBy = NULL, symmetric = FALSE, orderModules = TRUE, plotNodeNames = TRUE, plotModuleNames = NULL, main = "", main.line = 1, lwd = 1, plotLegend = TRUE, legend.main = "Edge weight", legend.main.line = 1, naxt.line = -0.5, maxt.line = 3, legend.position = NULL, laxt.tck = NULL, laxt.line = NULL, cex.axis = 0.8, cex.lab = 1.2, cex.main = 2, netCols = network.palette(), netRange = c(0, 1), naCol = "#bdbdbd", dryRun = FALSE)
plotContribution(network, data, correlation, moduleAssignments = NULL, modules = NULL, backgroundLabel = "0", discovery = NULL, test = NULL, verbose = TRUE, orderNodesBy = NULL, orderModules = TRUE, plotNodeNames = TRUE, plotModuleNames = NULL, main = "", main.line = 1, ylab.line = 2.5, lwd = 1, drawBorders = FALSE, naxt.line = -0.5, maxt.line = 3, yaxt.line = 0, yaxt.tck = -0.035, cex.axis = 0.8, cex.lab = 1.2, cex.main = 2, contribCols = c("#A50026", "#313695"), naCol = "#bdbdbd", dryRun = FALSE)
plotDegree(network, data, correlation, moduleAssignments = NULL, modules = NULL, backgroundLabel = "0", discovery = NULL, test = NULL, verbose = TRUE, orderNodesBy = NULL, orderModules = TRUE, plotNodeNames = TRUE, plotModuleNames = NULL, main = "", main.line = 1, lwd = 1, drawBorders = FALSE, naxt.line = -0.5, maxt.line = 3, yaxt.line = 0, yaxt.tck = -0.035, ylab.line = 2.5, cex.axis = 0.8, cex.lab = 1.2, cex.main = 2, degreeCol = "#feb24c", naCol = "#bdbdbd", dryRun = FALSE)
plotSummary(network, data, correlation, moduleAssignments = NULL, modules = NULL, backgroundLabel = "0", discovery = NULL, test = NULL, verbose = TRUE, orderSamplesBy = NULL, orderNodesBy = NULL, orderModules = TRUE, plotSampleNames = TRUE, plotModuleNames = NULL, main = "", main.line = 1, xlab.line = 2.5, lwd = 1, drawBorders = FALSE, saxt.line = -0.5, maxt.line = 0, xaxt.line = 0, xaxt.tck = -0.025, cex.axis = 0.8, cex.lab = 1.2, cex.main = 2, summaryCols = c("#1B7837", "#762A83"), naCol = "#bdbdbd", dryRun = FALSE)network for that
dataset. The columns should correspond to variables in the data
(nodes in the network) and rows to samples in that dataset.data used to infer the interaction network for that dataset.discovery dataset,
of modules to perform the analysis on. If unspecified, all modules
in each discovery dataset will be analysed, with the exception of
those specified in backgroundLabel argument.moduleAssignments argument.data, correlation, network,
moduleAssignments, modules, and test lists.discovery dataset,
of names or indices denoting the test dataset(s) in the data,
correlation, and network lists.TRUE.NULL (default), NA, or a vector
containing a single dataset name or index. Controls how samples are ordered
on the plot (see details).NULL (default), NA, or a vector of dataset
names or indices. Controls how nodes are ordered on the plot (see details).TRUE modules ordered by clustering
their summary vectors. If FALSE modules are returned in the order
provided.modules
are drawn.plotCorrelation, plotNetwork, or plotData.laxt.tck.NA or
NULL.dataCols gradient
(see details). Automatically determined if NA or NULL.TRUE, only the axes and labels will be
drawed.corCols gradient
(see details).corCols gradient
(see details). Automatically determined if NA or NULL.TRUE, borders are drawn around the
weighted degree, node conribution, and module summary
bar plots.NetRep package have the
following arguments:
network:
a list of interaction networks, one for each dataset.
data:
a list of data matrices used to infer those networks, one for each
dataset.
correlation:
a list of matrices containing the pairwise correlation coefficients
between variables/nodes in each dataset.
moduleAssignments:
a list of vectors, one for each discovery dataset, containing
the module assignments for each node in that dataset.
modules:
a list of vectors, one for each discovery dataset, containing
the names of the modules from that dataset to analyse.
discovery:
a vector indicating the names or indices of the previous arguments'
lists to use as the discovery dataset(s) for the analyses.
test:
a list of vectors, one vector for each discovery dataset,
containing the names or indices of the network, data, and
correlation argument lists to use as the test dataset(s)
for the analysis of each discovery dataset.
The formatting of these arguments is not strict: each function will attempt
to make sense of the user input. For example, if there is only one
discovery dataset, then input to the moduleAssigments and
test arguments may be vectors, rather than lists. If the node and
sample ordering is being calculated within the same dataset being
visualised, then the discovery and test arguments do
not need to be specified, and the input matrices for the network,
data, and correlation arguments do not need to be wrapped in
a list.
Analysing large datasets:
Matrices in the network, data, and correlation lists
can be supplied as disk.matrix objects. This class allows
matrix data to be kept on disk and loaded as required by NetRep.
This dramatically decreases memory usage: the matrices for only one
dataset will be kept in RAM at any point in time.
Node, sample, and module ordering:
By default, nodes are ordered in decreasing order of weighted degree
in the discovery dataset (see nodeOrder). Missing
nodes are colored in grey. This facilitates the visual comparison of
modules across datasets, as the node ordering will be preserved.
Alternatively, a vector containing the names or indices of one or more
datasets can be provided to the orderNodesBy argument.
If a single dataset is provided, then nodes will be ordered in decreasing
order of weighted degree in that dataset. Only nodes that are
present in this dataset will be drawn when ordering nodes by a dataset
that is not the discovery dataset for the requested modules(s).
If multiple datasets are provided then the weighted degree will be
averaged across these datasets (see nodeOrder for more details).
This is useful for obtaining a robust ordering of nodes by relative
importance, assuming the modules displayed are preserved in those
datasets.
Ordering of nodes by weighted degree can be suppressed by setting
orderNodesBy to NA, in which case nodes will be ordered as
in the matrices provided in the network, data, and
correlation arguments.
When multiple modules are drawn, modules are ordered by the similarity
of their summary vectors in the dataset(s) specified in orderNodesBy
argument. If multiple datasets are provided to the orderNodesBy
argument then the module summary vectors are concatenated across datasets.
By default, samples in the data heatmap and accompanying module summary bar
plot are ordered in descending order of module summary in the drawn
dataset (specified by the test argument). If multiple modules are
drawn, samples are ordered as per the left-most module on the plot.
Alternatively, a vector containing the name or index of another dataset
may be provided to the orderSamplesBy argument. In this case,
samples will be ordered in descending order of module summary in
the specified dataset. This is useful when comparing different
measurements across samples, for example, gene expression data obtained
from multiple tissues samples across the same individuals. If the dataset
specified is the discovery dataset, then missing samples will be
displayed as horizontal grey bars. If the dataset specified is one of the
other datasets, then only samples present in both the specified dataset
and the test dataset will be displayed.
Order of samples by module summary can be suppressed by setting
orderSamplesBy to NA, in which case samples will be order as
in the matrix provided to the data argument for the drawn dataset.
Weighted degree scaling: When drawn on a plot, the weighted degree of each node is scaled to the maximum weighted degree within its module. The scaled weighted degree is measure of relative importance for each node to its module. This makes visualisation of multiple modules with different sizes and densities possible. However, the scaled weighted degree should only be interpreted for groups of nodes that have an apparent module structure.
Plot layout and device size
Although reasonable default values for most parameters have been provided,
the rendering of axes and titles may need adjusting depending on the size
of the plot window. The dryRun argument is useful for quickly
determining whether the plot will render correctly. When dryRun
is TRUE only the axes, legends, labels, and title will be drawn,
allowing for quick iteration of customisable parameters to get the plot
layout correct.
Warning: PDF and other vectorized devices should not be used when
plotting the heatmaps with more than a hundred nodes. Large files will be
generated which may cause image editing programs such as Inkscape or
Illustrator to crash when polishing figures for publication.
If axis labels or legends are drawn off screen then the margins of the
plot should be adjusted prior to plotting using the
par command to increase the margin size
(see the "mar" option in the par help page).
The size of text labels can be modified by increasing or decreasing the
cex.main, cex.lab, and cex.axis arguments:
cex.main: controls the size of the plot title (specified
in the main argument).
cex.lab: controls the size of the axis labels on the
weighted degree, node contribution,
and module summary bar plots as well as
the size of the module labels and the heatmap
legend titles.
cex.axis: contols the size of the axis tick labels,
including the node and sample labels.
The position of these labels can be changed through the following arguments:
xaxt.line: controls the distance from the plot the x-axis
tick labels are drawn on the module summary bar plot.
xlab.line: controls the distance from the plot the x-axis
label is drawn on the module summary bar plot.
yaxt.line: controls the distance from the plot the y-axis
tick labels are drawn on the weighted degree and
node contribution bar plots.
ylab.line: controls the distance from the plot the y-axis
label is drawn on the weighted degree and
node contribution bar plots.
main.line: controls the distance from the plot the title is
drawn.
naxt.line: controls the distance from the plot the node
labels are drawn.
saxt.line: controls the distance from the plot the sample
labels are drawn.
maxt.line: controls the distance from the plot the module
labels are drawn.
laxt.line: controls the distance from the heatmap legends
that the gradient legend labels are drawn.
legend.main.line: controls the distance from the heatmap
legends that the legend title is drawn.
The rendering of node, sample, and module names can be disabled by setting
plotNodeNames, plotSampleNames, and plotModuleNames
to FALSE.
The size of the axis ticks can be changed by increasing or decreasing the
following arguments:
xaxt.tck: size of the x-axis tick labels as a multiple of
the height of the module summary bar plot
yaxt.tck: size of the y-axis tick labels as a multiple of
the width of the weighted degree or node contribution
bar plots.
laxt.tck: size of the heatmap legend axis ticks as a
multiple of the width of the data, correlation structure, or
network edge weight heatmaps.
The placement of heatmap legends is controlled by the following arguments:
plotLegend: if FALSE legend will not be drawn.
legend.position: a multiple of the plot width, controls
the horizontal distance from the plot the legend is drawn.
drawBorders argument controls whether borders are drawn around
the weighted degree, node contribution, or module summary bar plots. The
lwd argument controls the thickness of these borders, as well as
the thickness of axes and axis ticks.Modifying the color palettes:
The dataCols and dataRange arguments control the appearance
of the data heatmap (see plotData). The gradient of colors
used on the heatmap can be changed by specifying a vector of colors to
interpolate between in dataCols and dataRange specifies the
range of values that maps to this gradient. Values outside of the
specified dataRange will be rendered with the colors used at either
extreme of the gradient. The default gradient is determined based on the
data shown on the plot. If all values in the data matrix are
positive, then the gradient is interpolated between white and green, where
white is used for the smallest value and green for the largest. If all
values are negative, then the gradient is interpolated between purple and
white, where purple is used for the smallest value and white for the value
closest to zero. If the data contains both positive and negative values,
then the gradient is interpolated between purple, white, and green, where
white is used for values of zero. In this case the range shown is always
centered at zero, with the values at either extreme determined by the
value in the rendered data with the strongest magnitude (the
maximum of the absolute value).
The corCols and corRange arguments control the appearance of
the correlation structure heatmap (see plotCorrelation). The
gradient of colors used on the heatmap can be changed by specifying a
vector of colors to interpolate between in corCols. By default,
strong negative correlations are shown in blue, and strong positive
correlations in red, and weak correlations as white. corRange
controls the range of values that this gradient maps to, by default, -1 to
1. Changing this may be useful for showing differences where range of
correlation coefficients is small.
The netCols and netRange arguments control the appearance of
the network edge weight heatmap (see plotNetwork). The
gradient of colors used on the heatmap can be changed by specifying a
vector of colors to interpolate between in netCols. By default,
weak or non-edges are shown in white, while strong edges are shown in red.
The netRange controls the range of values this gradient maps to,
by default, 0 to 1. If netRange is set to NA, then the
gradient will be mapped to values between 0 and the maximum edge weight of
the shown network.
The degreeCol argument controls the color of the weighted degree
bar plot (see plotDegree).
The contribCols argument controls the color of the node
contribution bar plot (see plotContribution. This can be
specified as single value to be used for all nodes, or as two colors: one
to use for nodes with positive contributions and one to use for nodes with
negative contributions.
The summaryCols argument controls the color of the module summary
bar plot (see plotSummary. This can be specified as single
value to be used for all samples, or as two colors: one to use for samples
with a positive module summary value and one fpr samples with a negative
module summary value.
The naCol argument controls the color of missing nodes and samples
on the data, correlaton structure, and network edge weight heatmaps.
plotModule for a combined plot showing all topological
properties for a network module.
# load in example data, correlation, and network matrices for a discovery and test dataset:
data("NetRep")
# Set up input lists for each input matrix type across datasets. The list
# elements can have any names, so long as they are consistent between the
# inputs.
network_list <- list(discovery=discovery_network, test=test_network)
data_list <- list(discovery=discovery_data, test=test_data)
correlation_list <- list(discovery=discovery_correlation, test=test_correlation)
labels_list <- list(discovery=module_labels)
# Plot the data for module 1, 2 and 4 in the discovery dataset
plotData(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4)
)
# Symmetric = TRUE gives a traditional heatmap for the correlation structure
# and weighted network
plotCorrelation(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4), symmetric=TRUE
)
# While the default is to render only one half of the (symmetric) matrix
plotNetwork(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4)
)
# Plot the degree of nodes in each module in the test dataset, but show them
# in the same order as the discovery dataset to compare how node degree
# changes
plotDegree(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4), discovery="discovery",
test="test"
)
# Alternatively nodes can be ordered on the plot by degree in the test dataset
plotDegree(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4), discovery="discovery",
test="test", orderNodesBy="test"
)
# Or by averaging the degree across datasets for a more robust ordering
plotDegree(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4), discovery="discovery",
test="test", orderNodesBy=c("discovery", "test")
)
# Arbitrary subsets can be plotted:
plotContribution(
network=network_list[[1]][1:10, 1:10], data=data_list[[1]][, 1:10],
correlation=correlation_list[[1]][1:10, 1:10], orderNodesBy=NA
)
# Plot the module summary vectors for multiple modules:
plotSummary(
network=network_list, data=data_list, correlation=correlation_list,
moduleAssignments=labels_list, modules=c(1, 2, 4), discovery="discovery",
test="test", orderSamplesBy="test"
)
Run the code above in your browser using DataLab