Your question here

If you have problems or questions, ideas for improvements, or even found a bug or two, feel free to post at or email one of the developers, anything and everything is welcome.

Preserving relative abundances in a subset of larger data

By default the raw read counts in the abundance matrix are normalised (transformed to percentages) by some plotting functions automatically (for example amp_heatmap, amp_timeseries, and more). This means that the relative abundances shown will be calculated based on the remaining taxa after the subset, not including the removed taxa, if any. To circumvent this, set normalise = TRUE when subsetting with the amp_subset_taxa and amp_subset_samples functions, and then set raw = TRUE in the plotting function. This will transform the OTU counts to relative abundances BEFORE the subset, and setting raw = TRUE will skip the transformation in the plotting function, see the example below.

subsettedData <- amp_subset_samples(MiDAS,
                                    Plant %in% c("Aalborg West", "Aalborg East"),
                                    normalise = TRUE #add this
            group_by = "Plant",
            tax_aggregate = "Phylum",
            tax_add = "Genus",
            normalise = FALSE #add this

Custom distance matrix for use in ordination

If you wan’t to calculate a distance matrix manually and use it for PCoA in amp_ordinate, it can be done quite easily by just setting filter_species = 0, transform = "none", and distmeasure = "none", like below. The matrix should be a symmetrical matrix containing coefficients for all pairs of samples in the data. This is not ideal for nMDS (nor possible) since it is not an eigenvalue based method, but if you really want, set distmeasure = "euclidean" instead of “none”.

#Override the abundance table in the ampvis2 object with a custom distance matrix
ampvis2_object$abund <- as.dist(custom_dist_matrix)

#set filter_species = 0, transform = "none", and distmeasure = "none"
             type = "pcoa",
             filter_species = 0,
             transform = "none",
             distmeasure = "none")

Loading phyloseq objects

Simply source the phyloseq_to_ampvis2() function from this gist, either by copy/pasting into R, or by using devtools::source_gist() as shown below. You need both the phyloseq and ampvis2 packages installed for it to work.

#require the devtools package to source gist
#source the phyloseq_to_ampvis2() function from the gist

#go converty
ampvis2_obj <- phyloseq_to_ampvis2(phyloseq_obj)