diff --git a/.github/workflows/basic_checks.yaml b/.github/workflows/basic_checks.yaml index 40e90cb..b6eb96c 100644 --- a/.github/workflows/basic_checks.yaml +++ b/.github/workflows/basic_checks.yaml @@ -19,6 +19,18 @@ jobs: - name: Checkout Repository uses: actions/checkout@v6 + - name: Preserve Joint-RPCA validation report + run: | + cp \ + inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html \ + "$RUNNER_TEMP/joint-rpca-mia-gemelli-comparison.html" + + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + with: + version: "1.10.18" + - name: Query dependencies and update old packages run: | options(repos = c(CRAN = Sys.getenv("CRAN"))) @@ -55,9 +67,8 @@ jobs: run: | mkdir -p docs/filterRPCAInput_validation cp \ - vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html \ + "$RUNNER_TEMP/joint-rpca-mia-gemelli-comparison.html" \ docs/filterRPCAInput_validation/index.html - - name: Upload pkgdown artifact if: github.event_name == 'push' uses: actions/upload-artifact@v4 @@ -67,7 +78,7 @@ jobs: deploy: needs: r-build-and-check - if: github.event_name == 'push' && success() + if: github.event_name == 'push' && github.ref == 'refs/heads/devel' && success() runs-on: ubuntu-latest permissions: contents: write diff --git a/DESCRIPTION b/DESCRIPTION index f31ba07..610319e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,8 +23,11 @@ Suggests: mia, miaViz, rmarkdown, - pkgdown + pkgdown, + quarto, + SummarizedExperiment URL: https://microbiome.github.io/OMAWorkflows/ BugReports: https://github.com/microbiome/OMAWorkflows/issues/new/choose -VignetteBuilder: knitr +VignetteBuilder: knitr, quarto +SystemRequirements: Quarto command line tool DockerImage: ghcr.io/microbiome/OMAWorkflows:latest diff --git a/_pkgdown.yml b/_pkgdown.yml index 6023d8a..b8e387c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,18 +1,15 @@ -url: https://seandavi.github.io/BuildABiocWorkshop +url: https://microbiome.github.io/OMAWorkflows/ template: - params: - bootswatch: flatly - #ganalytics: UA-99999999-9 + bootstrap: 5 + bootswatch: flatly home: - title: "BuildABiocWorkshop" + title: "OMAWorkflows" type: inverse - navbar: right: - - icon: fa-github - href: https://github.com/seandavi/BuildABiocWorkshop - - + - icon: fa-github + aria-label: GitHub + href: https://github.com/microbiome/OMAWorkflows diff --git a/vignettes/filterRPCAInput_validation/SETUP.md b/inst/doc/filterRPCAInput_validation/README.md similarity index 90% rename from vignettes/filterRPCAInput_validation/SETUP.md rename to inst/doc/filterRPCAInput_validation/README.md index d8f252d..fa5f3ad 100644 --- a/vignettes/filterRPCAInput_validation/SETUP.md +++ b/inst/doc/filterRPCAInput_validation/README.md @@ -3,6 +3,23 @@ This guide runs the numbered scripts and then renders one complete HTML report. You only need to enter the locations on your computer once in each environment. +The rendered report is published at +[the OMAWorkflows website](https://microbiome.github.io/OMAWorkflows/filterRPCAInput_validation/). + +## Repository locations + +The reproducibility files are stored in standard package locations: + +- report source, rendered report, and this guide: + `inst/doc/filterRPCAInput_validation/`; +- run configuration: `inst/extdata/filterRPCAInput_validation/config.tsv`; +- executable scripts: `inst/scripts/filterRPCAInput_validation/`. + +For an independent run, copy the report source and configuration into one +working directory, create a `scripts/` subdirectory, and copy the four +numbered scripts into it. The resulting working directory is the +`PROJECT_DIR` shown below. + ## Reproducibility specification | Item | Fixed value | @@ -37,7 +54,7 @@ Extract or copy the supplied files into one folder. This folder is called ```text / ├── config.tsv -├── SETUP.md +├── README.md ├── joint-rpca-mia-gemelli-comparison.qmd └── scripts/ ├── 00_check_gemelli_environment.py diff --git a/vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html b/inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html similarity index 99% rename from vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html rename to inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html index f665f57..4abd81f 100644 --- a/vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html +++ b/inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.html @@ -3506,7 +3506,7 @@

