There are many useful examples of phyloseq network graphics in the
phyloseq online tutorials.
A custom plotting function for displaying networks
using advanced 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.
(Required). An igraph-class object created
either by the convenience wrapper make_network,
or directly by the tools in the igraph-package.
physeq
(Optional). Default NULL.
A phyloseq-class object on which g is based.
type
(Optional). Default "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.
color
(Optional). Default NULL.
The name of the sample variable in physeq to use for color mapping
of points (graph vertices).
shape
(Optional). Default NULL.
The name of the sample variable in physeq to use for shape mapping.
of points (graph vertices).
point_size
(Optional). Default 4.
The size of the vertex points.
alpha
(Optional). Default 1.
A value between 0 and 1 for the alpha transparency of the vertex points.
label
(Optional). Default "value".
The name of the sample variable in physeq to use for
labelling the vertex points.
hjust
(Optional). Default 1.35.
The amount of horizontal justification to use for each label.
line_weight
(Optional). Default 0.3.
The line thickness to use to label graph edges.
line_color
(Optional). Default color.
The name of the sample variable in physeq to use for color mapping
of lines (graph edges).
line_alpha
(Optional). Default 0.4.
The transparency level for graph-edge lines.
layout.method
(Optional). Default 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:
title
(Optional). Default NULL. Character string.
The main title for the graphic.
layout.fruchterman.reingold
Value
A ggplot2 plot representing the network,
with optional mapping of variable(s) to point color or shape.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(phyloseq)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/phyloseq/plot_network.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot_network
> ### Title: Microbiome Network Plot using ggplot2
> ### Aliases: plot_network
>
> ### ** Examples
>
>
> data(enterotype)
> ig <- make_network(enterotype, max.dist=0.3)
> plot_network(ig, enterotype, color="SeqTech", shape="Enterotype", line_weight=0.3, label=NULL)
Warning message:
attributes are not identical across measure variables; they will be dropped
> # 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)
Warning message:
attributes are not identical across measure variables; they will be dropped
>
>
>
>
>
> dev.off()
null device
1
>