Abstract
Recurrent neural networks (RNNs) with memory (e.g. LSTMs) and attention mechanisms are widely used in natural language processing because they can capture short and long term sequential information for diverse tasks. We propose an integrated deep learning model for microbial DNA sequence data, which exploits convolutional networks, recurrent neural networks, and attention mechanisms to perform sample-associated attribute prediction—phenotype prediction—and extract interesting features, such as informative taxa and predictive k-mer context. In this paper, we develop this novel deep learning approach and evaluate its application to amplicon sequences. We focus on typically short DNA reads of 16s ribosomal RNA (rRNA) marker genes, which identify the heterogeneity of a microbial community sample. Our deep learning approach enables sample-level attribute and taxonomic prediction, with the aim of aiding biological research and supporting medical diagnosis. We demonstrate that our implementation of a novel attention-based deep network architecture, Read2Pheno, achieves read-level phenotypic prediction and, in turn, that aggregating read-level information can robustly predict microbial community properties, host phenotype, and taxonomic classification, with performance comparable to conventional approaches. Most importantly, as a further result of the training process, the network architecture will encode sequences (reads) into dense, meaningful representations: learned embedded vectors output on the intermediate layer of the network model, which can provide biological insight when visualized. Finally, we demonstrate that a model with an attention layer can automatically identify informative regions in sequences/reads which are particularly informative for classification tasks.
Introduction
The standard approach to analyzing the microbiome—the complex communities of microbes inhabiting various environments—typically involves sequencing the 16S rRNA gene, a universal taxonomic "barcode." Traditional bioinformatics pipelines group these sequences into Operational Taxonomic Units (OTUs) or Amplicon Sequence Variants (ASVs) to build abundance tables for phenotype prediction (e.g., disease state). However, this process often discards subtle nucleotide variations and ignores the sequential "sentence structure" of DNA.
To address these limitations, we developed Read2Pheno, a deep learning architecture that treats DNA sequences as a language. By applying natural language processing (NLP) techniques directly to raw 16S rRNA reads, the model can predict host phenotypes while simultaneously identifying the specific genetic motifs that drive its decisions.
Methodology
Read2Pheno is a hybrid neural network designed to capture both local patterns and global context within DNA reads. The architecture integrates several specialized layers:
- Convolutional Blocks (CNN): These act as motif detectors, scanning the sequence for short, local patterns (such as 9-mers).
- ResNet Blocks: These facilitate deeper feature extraction while maintaining stable gradient flow during training.
- Bidirectional LSTM (Bi-LSTM): This recurrent layer captures long-range dependencies, allowing the model to understand how a pattern at the beginning of a read relates to one at the end.
- Attention Mechanism: This component assigns a weight to every position in the DNA read, highlighting the most informative regions for the final classification task.
The model processes one-hot encoded inputs to produce "Read embeddings"—dense mathematical representations of the sequences. For sample-level analysis, where a single sample contains thousands of reads, the model employs aggregation strategies such as majority voting or clustering embeddings into "Pseudo OTUs."
Experimental Evaluation
The model was rigorously tested across three distinct datasets:
- American Gut Project (AGP): Used to predict the body site origin (e.g., feces, tongue, skin) of a sample.
- Gevers Dataset: A clinical dataset used to distinguish between patients with Inflammatory Bowel Disease (IBD) and healthy controls.
- SILVA Database: A high-quality database of full-length 16S rRNA sequences used to evaluate the model’s taxonomic classification accuracy at the genus level.
Results and Discussion
Read2Pheno achieved performance comparable to state-of-the-art Random Forest classifiers trained on traditional OTU tables. On the AGP dataset, it reached 78-88% accuracy depending on the aggregation method. For taxonomic classification on the SILVA dataset, the model achieved 95.9% accuracy at the genus level, nearly matching industry-standard tools like the RDP Classifier.
One of the most significant findings was the interpretability provided by the attention mechanism. Without prior biological supervision, the model consistently highlighted the V2, V3, and V4 hypervariable regions of the 16S gene—the exact regions biologists have identified over decades as the most informative for distinguishing bacterial species. Furthermore, the learned embeddings naturally clustered by taxonomy, even when the model was trained only on phenotypic labels. For example, in a case study of Prevotella reads, the model correctly identified the source body site with 91.3% accuracy by pinpointing specific nucleotide mutations that differentiate oral strains from fecal strains.
Conclusion
Read2Pheno demonstrates that deep learning can effectively bypass lossy intermediate steps in microbiome analysis, providing both high predictive accuracy and biological interpretability. The attention mechanism effectively "aligns" important features internally, making the model robust to unaligned, raw reads. Future work will focus on adapting this architecture for metagenomic data, which involves much longer sequences and requires even more advanced models, such as Transformers, to capture dependencies across millions of base pairs.
Summary updated