Skip to contents

Run ordinations on a distance matrix.

Usage

distmat_ord_table(dm, ord = "PCoA", k = 2L, ...)

Arguments

dm

A dist-class distance matrix, as returned from bdiv_distmat() or stats::dist(). Required.

ord

Method for reducing dimensionality. Options are:

"PCoA" -

Principal coordinate analysis; ape::pcoa().

"UMAP" -

Uniform manifold approximation and projection; uwot::umap().

"NMDS" -

Nonmetric multidimensional scaling; vegan::metaMDS().

"tSNE" -

t-distributed stochastic neighbor embedding; tsne::tsne().

Default: "PCoA"

Multiple/abbreviated values allowed.

k

Number of ordination dimensions to return. Either 2L or 3L. Default: 2L

...

Additional arguments for ord.

Value

A data.frame with columns .sample, .ord, .x, .y, and (optionally) .z.

See also

Other ordination: bdiv_ord_plot(), bdiv_ord_table()

Examples

    library(rbiom) 
    
    dm  <- bdiv_distmat(hmp50, "bray")
    ord <- distmat_ord_table(dm, "PCoA")
    head(ord)
#> # Ordination: ape::pcoa(D = dm)
#> # A tibble:   6 × 4
#>   .ord  .sample     .x       .y
#>   <fct> <chr>    <dbl>    <dbl>
#> 1 PCoA  HMP01   -0.358  0.00236
#> 2 PCoA  HMP02   -0.420  0.0104 
#> 3 PCoA  HMP03   -0.382  0.0135 
#> 4 PCoA  HMP04   -0.388  0.00485
#> 5 PCoA  HMP05   -0.415 -0.0115 
#> 6 PCoA  HMP06   -0.414 -0.00703