add_ord() adds the first n dimensions of a dimensionality reduction
method performed on a given dissimilarity matrix as new variables to the
sample table of a tidytacos object.
Arguments
- ta
A tidytacos object.
- distance
The distance indices to use, see
vegan::vegdist().- method
The ordination method to use to calculate coordinates. Choices are
pcoa,tsne,umap.- dims
The amount of dimensions to reduce the dissimilarities to.
- binary
Perform presence/absence standardisation before distance computation or not.
- ...
Additional arguments to pass to the ordination function: either
stats::cmdscale(),Rtsne::Rtsne()orumap::umap().
Details
This function calculates the dissimilarities between samples followed by
an ordination analysis. It will then add the first n dimensions to
the sample table of a tidytacos object named "ord1", "ord2", ... This
function will also add relative abundances if not present using
add_rel_abundance().
See also
Other sample-modifiers:
add_alpha(),
add_alphas(),
add_dominant_taxa(),
add_metadata(),
add_sample_clustered(),
add_spike_ratio(),
add_subsampled_alpha(),
add_total_absolute_abundance(),
add_total_count(),
add_total_density(),
cluster_samples()
Other diversity-metrics:
add_alpha(),
add_alphas(),
add_subsampled_alpha()
Examples
# Initiate counts matrix
x <- matrix(
c(1500, 1300, 280, 356, 456, 678),
ncol = 3
)
rownames(x) <- c("taxon1", "taxon2")
colnames(x) <- c("sample1", "sample2", "sample3")
# Convert to tidytacos object
data <- create_tidytacos(x,
taxa_are_columns = FALSE
)
# Add pcoa
data <- data %>%
add_ord()
# The variances of the ordination dimensions can be accessed with
data$ord_variances
#> [1] 1.000000e+00 5.494303e-16 0.000000e+00
