plot_net: Microbiome Network Plot using ggplot2

View source: R/plot-methods.R

plot_netR Documentation

Microbiome Network Plot using ggplot2

Description

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. Note that this function is a performance and interface revision to plot_network, which requires an igraph object as its first argument. This new function is more in-line with other plot_* functions in the phyloseq-package, in that its first/main argument is a phyloseq-class instance. 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. However, network line thickness and opacity is scaled according to the similarity of vertices (either samples or taxa), helping to temper, somewhat, the effect of the threshold. Also note that the choice of network layout algorithm can have a large effect on the impression and interpretability of the network graphic, and you may want to familiarize yourself with some of these options (see the laymeth argument).

Usage

plot_net(physeq, distance = "bray", type = "samples", maxdist = 0.7,
  laymeth = "fruchterman.reingold", color = NULL, shape = NULL,
  rescale = FALSE, point_size = 5, point_alpha = 1,
  point_label = NULL, hjust = 1.35, title = NULL)

Arguments

physeq

(Required). The phyloseq-class object that you want to represent as a network.

distance

(Optional). Default is "bray". Can be either a distance method supported by distance, or an already-computed dist-class with labels that match the indices implied by both the physeq and type arguments (that is, either sample or taxa names). If you used distance to pre-calculate your distance, and the same type argument as provided here, then they will match.

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.

maxdist

(Optional). Default 0.7. The maximum distance value between two vertices to connect with an edge in the graphic.

laymeth

(Optional). Default "fruchterman.reingold". A character string that indicates the method that will determine the placement of vertices, typically based on conectedness of vertices and the number of vertices. This is an interesting topic, and there are lots of options. See igraph-package for related topics in general, and see layout.auto for descriptions of various alternative layout method options supported here. The character string argument should match exactly the layout function name with the "layout." omitted. Try laymeth="list" to see a list of options.

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).

rescale

(Optional). Logical. Default FALSE. Whether to rescale the distance values to be [0, 1], in which the min value is close to zero and the max value is 1.

point_size

(Optional). Default 5. The size of the vertex points.

point_alpha

(Optional). Default 1. A value between 0 and 1 for the alpha transparency of the vertex points.

point_label

(Optional). Default NULL. The variable name in physeq covariate data to map to vertex labels.

hjust

(Optional). Default 1.35. The amount of horizontal justification to use for each label.

title

(Optional). Default NULL. Character string. The main title for the graphic.

Value

A ggplot2 network plot. Will render to default graphic device automatically as print side effect. Can also be saved, further manipulated, or rendered to a vector or raster file using ggsave.

See Also

Original network plotting functions:

make_network

plot_network

Examples

data(enterotype)
plot_net(enterotype, color="SeqTech", maxdist = 0.3)
plot_net(enterotype, color="SeqTech", maxdist = 0.3, laymeth = "auto")
plot_net(enterotype, color="SeqTech", maxdist = 0.3, laymeth = "svd")
plot_net(enterotype, color="SeqTech", maxdist = 0.3, laymeth = "circle")
plot_net(enterotype, color="SeqTech", shape="Enterotype", maxdist = 0.3, laymeth = "circle")

joey711/phyloseq documentation built on Nov. 4, 2022, 1:16 a.m.