ggplot2 formatting.
The network itself should be represented using
the igraph package.
For the phyloseq-package it is suggested that the network object
(argument g)
be created using the
make_network function,
and based upon sample-wise or taxa-wise microbiome ecological distances
calculated from a phylogenetic sequencing experiment
(phyloseq-class).
In this case, edges in the network are created if the distance between
nodes is below a potentially arbitrary threshold,
and special care should be given to considering the choice of this threshold.plot_network(g, physeq=NULL, type="samples",
color=NULL, shape=NULL, point_size=4, alpha=1,
label="value", hjust = 1.35,
line_weight=0.5, line_color=color, line_alpha=0.4,
layout.method=layout.fruchterman.reingold, title=NULL)igraph-class object created
either by the convenience wrapper make_network,
or directly by the tools in the igraph-package.NULL.
A phyloseq-class object on which g is based."samples".
Whether the network represented in the primary argument, g,
is samples or taxa/OTUs.
Supported arguments are "samples", "taxa",
where "taxa" indicates using the taxa indices,
whether they actually represent species or some other taxonomic rank.NULL.
The name of the sample variable in physeq to use for color mapping
of points (graph vertices).NULL.
The name of the sample variable in physeq to use for shape mapping.
of points (graph vertices).4.
The size of the vertex points.1.
A value between 0 and 1 for the alpha transparency of the vertex points."value".
The name of the sample variable in physeq to use for
labelling the vertex points.1.35.
The amount of horizontal justification to use for each label.0.3.
The line thickness to use to label graph edges.color.
The name of the sample variable in physeq to use for color mapping
of lines (graph edges).0.4.
The transparency level for graph-edge lines.layout.fruchterman.reingold.
A function (closure) that determines the placement of the vertices
for drawing a graph. Should be able to take an igraph-class
as sole argument, and return a two-column coordinate matrix with nrow
equal to the number of vertices. For possible options already included in
igraph-package, see the others also described in the help file:NULL. Character string.
The main title for the graphic.ggplot2 plot representing the network,
with optional mapping of variable(s) to point color or shape. The code most directly used/modified was first posted here:
make_networkdata(enterotype)
ig <- make_network(enterotype, max.dist=0.3)
plot_network(ig, enterotype, color="SeqTech", shape="Enterotype", line_weight=0.3, label=NULL)
# Change distance parameter
ig <- make_network(enterotype, max.dist=0.2)
plot_network(ig, enterotype, color="SeqTech", shape="Enterotype", line_weight=0.3, label=NULL)Run the code above in your browser using DataLab