B
BarCodeR documentationEmbedded documentation — works offline
/

Exploration — Methodological guide

1. Purpose and module structure#

Exploration visualizes, summarizes and compares the phyloseq objects loaded in the current project. It contains six tools:

Tool Main question
Barplot What is the taxonomic composition of samples or groups?
Alpha diversity How diverse is each sample internally?
Venn diagram / UpSet Which taxa or sequences are shared among sets?
Heat Tree How are abundances distributed across the taxonomic hierarchy?
Phylogenetic tree How are taxa arranged in the tree and what phylogenetic diversity do they represent?
Taxonomic assignment quality How deeply are taxa and reads assigned?

Some outputs are descriptive, while targeted taxon tests, alpha-diversity statistics, ANCOM-BC and Faith-PD comparisons are inferential. A large visual difference is not automatically a statistical result.

2. Common workflow#

Most tools separate scientific computation from visual rendering. Dataset selection, ranks, groups, indices, local filters and statistical methods require a new computation. Colors, dimensions, labels, orientation and layout generally reuse the last calculation.

After changing scientific settings, the old plot may remain visible. Check indicators such as Recalculation required, Analysis up to date, Regenerate figure and Save required.

Barplot, Heat Tree, Phylogenetic Tree and Taxonomic Quality usually follow the global active dataset, but a local choice does not redefine active_ds(). Alpha and Venn can use several datasets independently.

3. Local filtering#

Barplot, Alpha, Venn/UpSet, Heat Tree and Taxonomic Quality can use a temporary local filter. It is private to the current submodule:

registry dataset → local staged filtering → exploration result

It does not overwrite the registry, create a global dataset or propagate to another Exploration tool. Recompute after changing it. To preserve the filtered object, reproduce the criteria in Filtration, save it under a new name and save the project.

4. Barplot#

Barplot displays taxonomic composition by sample or metadata group, with raw or relative abundance.

The OTU table is required; taxonomy is needed for ranks and metadata for grouping. Taxonomic aggregation uses tax_glom(..., NArm = FALSE), which retains unassigned taxa. Users define which values are grouped as Unknown.

Without grouping, one bar represents one sample. With grouping, reads are pooled first and then converted to a composition. This is depth-weighted pooling, not the mean of individual sample proportions.

Top N is computed from displayed data; remaining taxa become Other. The abundance threshold is applied after Top N, and removed rows are not automatically added to Other. A 100%-stacked plot visually renormalizes remaining segments.

Available layouts include stacked, grouped, dodged, horizontal, total-taxon bars and lollipop views. Samples and taxa can be sorted and colors customized.

A selected taxon can be compared among groups. Depending on groups, sample size, normality and variances, the module can choose Student, Welch, Wilcoxon, ANOVA/Tukey, Welch ANOVA or Kruskal-Wallis with corrected pairwise tests. Covariates can be added. This is a targeted analysis, not a global compositional differential-abundance method.

5. Alpha diversity#

Available indices include Observed, Shannon, Simpson, InvSimpson, Chao1, ACE, Fisher and Pielou. Pielou is missing when Observed is at most one.

Non-integer data are not rounded. Observed, Shannon, Simpson, InvSimpson and Pielou can still be computed, but Chao1, ACE and Fisher are returned as missing because they require count-like data.

A grouping variable is offered only when present in every analyzed dataset. Cross-dataset comparisons require compatible markers, processing, abundance types and filtering.

Optional rarefaction uses rarefy_even_depth() with seed 2026. A target of zero uses each dataset's own positive minimum, not a shared global target. Rarefaction removes reads and may remove samples.

Depth diagnostics can include rarefaction curves and Good's coverage:

1 - singletons / total reads

They require integer counts.

The Statistics tab runs separately. One explanatory variable uses automatic Student/Welch/Wilcoxon/ANOVA/Kruskal logic. Several variables create adjusted models such as Y ~ V1 + V2 or Y ~ V1 * V2. Diagnostics may include residual tests, R², Breusch-Pagan and emmeans. Sparse interaction cells can be unstable.

