Abstract
Microbiome analysis often involves processing large sets of DNA sequences to characterize biological samples. Traditional embedding methods typically rely on simple averaging, which neglects the critical signal of sequence abundance. This paper introduces an Abundance-Aware Set Transformer that integrates quantitative sequence frequency data into an attention-based neural architecture. By leveraging DNABERT-2 for sequence embedding and a permutation-invariant Set Transformer for aggregation, the proposed model achieves superior performance across clinical and environmental classification tasks, including perfect accuracy in pathogen detection and enhanced generalization in cross-study domain shifts.
Introduction
Microbiome samples are complex "bags of sequences" containing thousands of DNA fragments from diverse microbial communities. To apply modern machine learning techniques, these variable-length sets must be transformed into fixed-size vector representations, or embeddings. A significant limitation of current approaches is the reliance on mean pooling, which treats all sequences as equally important. In biological systems, however, the relative abundance of specific microbes is often a primary indicator of health or environmental state. A rare but critical pathogen can easily be obscured by a simple average of common, non-informative sequences. This research addresses the challenge of creating sample-level representations that preserve the quantitative structure of the microbiome.
Methodology
The proposed pipeline integrates a DNA language model with a specialized Set Transformer architecture to produce abundance-aware embeddings.
Architecture Overview
The model consists of two primary stages: sequence-level embedding and set-level aggregation.
- Sequence Embedding: Individual DNA sequences are processed using DNABERT-2, a pretrained transformer model, to generate 768-dimensional vector representations.
- Set Aggregation: To handle the unordered nature of microbiome data, the authors utilize a Set Transformer. This architecture is permutation-invariant and employs Induced Set Attention Blocks (ISAB) to efficiently process large input sets.
Integrating Abundance
Two strategies for incorporating biological abundance were evaluated:
- Repetition-based Weighting: Embedding vectors are repeated in the input set proportionally to their observed abundance.
- Weighted Set Transformer: Unique sequences are processed once, and a soft weighting scheme is applied to the output vectors based on relative abundance. This method is computationally efficient and avoids the overhead of processing redundant vectors.
Experimental Setup
The model was evaluated on three real-world microbiome classification tasks sourced from the Qiita platform:
- Clinical (Study 14245): Classification of bladder tissue as tumor vs. non-tumor (116 samples).
- Environmental (Study 10442): Prediction of Acanthamoeba and Leptospira co-occurrence in freshwater (730 samples).
- Cross-Study Generalization (Studies 15573 & 1728): Training on marine surface samples and testing on urban asphalt/soil samples to identify "soil-associated" microbes under domain shift.
Results and Discussion
The Abundance-Aware Set Transformer consistently outperformed baseline methods, including mean pooling and vanilla Set Transformers.
Performance Metrics
On the Leptospira detection task, the model achieved perfect performance with an accuracy and F1 score of 1.0, significantly surpassing the 0.92–0.96 range of baseline methods. In the cross-study generalization task, the model reached an accuracy of 0.5882, compared to 0.4118 for all other methods, demonstrating its robustness to environmental domain shifts.
Latent Space Analysis
Visualizations using UMAP and t-SNE reveal that abundance-aware embeddings form tighter and more distinct clusters compared to traditional averaging. This suggests that the model learns a more biologically meaningful representation by preventing high-importance, low-abundance signals from being diluted by background noise.
Conclusion
This work demonstrates that sequence abundance is a first-class signal in microbiome analysis. By integrating abundance into an attention-based Set Transformer, the model captures the quantitative structure of microbial ecosystems more effectively than standard pooling methods. Future research will focus on reducing computational overhead for massive datasets and exploring the integration of abundance at higher taxonomic and functional levels.
Summary updated