Skip to contents

This article shows you how to quickly get started with interactive exploration of your data/ ordination plot.

library(phyloseq)
library(microViz)
#> microViz version 0.12.7 - Copyright (C) 2021-2025 David Barnett
#> ! Website: https://david-barnett.github.io/microViz
#>  Useful?  For citation details, run: `citation("microViz")`
#>  Silence? `suppressPackageStartupMessages(library(microViz))`

Example

Example data loaded from the corncob package. All you need is a valid phyloseq object, and to run tax_fix to ensure the tax_table doesn’t contain problematic names.

pseq <- microViz::ibd %>%
  tax_fix() %>%
  phyloseq_validate()

The gif animation below shows the result of running ord_explore, the animation starts immediately after interactively selecting “Genus” level aggregation, “clr” transformation, and the “PCA” ordination method from the “Edit” menu.

ord_explore(pseq)

Another (old) example

Get example dataset from the phyloseq package and clean up the taxa just a little.

data("enterotype", package = "phyloseq")
taxa_names(enterotype)[1] <- "Unclassified" # replace strange "-1" name
ps <- tax_fix(enterotype) # remove NA taxa and similar
#> Row named: Unclassified
#> contains no non-unknown values, returning:
#> 'Unclassified' for all replaced levels.
#> Consider editing this tax_table entry manually.
#> Row named: Bacteria
#> contains no non-unknown values, returning:
#> 'Bacteria' for all replaced levels.
#> Consider editing this tax_table entry manually.

Create simple Bray-Curtis PCoA to explore interactively.

ord1 <- ps %>%
  tax_transform("identity", rank = "Genus") %>%
  dist_calc("bray") %>% # bray curtis
  ord_calc() # automagically picks PCoA
#> Warning: otu_table of counts is NOT available!
#> Available otu_table contains 50166 values that are not non-negative integers

Start interactive Shiny app. Note that the gif animation shown is from an outdated version of microViz. More recent versions of ord_explore allow editing the ordination shown, and generating ord_plot code.

ord_explore(data = ord1, auto_caption = NA)
Note: GIF is sped up x2: redrawing plots is not instantaneous, but pretty quick unless your dataset has many 1000s of samples. Date of creation: 29/03/2021
Note: GIF is sped up x2: redrawing plots is not instantaneous, but pretty quick unless your dataset has many 1000s of samples. Date of creation: 29/03/2021

