Learning, visualizing and exploring 16S rRNA structure using an attention-based deep neural network

Zhengqiao Zhao, Stephen Woloszynek, Felix Agbavor, Joshua Chang Mell, Bahrad A. Sokhansanj, Gail L. RosenPLOS Computational Biology 2021 · DOI · OpenReview

Abstract

The 16S ribosomal RNA (rRNA) gene serves as a ubiquitous biological barcode for microbial identification. Conventional analysis pipelines typically group sequences into Operational Taxonomic Units (OTUs) or Amplicon Sequence Variants (ASVs), a process that can obscure fine-grained sequential information and structural nuances. We introduce Read2Pheno, a deep learning framework designed to classify microbial DNA sequences and predict host phenotypes directly from raw 16S rRNA reads. By combining Convolutional Neural Networks (CNNs), Bidirectional LSTMs, and attention mechanisms, Read2Pheno matches the performance of traditional alignment-based methods while automatically identifying biological "hotspots" within sequences.

Introduction

Microbiome research relies heavily on the 16S rRNA gene to identify bacteria. However, the standard practice of "binning" sequences into categories often discards the inherent context of the genetic code. While alignment-free methods like k-mer counting offer some improvements, they frequently fail to capture long-range dependencies. Read2Pheno addresses these challenges by providing an end-to-end model that handles raw sequences, maintains sequential context, and offers interpretability regarding its classification decisions.

Methods

Read2Pheno utilizes a hybrid architecture to process one-hot encoded DNA sequences. The model consists of several key components:

  1. Convolutional Neural Networks (CNN): These layers act as local feature extractors, identifying short patterns and learning optimal representations of genetic motifs.
  2. Bidirectional LSTM (Long Short-Term Memory): This recurrent layer captures the sequential order of features, enabling the model to understand relationships between distant parts of the gene.
  3. Attention Mechanism: This layer assigns weights to every position in the sequence, highlighting the nucleotides most informative for specific tasks, such as distinguishing body site origins.
  4. Aggregation: To handle samples containing thousands of reads, the model employs strategies like majority voting or "Pseudo OTU" clustering using intermediate layer embeddings.
Architecture of the Read2Pheno model, illustrating the integration of CNN, ResNet, Bi-LSTM, and attention layers for sequence processing.

Experimental Validation

The model was validated across three diverse datasets:

  • American Gut Project (AGP): Predicting sample origin across five body sites (e.g., feces, tongue, skin).
  • Gevers IBD Dataset: Discriminating between Crohn’s Disease patients and healthy controls.
  • SILVA 16S Database: Performing large-scale taxonomic classification across 495 genera.

Key Results

Read2Pheno demonstrated high performance across all tasks. On the SILVA dataset, it achieved a taxonomic classification accuracy of 95.9%, comparable to the industry-standard RDP classifier (97.6%). In phenotype prediction using AGP data, the model reached sample-level accuracies of approximately 88%, outperforming traditional OTU-based methods (83%). Notably, in a case study of the genus Prevotella, the model achieved 91.3% accuracy in identifying body site origin, specifically pinpointing discriminative regions in 100bp reads.

Discussion and Insights

A significant finding of this work is the emergence of biological relevance from model weights. The attention mechanism consistently highlighted known variable regions (V-regions) of the 16S gene (V2, V3, and V4) without prior biological supervision. Furthermore, the model's internal representations naturally clustered sequences by genus, suggesting that taxonomic structure is learned implicitly during phenotype prediction tasks.

Despite its success, Read2Pheno faces challenges common to deep learning in genomics, including high computational training costs and sensitivity to class imbalance for rare organisms. Future work will focus on scaling the architecture to handle full-length 16S sequences (approx. 1500bp) and further validating interpretability using synthetic ground-truth sequences.

Conclusion

Read2Pheno represents a shift toward end-to-end microbial sequence analysis. By bypassing manual pre-processing steps like sequence alignment or OTU picking, the framework reduces human bias and provides a robust, interpretable tool for exploring the relationship between microbial sequences and host phenotypes.

Summary updated

Abstract

Recurrent neural networks with memory 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 neural networks, recurrent neural networks, and attention mechanisms to predict taxonomic classifications and sample-associated attributes, such as the relationship between the microbiome and host phenotype, on the read/sequence level. In this paper, we develop this novel deep learning approach and evaluate its application to amplicon sequences. We apply our approach to short DNA reads and full sequences of 16S ribosomal RNA (rRNA) marker genes, which identify the heterogeneity of a microbial community sample. We demonstrate that our implementation of a novel attention-based deep network architecture, Read2Pheno, achieves read-level phenotypic prediction. Training Read2Pheno models will encode sequences (reads) into dense, meaningful representations: learned embedded vectors output from the intermediate layer of the network model, which can provide biological insight when visualized. The attention layer of Read2Pheno models can also automatically identify nucleotide regions in reads/sequences which are particularly informative for classification. As such, this novel approach can avoid pre/post-processing and manual interpretation required with conventional approaches to microbiome sequence classification. We further show, as proof-of-concept, that aggregating read-level information can robustly predict microbial community properties, host phenotype, and taxonomic classification, with performance at least comparable to conventional approaches. An implementation of the attention-based deep learning network is available at https://github.com/EESI/sequence_attention (a python package) and https://github.com/EESI/seq2att (a command line tool).
BibTeX
@article{zhao2021learning,
  author = {Zhengqiao Zhao and Stephen Woloszynek and Felix Agbavor and Joshua Chang Mell and Bahrad A. Sokhansanj and Gail L. Rosen},
  title = {{Learning, visualizing and exploring 16S rRNA structure using an attention-based deep neural network}},
  journal = {PLOS Computational Biology},
  year = {2021},
  doi = {10.1371/journal.pcbi.1009345},
}
Figure