6. Venn and UpSet#

The module compares presence/absence. An element is present after its first occurrence in the locally filtered data.

Inter-dataset mode uses datasets as sets; intra-dataset mode uses metadata levels. Elements can be taxonomic labels or exact RefSeq strings. Sequence mode does not align or cluster sequences by similarity.

Regex rules can remove ambiguous labels. Optional normalization harmonizes rank prefixes, spaces, underscores and case, which can also merge originally distinct labels. ASVs sharing a label are aggregated and prevalence is recalculated by sample.

Venn supports up to seven sets; larger comparisons switch automatically to UpSet. UpSet can filter and order intersections and annotate reads or prevalence.

An intersection indicates shared presence, not comparable abundance. Core and unique elements depend on filtering, detection, group size, depth, rank and label normalization.

7. Heat Tree#

Heat Tree maps values onto the taxonomic hierarchy. Modes are simple, descriptive differential and multi-comparison matrix.

Simple metrics include sum, mean, occurrence, contributing ASVs, median, variance, mean relative abundance, log abundance, dominance and relative frequency. Several metrics can use present samples only or all samples with zeros.

The fast differential mode displays a log2 ratio of medians between two groups. It is descriptive: no p-value, multiplicity correction or compositional adjustment.

ANCOM-BC provides inferential compositional analysis with covariates, prevalence and library thresholds, p-adjustment, alpha, structural zeros, convergence settings, pseudo-count, sensitivity and optional random effects. Test alpha requires recomputation; display q and logFC thresholds only filter the completed result.

ANCOM-BC is run independently for each selected rank and contrast. With k groups, pairwise matrices have k(k-1)/2 contrasts. Rank × contrast count can become very expensive, especially at ASV level. Cancellation may take effect only between runs.

8. Phylogenetic tree#

A phy_tree must already exist. The tool does not infer a tree from sequences. It uses rank aggregation, prevalence, total abundance, Top N and label-cleaning filters rather than the full local filtering modal.

Ambiguous labels may be rewritten as unclassified <last known ancestor> before aggregation. At least three taxa must remain.

Leaf metrics include sum, mean, relative abundance, median, variance, prevalence, log abundance and dominance. Diagnostics report tips, internal nodes, branch lengths, rooting, ultrametricity, binary status, total length and height.

Faith PD is computed with picante when available. It uses the aggregated community before display prevalence/abundance/Top-N filters, so those display settings do not change the Faith table. Rooted and unrooted values are not directly equivalent.

When some OTU taxa are missing from the tree, Faith PD can be based on partial coverage. BarCodeR reports missing taxa and read coverage. Comparisons use Wilcoxon for two groups and Kruskal-Wallis for three or more. Faith PD is sensitive to richness and depth.

Rendering engines include ggtree, phyloseq and ape; full interactivity is mainly available with ggtree.

9. Taxonomic assignment quality#

This tool computes assigned taxa and assigned reads at each rank, and a strict continuous assignment depth.

Taxon assignment percentage and read-weighted percentage can differ strongly: many unknown ASVs can represent few reads, or the opposite.

Unassigned patterns include NA, empty values, unknown/unclassified/uncultured labels, environmental or metagenome labels, empty rank prefixes and sp.. Invalid regex patterns are handled literally.

Strict depth stops at the first unassigned rank. A value at Order does not restore continuity if Class is missing.

Optional contaminant patterns are searched across all ranks. Excluding them affects only this calculation and changes the denominator; it does not edit the dataset. Default contaminant definitions must be adapted to the marker.

Results can be displayed by rank, cumulative depth or both, as percentages or absolute counts.

10. Descriptive versus inferential outputs#

Barplots, Venn/UpSet, simple Heat Trees, phylogenetic plots and assignment quality are mainly descriptive. Targeted barplot tests, Alpha statistics, ANCOM-BC and Faith comparisons are inferential. Descriptive effect size is not significance; significance is not causality or biological importance.

11. Histories and reproducibility#

Each tool has its own project history directory: barplot/, alpha_div/, venn_diag/, heat_tree/, phylo_tree/figures/ and tax_quality/.

