Skip to content

Differential Abundance with ANCOM-BC

ANCOM-BC (Analysis of Compositions of Microbiomes with Bias Correction) identifies taxa that are significantly more or less abundant between groups, while accounting for compositionality and sampling fraction bias.

Filter Low-Frequency Samples and Features

Remove samples below the rarefaction threshold and then remove rare ASVs:

qiime feature-table filter-samples \
  --i-table table_nomitochloro.qza \
  --p-min-frequency 1500 \
  --o-filtered-table table_nomitochloro_1500.qza

qiime feature-table filter-features \
  --i-table table_nomitochloro_1500.qza \
  --p-min-frequency 50 \
  --p-min-samples 4 \
  --o-filtered-table table_nomitochloro_1500_abund.qza

Why Filter Features?

ANCOM-BC is sensitive to very rare taxa that appear in only a few samples, filtering to features with at least 50 total reads present in at least 4 samples improves statistical power and reduces spurious findings.

Collapse to Species Level

Aggregate ASVs to GreenGenes2 taxonomy level 7 (species):

qiime taxa collapse \
  --i-table table_nomitochloro_1500_abund.qza \
  --i-taxonomy taxonomy_gg2.qza \
  --p-level 7 \
  --o-collapsed-table table_nomitochloro_1500_abund_L7.qza

Get Metadata Without Environmental Controls

Environmental controls are excluded from ANCOM-BC:

cp /pl/active/courses/2025_summer/CSU_2025/q2_workshop_final/QIIME2/metadata_q2_workshop_noECs.txt .

ANCOM-BC

Sample Type

Test for differentially abundant taxa between sample types:

qiime composition ancombc \
  --i-table table_nomitochloro_1500_abund_L7.qza \
  --m-metadata-file metadata_q2_workshop_noECs.txt \
  --p-formula 'sample_type' \
  --o-differentials ancombc_sample_type.qza

Visualize the results:

qiime composition tabulate \
  --i-data ancombc_sample_type.qza \
  --o-visualization ancombc_sample_type.qzv

qiime composition da-barplot \
  --i-data ancombc_sample_type.qza \
  --p-significance-threshold 0.001 \
  --p-label-limit 5000 \
  --p-level-delimiter ";" \
  --o-visualization da_barplot_sample_type.qzv

ANCOM-BC

Facility

Test for differentially abundant taxa between facilities:

qiime composition ancombc \
  --i-table table_nomitochloro_1500_abund_L7.qza \
  --m-metadata-file metadata_q2_workshop_noECs.txt \
  --p-formula 'facility' \
  --o-differentials ancombc_facility.qza

Visualize the results:

qiime composition tabulate \
  --i-data ancombc_facility.qza \
  --o-visualization ancombc_facility.qzv

qiime composition da-barplot \
  --i-data ancombc_facility.qza \
  --p-significance-threshold 0.001 \
  --p-label-limit 5000 \
  --p-level-delimiter ";" \
  --o-visualization da_barplot_facility.qzv

Interpreting Results

When reviewing the DA barplots and tabulated results, work through this checklist:

ANCOM-BC Results Review

Outputs

File Type Description
table_nomitochloro_1500.qza Artifact Samples filtered to ≥1500 reads
table_nomitochloro_1500_abund.qza Artifact Features filtered by frequency and prevalence
table_nomitochloro_1500_abund_L7.qza Artifact Collapsed to species level
ancombc_sample_type.qza Artifact ANCOM-BC results (sample type)
ancombc_sample_type.qzv Visualization Tabulated differentials (sample type)
da_barplot_sample_type.qzv Visualization DA barplot (sample type)
ancombc_facility.qza Artifact ANCOM-BC results (facility)
ancombc_facility.qzv Visualization Tabulated differentials (facility)
da_barplot_facility.qzv Visualization DA barplot (facility)

Next: Machine Learning