The main inspiration for the mvarVis
package comes from the
plot_ordination
command in package phyloseq
. Given the result of an
ordination, we should be able to plot various features onto the projected
points easily. plot_ordination
implements this idea in the case that
the ordination has features from a phyloseq
object, but the idea
can be applied more generally.
plot_ordination
analoguesTo get an idea for how this package works, here are some examples
re-implementing the methods in plot_ordination
from the
phyloseq documentation.
First we load the data from the linked page.
library("ape") library("ade4") library("phyloseq") library("vegan") library("mvarVis")
data("GlobalPatterns") GP = GlobalPatterns wh0 = genefilter_sample(GP, filterfun_sample(function(x) x > 5), A = 0.5 * nsamples(GP)) GP1 = prune_taxa(wh0, GP) GP1 = transform_sample_counts(GP1, function(x) 1e+06 * x/sum(x)) phylum.sum = tapply(taxa_sums(GP1), tax_table(GP1)[, "Phylum"], sum, na.rm = TRUE) top5phyla = names(sort(phylum.sum, TRUE))[1:5] GP1 = prune_taxa((tax_table(GP1)[, "Phylum"] %in% top5phyla), GP1) human = get_variable(GP1, "SampleType") %in% c("Feces", "Mock", "Skin", "Tongue") sample_data(GP1)$human <- factor(human)
vegan
methodsgp1_nmds <- ordi(GP1@otu_table, GP1@tax_table, GP1@sam_data, method = "metaMDS") plot_mvar(gp1_nmds, col = "Phylum", shape = "human", layers_list = "point-text") # DCA gp1_dca <- ordi(GP1@otu_table, GP1@tax_table, GP1@sam_data, method = "decorana") plot_mvar(gp1_dca, col = "Phylum", shape = "human")
ade4
methodsNote that we can pass in ade4
arguments through ordi
(as in the
scannf = F
below).
# MDS gp1_mds <- ordi(GP1@otu_table, GP1@tax_table, GP1@sam_data, method = "pco", dist_method = "euclidean", scannf = F) plot_mvar(gp1_mds, col = "Phylum", shape = "human")
I haven't implemented the pcoa example yet, since this needs a conversion
from an ape
specific format.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.