# FinfoMDS: Multidimensional scaling informed by F-statistic

# Contents

# About this vignette

This vignette describes how to perform F-informed multidimensional scaling using the `FinfoMDS` package. `FinfoMDS` was developed by Soobin Kim (sbbkim@ucdavis.edu). A proposal of the method and its full description can be found at:

- H Kim⋆, S Kim⋆, JA Kimbrel, MM Morris, X Mayali and CR Buie (2025). Multidimensional scaling informed by F-statistic: Visualizing grouped microbiome data with inference, arXiv (https://arxiv.org/abs/2308.00354v2).

This vignette was updated in August 2025.

# 1 Introduction

Multidimensional scaling (MDS) is a dimensionality reduction technique used in microbial ecology data analysis to represent multivariate structures while preserving pairwise distances between samples. While its improvement has enhanced the ability to reveal data patterns by sample groups, these MDS-based methods often require prior assumptions for inference, limiting their broader application in general microbiome analysis.

Here, we introduce a new MDS-based ordination, F-informed MDS (implemented in the R package `FinfoMDS`), which configures data distribution based on the F-statistic, the ratio of dispersion between groups that share common and different labels. Our approach offers a well-founded refinement of MDS that aligns with statistical test results, which can be beneficial for broader compositional data analyses in microbiology and ecology.

# 2 Installation

## 2.1 Bioconductor official release

To install the official release version of this package, start R (version “4.5”) and enter:

    BiocManager::install("FinfoMDS")

For older R versions, please refer to the appropriate Bioconductor release.

## 2.2 GitHub development version

The package may be updated before changes are migrated to the official release. To install the development version, enter:

    devtools::install_github("soob-kim/FinfoMDS")

# 3 Operation

As introduced earlier, F-informed MDS is a microbiome data visualization tool designed to display statistical significance. The visualization (a 2D representation) output is obtained by iterating an optimization algorithm at each epoch. The procedure is summarized in the diagram below and is implemented in the `fmds()` function.

For `fmds()` function to operate, the following arguments are required: 1) labels `y`, 2) either a distance matrix `D` or a design matrix `X` (if both are provided, `D` takes precedence). Additionally, the following optional arguments can be adjusted according to user preference: 1) hyperparameter `lambda`, 2) initial representation `z0`, 3) maximum epoch number `nit`, and 4) stopping criterion `threshold_p`. Upon completion, `fmds()` returns a two-column matrix containing the coordinates representing the distance matrix `D`.

# 4 Example

As an example, we use an algal-associated bacterial community (Kim et al., 2022). First, load a `phyloseq`-class object by typing:

    library(FinfoMDS)
    data("microbiome", package = "FinfoMDS")

Next, compute the weighted UniFrac distance from this dataset and obtain its label set:

    require(phyloseq)
    #> Loading required package: phyloseq
    D <- distance(microbiome, method = 'wunifrac') # requires phyloseq package
    y <- sample_data(microbiome)$Treatment

Then, compute the F-informed MDS by running:

    result <- fmds(D = D, y = y, lambda = 0.3, threshold_p = 0.05)
    #> epoch 0   lambda 0.3   total 0.10   mds 0.02   conf 0.26   p_z 0.509   p_0 0.091
    #> epoch 1   lambda 0.3   total 0.13   mds 0.01   conf 0.39   p_z 0.396   p_0 0.091
    #> epoch 2   lambda 0.3   total 0.10   mds 0.01   conf 0.28   p_z 0.298   p_0 0.091
    #> epoch 3   lambda 0.3   total 0.06   mds 0.01   conf 0.15   p_z 0.161   p_0 0.091
    #> epoch 4   lambda 0.3   total 0.02   mds 0.01   conf 0.04   p_z 0.083   p_0 0.091
    #> Lambda 0.30 ...halt iteration