Purpose

  • the same training/test split; and
  • the same number of components and iterations.
  • -

    The full installation and execution instructions are in SETUP.md. The computational details remain in the numbered scripts; this report contains only the small amount of code needed to display their validated outputs. No machine-specific path is fixed in this report: it uses MIA_GEMELLI_PROJECT when defined, or the folder from which the report is rendered.

    +

    The full installation and execution instructions are in README.md. The computational details remain in the numbered scripts; this report contains only the small amount of code needed to display their validated outputs. No machine-specific path is fixed in this report: it uses MIA_GEMELLI_PROJECT when defined, or the folder from which the report is rendered.

    diff --git a/vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.qmd b/inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.qmd similarity index 96% rename from vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.qmd rename to inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.qmd index a3a1938..40e5adc 100644 --- a/vignettes/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.qmd +++ b/inst/doc/filterRPCAInput_validation/joint-rpca-mia-gemelli-comparison.qmd @@ -30,7 +30,7 @@ project_root <- normalizePath(project_root, winslash = "/", mustWork = TRUE) config_path <- file.path(project_root, "config.tsv") if (!file.exists(config_path)) { stop( - "config.tsv was not found. Follow SETUP.md and render from the ", + "config.tsv was not found. Follow README.md and render from the ", "project root.", call. = FALSE ) @@ -55,7 +55,7 @@ read_result <- function(directory, filename) { if (!file.exists(path)) { stop( "Missing required result: ", path, - "\nRun the workflow in SETUP.md before rendering.", + "\nRun the workflow in README.md before rendering.", call. = FALSE ) } @@ -105,7 +105,7 @@ numerical structure when both implementations receive: - the same number of components and iterations. The full installation and execution instructions are in -[`SETUP.md`](SETUP.md). The computational details remain in the numbered +[README.md](https://github.com/microbiome/OMAWorkflows/blob/devel/inst/doc/filterRPCAInput_validation/README.md). The computational details remain in the numbered scripts; this report contains only the small amount of code needed to display their validated outputs. No machine-specific path is fixed in this report: it uses `MIA_GEMELLI_PROJECT` when defined, or the folder from which the report is diff --git a/vignettes/filterRPCAInput_validation/config.tsv b/inst/extdata/filterRPCAInput_validation/config.tsv similarity index 100% rename from vignettes/filterRPCAInput_validation/config.tsv rename to inst/extdata/filterRPCAInput_validation/config.tsv diff --git a/vignettes/filterRPCAInput_validation/scripts/00_check_gemelli_environment.py b/inst/scripts/filterRPCAInput_validation/00_check_gemelli_environment.py similarity index 100% rename from vignettes/filterRPCAInput_validation/scripts/00_check_gemelli_environment.py rename to inst/scripts/filterRPCAInput_validation/00_check_gemelli_environment.py diff --git a/vignettes/filterRPCAInput_validation/scripts/01_run_mia_filter_joint_rpca.R b/inst/scripts/filterRPCAInput_validation/01_run_mia_filter_joint_rpca.R similarity index 100% rename from vignettes/filterRPCAInput_validation/scripts/01_run_mia_filter_joint_rpca.R rename to inst/scripts/filterRPCAInput_validation/01_run_mia_filter_joint_rpca.R diff --git a/vignettes/filterRPCAInput_validation/scripts/02_run_gemelli_filter_joint_rpca.py b/inst/scripts/filterRPCAInput_validation/02_run_gemelli_filter_joint_rpca.py similarity index 100% rename from vignettes/filterRPCAInput_validation/scripts/02_run_gemelli_filter_joint_rpca.py rename to inst/scripts/filterRPCAInput_validation/02_run_gemelli_filter_joint_rpca.py diff --git a/vignettes/filterRPCAInput_validation/scripts/03_compare_mia_gemelli_corrected.R b/inst/scripts/filterRPCAInput_validation/03_compare_mia_gemelli_corrected.R similarity index 100% rename from vignettes/filterRPCAInput_validation/scripts/03_compare_mia_gemelli_corrected.R rename to inst/scripts/filterRPCAInput_validation/03_compare_mia_gemelli_corrected.R diff --git a/vignettes/filterRPCAInput-validation.qmd b/vignettes/filterRPCAInput-validation.qmd new file mode 100644 index 0000000..fe7033e --- /dev/null +++ b/vignettes/filterRPCAInput-validation.qmd @@ -0,0 +1,179 @@ +--- +title: "Filtering input for Joint-RPCA" +subtitle: "A reproducible workflow using mia" +author: "Sabuj Chandra Bhowmick" +date: "2026-08-03" +format: + html: + toc: true + toc-depth: 3 +engine: knitr +execute: + echo: true + warning: false + message: false +vignette: > + %\VignetteEngine{quarto::html} + %\VignetteIndexEntry{Filtering input for Joint-RPCA} + %\VignetteEncoding{UTF-8} +--- + +# Introduction + +Robust principal component analysis (RPCA) methods require appropriate +filtering of the raw count table before robust centered log-ratio +transformation. Low-depth samples and low-abundance or low-prevalence features +can otherwise contribute little information and increase computational cost. + +The `mia::filterRPCAInput()` function provides Gemelli-style filters for +`SummarizedExperiment` objects. Samples are retained when their total count +is strictly greater than `min.sample.count`. Features are retained when both +their total count and prevalence are strictly greater than the corresponding +thresholds. + +This vignette demonstrates the filtering step with executable R code. The +complete cross-language comparison of mia and Gemelli is maintained as a +separate validation report. See the +[OMAWorkflows package website](https://microbiome.github.io/OMAWorkflows/) +for additional workflows. + +# Installation + +Install OMAWorkflows and mia from Bioconductor: + +```{r} +#| eval: false + +if (!requireNamespace("BiocManager", quietly = TRUE)) { + install.packages("BiocManager") +} +BiocManager::install(c("OMAWorkflows", "mia")) +``` + +Load the packages used in the example: + +```{r} +library(mia) +library(SummarizedExperiment) +``` + +# Example data + +The `GlobalPatterns` dataset contains a raw count assay and is small enough +for a package vignette. + +```{r} +data(GlobalPatterns, package = "mia") +tse <- GlobalPatterns +count_matrix <- assay(tse, "counts") + +data.frame( + features = nrow(tse), + samples = ncol(tse), + total_reads = sum(count_matrix) +) +``` + +# Filter the RPCA input + +This example retains samples with more than 10,000 reads and features with +more than 100 total reads and prevalence greater than 10%. + +```{r} +min_sample_count <- 10000 +min_feature_count <- 100 +min_feature_frequency <- 0.10 + +filtered_tse <- filterRPCAInput( + tse, + assay.type = "counts", + min.sample.count = min_sample_count, + min.feature.count = min_feature_count, + min.feature.frequency = min_feature_frequency +) + +data.frame( + object = c("Before filtering", "After filtering"), + features = c(nrow(tse), nrow(filtered_tse)), + samples = c(ncol(tse), ncol(filtered_tse)) +) +``` + +# Verify the filtering rules + +The following calculation independently reconstructs the expected identifiers. +The checks also demonstrate that all three thresholds use strict +greater-than comparisons. + +```{r} +expected_samples <- colSums(count_matrix) > min_sample_count +expected_features <- rowSums(count_matrix) > min_feature_count +expected_features <- expected_features & + rowMeans(count_matrix > 0) > min_feature_frequency + +stopifnot( + identical( + colnames(filtered_tse), + colnames(tse)[expected_samples] + ), + identical( + rownames(filtered_tse), + rownames(tse)[expected_features] + ) +) + +data.frame( + criterion = c( + "Sample total count", + "Feature total count", + "Feature prevalence" + ), + threshold = c( + min_sample_count, + min_feature_count, + min_feature_frequency + ), + comparison = rep("strictly greater than", 3L) +) +``` + +Individual filters can be disabled with `NULL`. This is useful when a +threshold has already been applied upstream. + +```{r} +unfiltered_tse <- filterRPCAInput( + tse, + assay.type = "counts", + min.sample.count = NULL, + min.feature.count = NULL, + min.feature.frequency = NULL +) + +stopifnot(identical(dim(unfiltered_tse), dim(tse))) +``` + +# Complete mia-Gemelli validation + +The complete cross-language validation includes filtering and rCLR agreement, +component alignment, sample and feature loadings, explained variation, sample +distances, and cross-validation trajectories. + +View the +[rendered Joint-RPCA validation report](https://microbiome.github.io/OMAWorkflows/filterRPCAInput_validation/) +or inspect its reproducibility files under +`inst/doc/filterRPCAInput_validation/`, +`inst/extdata/filterRPCAInput_validation/`, and +`inst/scripts/filterRPCAInput_validation/`. + +# References + +Martino, C., Shenhav, L., Marotz, C. A., et al. (2020). +Context-aware dimensionality reduction deconvolutes gut microbial community +dynamics. *Nature Biotechnology*, 39, 165-168. +[doi:10.1038/s41587-020-0660-7](https://doi.org/10.1038/s41587-020-0660-7). + +# Session information + +```{r} +sessionInfo() +``` \ No newline at end of file