Displayed results are not automatically saved. A snapshot can include PNG, RDS, metadata, parameters, calculated data, logs and XLSX tables. Deleting an entry removes its files without an internal trash.

Recent snapshots may provide reproducible R code. It can depend on the snapshot RDS, installed package versions and specialized dependencies, and should be reviewed before publication. Older snapshots may not provide code. Logs record data, filters, settings, tests, warnings and errors; some log text remains French.

12. Scientific comparability#

Before comparison, verify marker, region, technology, denoising/clustering, ASV/OTU definition, reference taxonomy, ranks, samples, abundance type, filtering, normalization and depth.

Rarefaction, Chao1, ACE, Fisher, Good's coverage, ANCOM-BC and read/prevalence summaries assume count-like data. CLR or log-transformed data change the meaning of presence and totals.

Taxonomic aggregation changes the analyzed unit. Group size affects pooled compositions and probability of observing rare taxa. Global tests need suitable multiplicity correction and compositional methods.

13. Performance and dependencies#

Cost increases with samples, taxa, datasets, indices, sets, intersections, ranks, contrasts and tree tips. ANCOM-BC rank sweeps and large interactive trees are especially expensive.

Dependencies can include phyloseq, vegan, metacoder, ANCOMBC, ggVennDiagram, ComplexUpset, ape, ggtree, picante, ggiraph, plotly, emmeans, lmtest and openxlsx. Missing packages may disable outputs or trigger fallbacks; inspect logs.

Reduce cost by filtering, aggregating to a rank, limiting groups/ranks/contrasts, using UpSet for many sets and disabling heavy interactivity.

14. Troubleshooting#

Symptom Main explanation
Plot does not match current settings Recompute scientific parameters
Local filter is absent in another tool Local states are independent
Grouped bar is not an average Reads were pooled
Chao1/ACE/Fisher are missing Data are non-integer
Samples disappear after rarefaction Depth below target
Venn becomes UpSet More than seven sets
ANCOM-BC is very slow Too many ranks, contrasts or ASVs
q threshold changes nodes without recomputation It is a display filter
Faith does not change with Top N Faith is computed before display filters
Assignment rate rises after contaminant exclusion Denominator changed
History is empty Wrong project or result not saved
Reproducible code fails Missing RDS, package or version mismatch

15. Checklists#

Before exploring: verify project, datasets, count/transformation status, tables, ranks, metadata types, groups and active local filters.

Before statistics: verify replication, missing data, depth, assumptions, covariates, interactions, multiple-testing correction and effect size.

Before ANCOM-BC: use suitable counts, define group/reference, start at higher ranks, limit contrasts and distinguish computational alpha from display q.

Before saving: ensure computation and rendering are current, verify title/colors/dimensions, read logs, save the history and export required tables.

16. Main limitations#

Independent local states, potentially stale plots, pooled group barplots, non-integer richness limitations, per-dataset zero-target rarefaction, exact-presence Venn logic, label normalization merges, descriptive median Heat Tree, expensive ANCOM-BC sweeps, Faith based on pre-display filtering and possibly partial trees, regex-dependent taxonomic quality, and project-dependent snapshots.

17. Recommended workflow#

  1. Inspect datasets in Description.
  2. Determine whether values are raw counts.
  3. Check groups and replicates.
  4. Use local filtering only for exploratory trials.
  5. Start with a simple descriptive plot.
  6. Choose an appropriate rank and limit displayed elements.
  7. Recompute after scientific changes.
  8. Run statistics only after validating the design.
  9. Read diagnostics and logs.
  10. Save figures, parameters and tables.
  11. Review reproducible R code.
  12. Reproduce persistent filters in Filtration and save the project.

18. Verified internal sources#

The guide is grounded in modules/exploration/mod_exploration_main_*, _shared/_dirty_tracking.R, _active_dataset_sync.R, and all files under barplot/, alpha/, venn/, heattree/, phylotree/ and tax_quality/, checked against architecture notes 30–35.