Session info

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.0 (2025-04-11)
#>  os       Ubuntu 24.04.2 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       UTC
#>  date     2025-04-14
#>  pandoc   3.1.11 @ /opt/hostedtoolcache/pandoc/3.1.11/x64/ (via rmarkdown)
#>  quarto   NA
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package          * version date (UTC) lib source
#>  ade4               1.7-23  2025-02-14 [1] RSPM
#>  ape                5.8-1   2024-12-16 [1] RSPM
#>  Biobase            2.67.0  2024-10-29 [1] Bioconduc~
#>  BiocGenerics       0.53.6  2025-01-27 [1] Bioconduc~
#>  biomformat         1.35.0  2024-10-29 [1] Bioconduc~
#>  Biostrings         2.75.4  2025-02-21 [1] Bioconduc~
#>  bslib              0.9.0   2025-01-30 [1] RSPM
#>  cachem             1.1.0   2024-05-16 [1] RSPM
#>  cli                3.6.4   2025-02-13 [1] RSPM
#>  cluster            2.1.8.1 2025-03-12 [3] CRAN (R 4.5.0)
#>  codetools          0.2-20  2024-03-31 [3] CRAN (R 4.5.0)
#>  colorspace         2.1-1   2024-07-26 [1] RSPM
#>  crayon             1.5.3   2024-06-20 [1] RSPM
#>  data.table         1.17.0  2025-02-22 [1] RSPM
#>  desc               1.4.3   2023-12-10 [1] RSPM
#>  devtools           2.4.5   2022-10-11 [1] RSPM
#>  digest             0.6.37  2024-08-19 [1] RSPM
#>  dplyr              1.1.4   2023-11-17 [1] RSPM
#>  ellipsis           0.3.2   2021-04-29 [1] RSPM
#>  evaluate           1.0.3   2025-01-10 [1] RSPM
#>  fastmap            1.2.0   2024-05-15 [1] RSPM
#>  foreach            1.5.2   2022-02-02 [1] RSPM
#>  fs                 1.6.5   2024-10-30 [1] RSPM
#>  generics           0.1.3   2022-07-05 [1] RSPM
#>  GenomeInfoDb       1.43.4  2025-01-24 [1] Bioconduc~
#>  GenomeInfoDbData   1.2.14  2025-04-14 [1] Bioconductor
#>  ggplot2            3.5.2   2025-04-09 [1] RSPM
#>  glue               1.8.0   2024-09-30 [1] RSPM
#>  gtable             0.3.6   2024-10-25 [1] RSPM
#>  htmltools          0.5.8.1 2024-04-04 [1] RSPM
#>  htmlwidgets        1.6.4   2023-12-06 [1] RSPM
#>  httpuv             1.6.15  2024-03-26 [1] RSPM
#>  httr               1.4.7   2023-08-15 [1] RSPM
#>  igraph             2.1.4   2025-01-23 [1] RSPM
#>  IRanges            2.41.3  2025-02-12 [1] Bioconduc~
#>  iterators          1.0.14  2022-02-05 [1] RSPM
#>  jquerylib          0.1.4   2021-04-26 [1] RSPM
#>  jsonlite           2.0.0   2025-03-27 [1] RSPM
#>  knitr              1.50    2025-03-16 [1] RSPM
#>  later              1.4.2   2025-04-08 [1] RSPM
#>  lattice            0.22-6  2024-03-20 [3] CRAN (R 4.5.0)
#>  lifecycle          1.0.4   2023-11-07 [1] RSPM
#>  magrittr           2.0.3   2022-03-30 [1] RSPM
#>  MASS               7.3-65  2025-02-28 [3] CRAN (R 4.5.0)
#>  Matrix             1.7-3   2025-03-11 [3] CRAN (R 4.5.0)
#>  memoise            2.0.1   2021-11-26 [1] RSPM
#>  mgcv               1.9-1   2023-12-21 [3] CRAN (R 4.5.0)
#>  microbiome         1.29.0  2025-01-23 [1] Bioconduc~
#>  microViz         * 0.12.7  2025-04-14 [1] local
#>  mime               0.13    2025-03-17 [1] RSPM
#>  miniUI             0.1.1.1 2018-05-18 [1] RSPM
#>  multtest           2.63.0  2024-10-29 [1] Bioconduc~
#>  munsell            0.5.1   2024-04-01 [1] RSPM
#>  nlme               3.1-168 2025-03-31 [3] CRAN (R 4.5.0)
#>  permute            0.9-7   2022-01-27 [1] RSPM
#>  phyloseq         * 1.51.0  2025-01-23 [1] Bioconduc~
#>  pillar             1.10.2  2025-04-05 [1] RSPM
#>  pkgbuild           1.4.7   2025-03-24 [1] RSPM
#>  pkgconfig          2.0.3   2019-09-22 [1] RSPM
#>  pkgdown            2.1.1   2024-09-17 [1] RSPM
#>  pkgload            1.4.0   2024-06-28 [1] RSPM
#>  plyr               1.8.9   2023-10-02 [1] RSPM
#>  profvis            0.4.0   2024-09-20 [1] RSPM
#>  promises           1.3.2   2024-11-28 [1] RSPM
#>  purrr              1.0.4   2025-02-05 [1] RSPM
#>  R6                 2.6.1   2025-02-15 [1] RSPM
#>  ragg               1.4.0   2025-04-10 [1] RSPM
#>  Rcpp               1.0.14  2025-01-12 [1] RSPM
#>  remotes            2.5.0   2024-03-17 [1] RSPM
#>  reshape2           1.4.4   2020-04-09 [1] RSPM
#>  rhdf5              2.51.2  2025-01-08 [1] Bioconduc~
#>  rhdf5filters       1.19.2  2025-03-05 [1] Bioconduc~
#>  Rhdf5lib           1.29.2  2025-03-24 [1] Bioconduc~
#>  rlang              1.1.5   2025-01-17 [1] RSPM
#>  rmarkdown          2.29    2024-11-04 [1] RSPM
#>  Rtsne              0.17    2023-12-07 [1] RSPM
#>  S4Vectors          0.45.4  2025-02-11 [1] Bioconduc~
#>  sass               0.4.9   2024-03-15 [1] RSPM
#>  scales             1.3.0   2023-11-28 [1] RSPM
#>  sessioninfo        1.2.3   2025-02-05 [1] RSPM
#>  shiny              1.10.0  2024-12-14 [1] RSPM
#>  stringi            1.8.7   2025-03-27 [1] RSPM
#>  stringr            1.5.1   2023-11-14 [1] RSPM
#>  survival           3.8-3   2024-12-17 [3] CRAN (R 4.5.0)
#>  systemfonts        1.2.2   2025-04-04 [1] RSPM
#>  textshaping        1.0.0   2025-01-20 [1] RSPM
#>  tibble             3.2.1   2023-03-20 [1] RSPM
#>  tidyr              1.3.1   2024-01-24 [1] RSPM
#>  tidyselect         1.2.1   2024-03-11 [1] RSPM
#>  UCSC.utils         1.3.1   2025-01-15 [1] Bioconduc~
#>  urlchecker         1.0.1   2021-11-30 [1] RSPM
#>  usethis            3.1.0   2024-11-26 [1] RSPM
#>  vctrs              0.6.5   2023-12-01 [1] RSPM
#>  vegan              2.6-10  2025-01-29 [1] RSPM
#>  withr              3.0.2   2024-10-28 [1] RSPM
#>  xfun               0.52    2025-04-02 [1] RSPM
#>  xtable             1.8-4   2019-04-21 [1] RSPM
#>  XVector            0.47.2  2025-01-08 [1] Bioconduc~
#>  yaml               2.3.10  2024-07-26 [1] RSPM
#> 
#>  [1] /home/runner/work/_temp/Library
#>  [2] /opt/R/4.5.0/lib/R/site-library
#>  [3] /opt/R/4.5.0/lib/R/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────