NJGPT: A Large Language Model-Driven, User-Friendly Solution for Phylogenetic Tree Construction

Zhixuan Wang, Haoyuan Huang, Teng Li, Allen G. RodrigobioRxiv 2024

Abstract

Phylogenetic reconstruction plays an integral part in much of the research in evolutionary biology. Currently, a newly minted phylogeneticist must choose amongst a relatively large array of phylogenetic software, each often with its own analytical routines, inputs and outputs. Our overarching aim is to construct a user-friendly pipeline with the most recent generative AI tool, ChatGPT-4 (at the time of writing) released by OpenAI, that is able to understand queries written in natural language, to build a phylogenetic tree using sequence data. By doing this, we demonstrate how generative AI may be used in phylogenetics, as a proof-of-concept. We also demonstrate the steps needed, presently, to ensure that ChatGPT can build phylogenetic trees accurately. Results We present NJGPT, a phylogenetic tool built using ChatGPT, a Large Language Model (LLM) Generative Pre-trained Transformer (GPT),which employs the Neighbor-Joining method to construct phylogenetic trees. NJGPT simplifies phylogenetic tree construction by allowing users to generate and visualize trees using natural language queries. It supports multiple sequence file formats, matrix calculation models, and gap-deletion methods. To evaluate the performance of NJGPT, we compared output and runtimes with the widely-used phylogenetic software, MEGA. Our results show that NJGPT produces identical trees over a range of sequence lengths and simple models of evolution. However, NJGPT faces visualization issues with datasets over 50 taxa and operational failures with larger datasets due to token limits. NJGPT runtimes were also substantially slower than MEGA; however, NJGPT’s user-friendly interface makes it ideal for beginners.

Introduction

Phylogenetic reconstruction—the process of inferring evolutionary relationships from genetic data—is a cornerstone of modern biology. However, the software ecosystem (e.g., MEGA, PAUP*, BEAST) is often intimidating for beginners. These tools require familiarity with specific file formats, technical terminology, and rigid analytical pipelines. The authors identify a "barrier to entry" where researchers spend more time learning the software than focusing on the biological questions. NJGPT aims to solve this by providing a conversational interface where a user can simply upload a file and "talk" their way through tree construction.

Methodology and Implementation

NJGPT is built on the ChatGPT-4 platform, specifically leveraging its "Custom GPT" and "Code Interpreter" features. The system architecture consists of two primary layers:

  1. The Backend: The authors developed 11 modular Python scripts that handle the heavy lifting: reading sequence files, calculating distance matrices, and executing the Neighbor-Joining (NJ) algorithm. The tool supports multiple sequence formats (FASTA, PHYLIP, MEGA, XML) and offers three evolutionary distance models: Hamming, Jukes-Cantor (JC), and Kimura two-parameter (K2P).
  2. The Interface: Instead of clicking through menus, users interact via natural language. The LLM acts as an orchestrator, interpreting user requests (e.g., "Use the Jukes-Cantor model with pairwise deletion") and triggering the appropriate Python code blocks in a secure sandbox environment.

The NJGPT Workflow

The user experience is designed to be intuitive, moving from data input to visualization through guided dialogue.

The NJGPT workflow (A) illustrates the transition from raw sequence data to final visualization, while the interface screenshots (B) show the conversational steps of data interpretation and model selection.

Validation and Performance

To validate NJGPT, the authors compared its performance against MEGA v11.0.13 using simulated alignments with varying sequence lengths (50 to 1,000 nucleotides) and taxa counts (10, 30, and 50).

  • Perfect Accuracy: In all simulated scenarios, the Robinson-Foulds (RF) distance and patristic distance between NJGPT and MEGA were zero. This means the trees produced were topologically identical.
  • Reliability Limits: The tool reliably handles datasets with up to 50 taxa and 10,000 bases.
  • Performance Trade-off: NJGPT is significantly slower than MEGA, with runtimes typically between 1 to 3 minutes. While MEGA is faster for power users, the authors argue the "user-friendly" overhead is a fair trade for beginners.

Discussion: LLMs as Orchestrators

A critical insight from this work is the role of the LLM as a "human-in-the-loop" orchestrator. Rather than asking the LLM to predict the tree structure directly—which would be prone to hallucinations—NJGPT uses the LLM to interface with deterministic Python code. This approach combines the accuracy of traditional algorithms with the accessibility of AI. Furthermore, the conversational nature of the tool allows it to act as a tutor, explaining the rationale behind model choices during the analysis process.

Limitations and Future Directions

Despite its successes, NJGPT faces several constraints:

  • The "Token Wall": Due to the context window of ChatGPT-4, the tool fails on very large datasets (e.g., 400+ taxa), resulting in execution environment errors.
  • Visualization: Graphical output becomes cluttered when datasets exceed 50 taxa, although the underlying Newick files remain accurate.
  • Pre-processing: Current versions require pre-aligned sequence files, as NJGPT cannot yet perform sequence alignment natively.

Conclusion

NJGPT demonstrates the potential of generative AI to democratize complex bioinformatics tasks. By abstracting technical complexity behind a natural language interface, it provides an accessible entry point for students and researchers new to the field of phylogenetics.

Summary updated

BibTeX
@misc{wang2024njgpt,
  author = {Zhixuan Wang and Haoyuan Huang and Teng Li and Allen G. Rodrigo},
  title = {{NJGPT: A Large Language Model-Driven, User-Friendly Solution for Phylogenetic Tree Construction}},
  year = {2024},
  doi = {10.1101/2024.12.02.626464},
  howpublished = {bioRxiv},
}
Figure