This procedure will iterate until the 2D distributions converge, as long as the p-value does not deviate more than `threshold_p`, or until reaching the default maximum of 100 iterations, whichever occurs first. We have observed that setting lambda between 0.3 and 0.5 typically yields optimal results; however, this hyperparameter can be adjusted as long as it does not exceed 1.

The 2D representation of the community dataset is returned as a matrix and can be visualized by typing:

    plot(result, pch = y)

# 5 Reference

H Kim, JA Kimbrel, CA Vaiana, JR Wollard, X Mayali, and CR Buie (2022). Bacterial response to spatial gradients of algal-derived nutrients in a porous microplate. The ISME Journal, 16(4):1036–1045.

# 6 Session information

    sessionInfo()
    #> R version 4.6.0 Patched (2026-04-24 r89963)
    #> Platform: aarch64-apple-darwin23
    #> Running under: macOS Tahoe 26.3.1
    #>
    #> Matrix products: default
    #> BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib
    #> LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] phyloseq_1.56.0  FinfoMDS_1.2.0   BiocStyle_2.40.0
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] SummarizedExperiment_1.42.0 gtable_0.3.6
    #>  [3] xfun_0.57                   bslib_0.10.0
    #>  [5] ggplot2_4.0.3               Biobase_2.72.0
    #>  [7] lattice_0.22-9              vctrs_0.7.3
    #>  [9] tools_4.6.0                 generics_0.1.4
    #> [11] biomformat_1.40.0           stats4_4.6.0
    #> [13] parallel_4.6.0              tibble_3.3.1
    #> [15] cluster_2.1.8.2             pkgconfig_2.0.3
    #> [17] Matrix_1.7-5                data.table_1.18.2.1
    #> [19] RColorBrewer_1.1-3          S7_0.2.2
    #> [21] S4Vectors_0.50.0            lifecycle_1.0.5
    #> [23] compiler_4.6.0              farver_2.1.2
    #> [25] stringr_1.6.0               Biostrings_2.80.0
    #> [27] tinytex_0.59                Seqinfo_1.2.0
    #> [29] codetools_0.2-20            permute_0.9-10
    #> [31] htmltools_0.5.9             sass_0.4.10
    #> [33] yaml_2.3.12                 pillar_1.11.1
    #> [35] crayon_1.5.3                jquerylib_0.1.4
    #> [37] MASS_7.3-65                 cachem_1.1.0
    #> [39] DelayedArray_0.38.0         vegan_2.7-3
    #> [41] magick_2.9.1                iterators_1.0.14
    #> [43] abind_1.4-8                 foreach_1.5.2
    #> [45] nlme_3.1-169                tidyselect_1.2.1
    #> [47] digest_0.6.39               stringi_1.8.7
    #> [49] dplyr_1.2.1                 reshape2_1.4.5
    #> [51] bookdown_0.46               splines_4.6.0
    #> [53] ade4_1.7-24                 fastmap_1.2.0
    #> [55] grid_4.6.0                  cli_3.6.6
    #> [57] SparseArray_1.12.0          magrittr_2.0.5
    #> [59] S4Arrays_1.12.0             survival_3.8-6
    #> [61] dichromat_2.0-0.1           ape_5.8-1
    #> [63] scales_1.4.0                rmarkdown_2.31
    #> [65] XVector_0.52.0              matrixStats_1.5.0
    #> [67] multtest_2.68.0             igraph_2.3.0
    #> [69] otel_0.2.0                  evaluate_1.0.5
    #> [71] knitr_1.51                  GenomicRanges_1.64.0
    #> [73] IRanges_2.46.0              mgcv_1.9-4
    #> [75] rlang_1.2.0                 Rcpp_1.1.1-1.1
    #> [77] glue_1.8.1                  BiocManager_1.30.27
    #> [79] BiocGenerics_0.58.0         jsonlite_2.0.0
    #> [81] R6_2.6.1                    plyr_1.8.9
    #> [83] MatrixGenerics_1.24.0