plot_tsne_pq: Plot a tsne low dimensional representation of a phyloseq...

View source: R/plot_functions.R

plot_tsne_pqR Documentation

Plot a tsne low dimensional representation of a phyloseq object

Description

lifecycle-experimental

Partially inspired by phylosmith::tsne_phyloseq() function developed by Schuyler D. Smith.

Usage

plot_tsne_pq(
  physeq,
  method = "bray",
  dims = 2,
  theta = 0,
  perplexity = 30,
  fact = NA,
  ellipse_level = 0.95,
  plot_dims = c(1, 2),
  na_remove = TRUE,
  force_factor = TRUE,
  ...
)

Arguments

physeq

(required) a phyloseq-class object obtained using the phyloseq package.

method

A method to calculate distance using vegan::vegdist() function (default: "bray")

dims

(Int) Output dimensionality (default: 2)

theta

(Numeric) Speed/accuracy trade-off (increase for less accuracy), set to 0.0 for exact TSNE (default: 0.0 see details in the man page of Rtsne::Rtsne).

perplexity

(Numeric) Perplexity parameter (should not be bigger than 3 * perplexity < nrow(X) - 1, see details in the man page of Rtsne::Rtsne)

fact

Name of the column in physeq@sam_data used to color points and compute ellipses.

ellipse_level

The level used in stat_ellipse. Set to NULL to discard ellipse (default = 0.95)

plot_dims

A vector of 2 values defining the rank of dimension to plot (default: c(1,2))

na_remove

(logical, default TRUE) Does the samples with NA values in fact are removed? (default: true)

force_factor

(logical, default TRUE) Force the fact column to be a factor.

...

Additional arguments passed on to Rtsne::Rtsne()

Details

As explained in the documentation of tsne_pq(), t-SNE is a local technique: the plot is reliable for neighbourhood, outlier and cluster identification, but the distances between points or clusters, the cluster density and the class separability it suggests must not be read as faithful to the original space (Jeon et al., 2026). See tsne_pq() for details and for global alternatives (PCA, MDS/PCoA).

Value

A ggplot object

Author(s)

Adrien Taudière

References

Jeon, H., Park, J., Shin, S., & Seo, J. (2026). Stop Misusing t-SNE and UMAP for Visual Analytics. IEEE Transactions on Visualization and Computer Graphics. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2506.08725")}

van der Maaten, L., & Hinton, G. (2008). Visualizing Data using t-SNE. Journal of Machine Learning Research, 9, 2579-2605.

Examples


if (requireNamespace("Rtsne")) {
  plot_tsne_pq(data_fungi_mini, fact = "Height", perplexity = 15)
}


MiscMetabar documentation built on Nov. 16, 2026, 5:06 p.m.