View source: R/network-methods.R
make_network | R Documentation |
A specialized function for creating a network representation of microbiomes,
sample-wise or taxa-wise,
based on a user-defined ecological distance and (potentially arbitrary) threshold.
The graph is ultimately represented using the
igraph
-package.
make_network(physeq, type="samples", distance="jaccard", max.dist = 0.4, keep.isolates=FALSE, ...)
physeq |
(Required). Default |
type |
(Optional). Default NOTE: not all distance methods are supported if |
distance |
(Optional). Default Alternatively, if you have already calculated the sample-wise distance
object, the resulting A third alternative is to provide a function that takes a sample-by-taxa matrix (typical vegan orientation) and returns a sample-wise distance matrix. |
max.dist |
(Optional). Default |
keep.isolates |
(Optional). Default |
... |
(Optional). Additional parameters passed on to |
A igraph
-class object.
plot_network
# # Example plots with Enterotype Dataset data(enterotype) ig <- make_network(enterotype, max.dist=0.3) plot_network(ig, enterotype, color="SeqTech", shape="Enterotype", line_weight=0.3, label=NULL) # ig1 <- make_network(enterotype, max.dist=0.2) plot_network(ig1, enterotype, color="SeqTech", shape="Enterotype", line_weight=0.3, label=NULL) # # # Three methods of choosing/providing distance/distance-method # Provide method name available to distance() function ig <- make_network(enterotype, max.dist=0.3, distance="jaccard") # Provide distance object, already computed jaccdist <- distance(enterotype, "jaccard") ih <- make_network(enterotype, max.dist=0.3, distance=jaccdist) # Provide "custom" function. ii <- make_network(enterotype, max.dist=0.3, distance=function(x){vegan::vegdist(x, "jaccard")}) # The have equal results: all.equal(ig, ih) all.equal(ig, ii) # # Try out making a trivial "network" of the 3-sample esophagus data, # with weighted-UniFrac as distance data(esophagus) ij <- make_network(esophagus, "samples", "unifrac", weighted=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.