View source: R/plot.microNetProps.R
plot.microNetProps | R Documentation |
Plotting objects of class microNetProps
.
## S3 method for class 'microNetProps'
plot(x,
layout = "spring",
sameLayout = FALSE,
layoutGroup = "union",
repulsion = 1,
groupNames = NULL,
groupsChanged = FALSE,
labels = NULL,
shortenLabels = "none",
labelLength = 6L,
labelPattern = c(5, "'", 3, "'", 3),
charToRm = NULL,
labelScale = TRUE,
labelFont = 1,
labelFile = NULL,
# Nodes:
nodeFilter = "none",
nodeFilterPar = NULL,
rmSingles = "none",
nodeSize = "fix",
normPar = NULL,
nodeSizeSpread = 4,
nodeColor = "cluster",
colorVec = NULL,
featVecCol = NULL,
sameFeatCol = TRUE,
sameClustCol = TRUE,
sameColThresh = 2L,
nodeShape = NULL,
featVecShape = NULL,
nodeTransp = 60,
borderWidth = 1,
borderCol = "gray80",
# Hubs:
highlightHubs = TRUE,
hubTransp = NULL,
hubLabelFont = NULL,
hubBorderWidth = NULL,
hubBorderCol = "black",
# Edges:
edgeFilter = "none",
edgeFilterPar = NULL,
edgeInvisFilter = "none",
edgeInvisPar = NULL,
edgeWidth = 1,
negDiffCol = TRUE,
posCol = NULL,
negCol = NULL,
cut = NULL,
edgeTranspLow = 0,
edgeTranspHigh = 0,
# Additional arguments:
cexNodes = 1,
cexHubs = 1.2,
cexLabels = 1,
cexHubLabels = NULL,
cexTitle = 1.2,
showTitle = NULL,
title1 = NULL,
title2 = NULL,
mar = c(1, 3, 3, 3),
doPlot = TRUE,
...)
x |
object of class |
layout |
indicates the layout used for defining node positions. Can be
a character with one of the layouts provided by
|
sameLayout |
logical. Indicates whether the same layout should be used
for both networks. Ignored if |
layoutGroup |
numeric or character. Indicates the group, where the
layout is taken from if argument |
repulsion |
positive numeric value indicating the strength of repulsive
forces in the "spring" layout. Nodes are placed closer together for smaller
values and further apart for higher values. See the |
groupNames |
character vector with two entries naming the groups to
which the networks belong. Defaults to the group names returned by
|
groupsChanged |
logical. Indicates the order in which the networks are
plotted. If |
labels |
defines the node labels. Can be a named character vector, which
is used for both groups (then, the adjacency matrices in |
shortenLabels |
character indicating how to shorten node labels.
Ignored if node labels are defined via
|
labelLength |
integer defining the length to which labels shall
be shortened if |
labelPattern |
vector of three or five elements, which is used if
argument |
charToRm |
vector with characters to remove from node names. Ignored if
labels are given via |
labelScale |
logical. If |
labelFont |
integer defining the font of node labels. Defaults to 1. |
labelFile |
optional character of the form "<file name>.txt" naming a file where the original and renamed node labels are stored. The file is stored into the current working directory. |
nodeFilter |
character indicating whether and how nodes should be filtered. Possible values are:
|
nodeFilterPar |
parameters needed for the filtering method defined by
|
rmSingles |
character value indicating how to handle unconnected nodes.
Possible values are |
nodeSize |
character indicating how node sizes should be determined. Possible values are:
|
normPar |
list with parameters passed to the function for normalization
if |
nodeSizeSpread |
positive numeric value indicating the spread of node
sizes. The smaller the value, the more similar are the node sizes. Node
sizes are calculated by: (x - min(x)) / (max(x) - min(x)) * nodeSizeSpread
+ cexNodes. For |
nodeColor |
a character specifying the node colors. Possible values are
|
colorVec |
a vector or list with two vectors used to specify node colors. Different usage depending on the "nodeColor" argument:
|
featVecCol |
a vector with a feature for each node. Used for coloring
nodes if |
sameFeatCol |
logical indicating whether the same color should be used
for same features in both networks (only used if two networks are plotted,
|
sameClustCol |
if TRUE (default) and two networks are plotted, clusters
having at least |
sameColThresh |
indicates how many nodes a cluster must have in common
in the two groups to have the same color. See argument |
nodeShape |
character vector specifying node shapes. Possible values
are |
featVecShape |
a vector with a feature for each node. If not |
nodeTransp |
an integer between 0 and 100 indicating the transparency of node colors. 0 means no transparency, 100 means full transparency. Defaults to 60. |
borderWidth |
numeric specifying the width of node borders. Defaults to 1. |
borderCol |
character specifying the color of node borders. Defaults to "gray80" |
highlightHubs |
logical indicating if hubs should be highlighted. If
|
hubTransp |
numeric between 0 and 100 specifying the color transparency
of hub nodes. See argument |
hubLabelFont |
integer specifying the label font of hub nodes. Defaults
to |
hubBorderWidth |
numeric specifying the border width of hub nodes.
Defaults to |
hubBorderCol |
character specifying the border color of hub nodes.
Defaults to |
edgeFilter |
character specifying how edges are filtered. Possible values are:
x is defined by |
edgeFilterPar |
numeric specifying the "x" in |
edgeInvisFilter |
similar to |
edgeInvisPar |
numeric specifying the "x" in |
edgeWidth |
numeric specifying the edge width. See argument
|
negDiffCol |
logical indicating if edges with a negative corresponding
association should be colored different. If |
posCol |
vector (character or numeric) with one or two elements
specifying the color of edges with positive weight and also for edges with
negative weight if |
negCol |
vector (character or numeric) with one or two elements
specifying the color of edges with negative weight. The first
element is used for edges with absolute weight below |
cut |
defines the |
edgeTranspLow |
numeric value between 0 and 100 specifying the
transparency of edges with weight below |
edgeTranspHigh |
analogous to |
cexNodes |
numeric scaling node sizes. Defaults to 1. |
cexHubs |
numeric scaling hub sizes. Only used if |
cexLabels |
numeric scaling node labels. Defaults to 1. If set to 0, no node labels are plotted. |
cexHubLabels |
numeric scaling the node labels of hub nodes. Equals
|
cexTitle |
numeric scaling title(s). Defaults to 1.2. |
showTitle |
if |
title1 |
character giving a title for the first network. |
title2 |
character giving a title for the second network (if existing). |
mar |
a numeric vector of the form c(bottom, left, top, right) defining
the plot margins. Works similar to the |
doPlot |
logical. If |
... |
further arguments being passed to |
Returns (invisibly) a list with the following elements:
q1,q2 | the qgraph object(s) |
layout | layout(s) specifying node positions |
nodecolor | one or two vectors with node colors (one for each group) |
labels | one or two vectors with node labels |
# Load data sets from American Gut Project (from SpiecEasi package)
data("amgut1.filt")
# Network construction
amgut_net <- netConstruct(amgut1.filt, measure = "pearson",
filtTax = "highestVar",
filtTaxPar = list(highestVar = 50),
zeroMethod = "pseudoZO", normMethod = "clr",
sparsMethod = "threshold", thresh = 0.3)
# Network analysis
amgut_props <- netAnalyze(amgut_net)
### Network plots ###
# Clusters are used for node coloring:
plot(amgut_props,
nodeColor = "cluster")
# Remove singletons
plot(amgut_props,
nodeColor = "cluster",
rmSingles = TRUE)
# A higher repulsion places nodes with high edge weight closer together
plot(amgut_props,
nodeColor = "cluster",
rmSingles = TRUE,
repulsion = 1.2)
# A feature vector is used for node coloring
# (this could be a vector with phylum names of the ASVs)
set.seed(123456)
featVec <- sample(1:5, nrow(amgut1.filt), replace = TRUE)
# Names must be equal to ASV names
names(featVec) <- colnames(amgut1.filt)
plot(amgut_props,
rmSingles = TRUE,
nodeColor = "feature",
featVecCol = featVec,
colorVec = heat.colors(5))
# Use a further feature vector for node shapes
shapeVec <- sample(1:3, ncol(amgut1.filt), replace = TRUE)
names(shapeVec) <- colnames(amgut1.filt)
plot(amgut_props,
rmSingles = TRUE,
nodeColor = "feature",
featVecCol = featVec,
colorVec = heat.colors(5),
nodeShape = c("circle", "square", "diamond"),
featVecShape = shapeVec,
highlightHubs = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.