Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/basic_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 7 additions & 10 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -37,7 +54,7 @@ Extract or copy the supplied files into one folder. This folder is called
```text
<PROJECT_DIR>/
├── config.tsv
├── SETUP.md
├── README.md
├── joint-rpca-mia-gemelli-comparison.qmd
└── scripts/
├── 00_check_gemelli_environment.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3506,7 +3506,7 @@ <h1>Purpose</h1>
<li>the same training/test split; and</li>
<li>the same number of components and iterations.</li>
</ul>
<p>The full installation and execution instructions are in <a href="SETUP.md"><code>SETUP.md</code></a>. 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 <code>MIA_GEMELLI_PROJECT</code> when defined, or the folder from which the report is rendered.</p>
<p>The full installation and execution instructions are in <a href="https://github.com/microbiome/OMAWorkflows/blob/devel/inst/doc/filterRPCAInput_validation/README.md"><code>README.md</code></a>. 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 <code>MIA_GEMELLI_PROJECT</code> when defined, or the folder from which the report is rendered.</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
)
}
Expand Down Expand Up @@ -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
Expand Down
179 changes: 179 additions & 0 deletions vignettes/filterRPCAInput-validation.qmd
Original file line number Diff line number Diff line change
@@ -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()
```