Learn R Programming

phyloseq (version 1.12.2)

distance: General distance / dissimilarity index calculator

Description

Takes a phyloseq-class object and method option, and returns a distance object suitable for certain ordination methods and other distance-based analyses. There are currently 45 explicitly supported method options, as well as user-provided arbitrary methods via an interface to designdist. For the complete list of currently supported options/arguments to the method parameter, type distance("list") at the command-line. Only sample-wise distances are currently supported (the type argument), but eventually species-wise (OTU-wise) distances will be supported as well.

Usage

distance(physeq, method = "unifrac", type = "samples", ...)

Arguments

physeq
(Required). A phyloseq-class or an otu_table-class object. The latter is only appropriate for methods that do not require any additional data (one-table). For example, the ``unifrac'' option (UniFrac) requires phyloseq-class that contains both an otu_table and a phylogenetic tree (phylo).
method
(Optional). A character string. Default is "unifrac". Provide one of the 45 currently supported options. To see a list of supported options, enter the following into the command line:

distance("list")

For further details and additional arguments, see the documentation for the supprting functions, linked below under ``See Also''.

In particular, there are three methods included by the phyloseq-package, and accessed by the following method options:

"unifrac", for (unweighted) UniFrac distance, UniFrac;

"wunifrac", for weighted-UniFrac distance, UniFrac;

"dpcoa", sample-wise distance from Double Principle Coordinate Analysis, DPCoA;

"jsd", for Jensen-Shannon Divergence, JSD;

and it is recommended that you see their documentation for details, references, background and examples for use.

Alternatively, you can provide a character string that defines a custom distance method, if it has the form described in designdist.

type
(Optional). A character string. The type of pairwise comparisons being calculated: sample-wise or taxa-wise. The default is c("samples").
...
Additional arguments passed on to the appropriate distance function, determined by the method argument.

Value

An object of class ``dist'' suitable for certain ordination methods and other distance-based analyses.

Details

Depending on the method argument, distance() wraps one of UniFrac, DPCoA, JSD, vegdist, betadiver, designdist, or dist.

See Also

plot_ordination, UniFrac, DPCoA, JSD, vegdist, betadiver, designdist, dist.

Examples

Run this code
data(esophagus)
distance(esophagus) # Unweighted UniFrac
distance(esophagus, "wunifrac") # weighted UniFrac
distance(esophagus, "jaccard") # vegdist jaccard
distance(esophagus, "gower") # vegdist option "gower"
distance(esophagus, "g") # designdist method option "g"
distance(esophagus, "minkowski") # invokes a method from the base dist() function.
distance(esophagus, "(A+B-2*J)/(A+B)") # designdist custom distance
distance("help")
distance("list")
help("distance")

Run the code above in your browser using DataLab