-
Notifications
You must be signed in to change notification settings - Fork 96
Add DNA sequence classification workflow using LSTM (RNN) neural network from Galaxy ML tool suite #1229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add DNA sequence classification workflow using LSTM (RNN) neural network from Galaxy ML tool suite #1229
Changes from 16 commits
5caf748
8382a7f
db0eafa
16a312b
3d6e4e2
9b07b99
ffd2ea3
74ec191
005a932
31d1a5d
91bda80
d2ba6ef
0feb527
2ccdf96
7f4fa2a
46a29f1
e6449b9
96dbca4
41f2d0f
d5e13ca
ece5be8
5bb4861
f0ad81c
2ad8ace
a3bc7cd
8afb626
deb2d52
5a7cecd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: 1.2 | ||
| workflows: | ||
| - name: main | ||
| subclass: Galaxy | ||
| publish: true | ||
| primaryDescriptorPath: /dna-seq-classification-lstm.ga | ||
| testParameterFiles: | ||
| - /dna-seq-classification-lstm-tests.yml | ||
| authors: | ||
| - name: Anup Kumar | ||
| orcid: 0000-0002-2068-4695 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Changelog | ||
|
|
||
| ## [0.1] - 2026-05-04 | ||
|
|
||
| - First version of DNA sequence classification workflow. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # 🧬 DNA Sequence Classification using LSTM neural network (Galaxy Workflow) | ||
|
|
||
| ## 📌 Overview | ||
| This workflow implements a deep learning pipeline for DNA sequence classification using an LSTM-based neural network. It takes raw DNA sequences in FASTA format and their labels in tabular format, processes them into numerical representations, trains a model, and evaluates its performance. | ||
|
|
||
| ### An example task achieved by the workflow | ||
|
|
||
| The workflow can be used to perform DNA sequence classification on splice-junction gene sequences. In an example task, the workflow takes raw DNA sequence data as input and classifies each sequence according to whether it contains an exon–intron boundary, an intron–exon boundary, or no splice junction using an LSTM-based deep learning model. These classes correspond to donor sites (EI), acceptor sites (IE), and neither (N). The biological goal of such a task is to identify where RNA splicing occurs. During splicing, non-coding introns are removed and coding exons are joined together before a gene is translated into a protein. Detecting these splice-junction boundaries from DNA sequences helps in understanding gene structure and function. More information about such a dataset can be found in this [blogpost](https://galaxyproject.org/news/2026-04-28-tabpfn-v2-5/#splice-junction-gene-sequences) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for including the link. I see from the screenshot that you need to certify that you're not a commercial user. If tabfpn does not have a permissive license we cannot merge this into the IWC.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The blogpost is only for the explanation of such a dataset which can also be used for the LSTM based workflow (this PR) for DNA sequence classification. This workflow, however, does not use TabPFN anywhere as a tool or any other commercial tools.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This please edit the text so it says, "see here for how to produce a label file" ? Is that what that blogpost describes ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, the blogpost describes a dataset that comes from a public repository. This blogpost describes another workflow using TabPFN as a DNA sequence classifier (instead of LSTM network in the PR).
I will add a similar piece of text. Added here: 96dbca4 |
||
|
|
||
| --- | ||
|
|
||
| ## ⚙️ Key Features | ||
| - End-to-end pipeline in Galaxy | ||
| - DNA sequence encoding using k-mer representation | ||
| - Deep learning model built with Keras | ||
| - LSTM-based architecture for sequence learning | ||
| - Automatic train/test split | ||
| - Model evaluation with metrics and confusion matrix | ||
| - Prediction of class labels and probabilities | ||
|
|
||
| --- | ||
|
|
||
| ## 📥 Inputs | ||
| The workflow requires two datasets: | ||
| - DNA sequences (FASTA format) | ||
| - Labels for sequences (tabular format) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this format ? Each line is a value per nucleotide ? How does a user come across that file ? What's the logic of of the train/test split ? What are we predicting and how can we predict something if we use the same input as training ? Add this also to the description of the label input in the workflow. This reads so much like an AI written readme (apologies if handcrafted), which isn't a problem per se, but you should ask yourself if this is sufficient information for someone to understand and use the workflow. I probably don't care about the model architecture, i want to know what and how it does its thing.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The (biological) labelled data for ML usually comes (publicly available for example) in tabular format, even genomic sequences - seq_id,seq,label The sequence column are usually converted to k-mers (CGTAT -> CGT GTA TAT following 3-mers) the labels stay in the tabular format. Later, each 3-mer becomes a token and is represented by an integer index (CGT is represented by 38, GTA 29 and TAT by 3). So, CGTAT -> CGT GTA TAT -> 38, 29, 3 then 38, 29, 3 become 3 features and is associated with its original label which is 0 38, 29, 3,0 (the last column is the labels columns) and the rest are features.
No, each label is for a sequence (CGTAT)
there is no standard format, only a few standard steps such as k-mer conversion and feature transformation. Labels could also be embedded into the FASTA file itself for example.
We take the entire dataset and then make it ready for doing ML - convert it into features and labels combination (CGTAT 0 -> CGT GTA TAT 0 -> 38, 29, 3, 0), the last entry is the label. then, this entire data is split (a standard practice) horizontally into train and test (75% rows into training and rest for test). Model gets trained on the train data and then evaluated on the test data. Users can bring a separate test data but that needs to be transformed using the same k-mer vocabulary (like LLMs need their own vocabulary/tokenizers). The test data should come from the same distribution. The workflow can predicts the splice junctions for example which the labels.
I think it is there in the workflow file. Do you mean somewhere else also? |
||
|
|
||
| --- | ||
|
|
||
| ## 🔄 Workflow Steps | ||
|
|
||
| ### 1. Data Encoding | ||
| - DNA sequences are converted into numerical format using: | ||
| - k-mer encoding (k=3) | ||
| - Output: encoded feature matrix | ||
|
|
||
| ### 2. Data Preparation | ||
| - Encoded sequences are merged with labels | ||
| - Dataset is split into: | ||
| - Training set (75%) | ||
| - Test set (25%) | ||
|
|
||
| ### 3. Feature & Label Separation | ||
| - Training and test datasets are split into: | ||
| - X (features): encoded sequences | ||
| - y (labels): class labels | ||
| - Labels are converted to categorical (one-hot encoding) | ||
|
|
||
| --- | ||
|
|
||
| ## 🧠 Model Architecture | ||
|
|
||
| The workflow builds a Sequential Keras model with: | ||
|
|
||
| - Embedding layer: | ||
| - Input dim: 130 | ||
| - Output dim: 128 | ||
|
|
||
| - LSTM layers: | ||
| - LSTM (256 units, return sequences) | ||
| - LSTM (256 units) | ||
|
|
||
| - Dense layers: | ||
| - Dense (64 units, ELU activation) | ||
| - Output Dense (3 units, Softmax) | ||
|
|
||
| --- | ||
|
|
||
| ## 🏋️ Model Training | ||
|
|
||
| - Optimizer: Adam | ||
| - Loss function: categorical crossentropy | ||
| - Metrics: categorical accuracy | ||
|
|
||
| Training parameters: | ||
| - Epochs: 10 | ||
| - Batch size: 32 | ||
| - Validation split: 10% | ||
|
|
||
| --- | ||
|
|
||
| ## 📊 Evaluation | ||
|
|
||
| - Metrics reported: | ||
| - Accuracy | ||
| - F1-score (macro) | ||
| - Recall (macro) | ||
|
|
||
| - Outputs: | ||
| - Predictions on test data | ||
| - Class probabilities | ||
| - Confusion matrix visualization | ||
|
|
||
| --- | ||
|
|
||
| ## 📤 Outputs | ||
|
|
||
| - Trained model | ||
| - Prediction results (labels) | ||
| - Prediction probabilities | ||
| - Evaluation metrics | ||
| - Confusion matrix plot | ||
|
|
||
| --- | ||
|
|
||
| ## 🚀 Usage Notes | ||
|
|
||
| - Ensure DNA sequences are properly formatted (FASTA) | ||
| - Labels must align with input sequences | ||
| - GPU acceleration is enabled (if available) | ||
| - Suitable for multi-class classification problems | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll have to provide some more detail here. Properly formatted is such a wide range of things. If you mean fixed length, maybe even of a very specific fixed length you have to say that.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Updated it to "Ensure input datasets are in correct format: DNA sequences as FASTA and labels as tabular"
It comes alinged via published papers or public databases or huggingface datasets or Zenodo.
It is important to mention it. I do not enable it by default because a Galaxy server may not have a GPU support. But, if users use it on a Galaxy server that has GPU support (Main or EU), enabling such a feature would be super useful if say there are 10,000 DNA sequences in the analysis.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contigs or short read data or ... ? Correctly formatted fasta doesn't really mean much. Does it have to be the ATGC alphabet, are mixed length sequences supported, etc ? You mention 10000 sequences, that is very few if we're dealing with short read data. Maybe include expectation about input data types ? I assume you can't pass short read data if 10000 sequences requires GPU support ?
I still don't know what that means and what i'm looking for if I want to classify e.g. transcription factor binding sites. How do I as a user know that a label is aligned with the input sequences. What do I look for on zenodo or hugginface ?
The text says GPU acceleration is enabled (if available), which contradictsw
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The DNA sequences users can bring can be any sequence - short, long, contigs etc.. The workflow's job is to map the supplied sequences to their respective labels by learning differentiating (between labels) context. If I bring 10000 sequences which are 1000 bp long, GPUs would be extremely helpful because each base pair is represented by a fixed sized vector and because of the length of the sequences, number of matrix multiplications would be enormous. It is hard to put a number when someone needs a GPU - again it depends on the dataset.
Users have to bring their own datasets to use this workflow and tune the parameters of the workflow to obtain best possible performance. They can always use the the test data we provide to play around.
Users know their research question and the kind of dataset they want to analyse. README mentions they can do classification or regression tasks. For example, in single-cell cell type annotation tasks, the cell type names comes with Anndata.
It is changed to "Enable GPU for faster performance - consider this option when dataset is large (tested on Nvidia GPUs)". I don' know kind of GPUs are there on the Main or AU servers. It is not enabled because "I do not enable it by default because a Galaxy server may not have a GPU". Also, CI/CD pipelines also may not have GPU for automatic testing.
Added to README: "To enable it, open the workflow and go to "Deep learning training and evaluation" tool. At the bottom of the tool definition, there is an option "Job Resource Parameters". Choose "Specify job resource parameters" and the in the "Use GPU resources", set it to "Yes"."
With GPU, it is 2 mins (model training) on the test data and without, 4 mins (2X speedup). But, this is a subjective thing and depends on what kind of GPU deployed on the server. If it is A100, the speedup could be much more. |
||
|
|
||
| --- | ||
|
|
||
| ## 📄 License | ||
| MIT License | ||
|
|
||
| --- | ||
|
|
||
| ## 👤 Author | ||
| **Anup Kumar** | ||
| ORCID: 0000-0002-2068-4695 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are already in the workflow and the dockstore file
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, removed it |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| - doc: Test outline for dna-seq-classification-lstm.ga | ||
| job: | ||
| Labels of DNA sequences: | ||
| class: File | ||
| path: "test-data/dna-sequence-labels.tabular" | ||
| filetype: "tabular" | ||
| DNA sequences: | ||
| class: File | ||
| path: "test-data/dna-sequence.fasta" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. outfile_predict.tabular isn't referenced, can you remove that file ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in 005a932 |
||
| filetype: "fasta" | ||
| outputs: | ||
| predicted_labels: | ||
| asserts: | ||
|
Comment on lines
+11
to
+13
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 31d1a5d |
||
| has_n_columns: | ||
| n: 1 | ||
| has_n_lines: | ||
| n: 799 | ||
| has_text: | ||
| text: "Predicted" | ||
| text: "0" | ||
| text: "1" | ||
| text: "2" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something isn't right here in how this is phrased. What does "their labels" mean here ? How can you "evaluate performance" when you don't have ground truth ? Is this some kind of ML lingo that doesn't correspond to what a scientist would call "evaluate performance" ? If i give this some random fasta file will the "performance" be worse than if this was a from a genome of the species the labels originate from ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corresponding labels of DNA sequences.
Yes, in the ML field, evaluate performance means testing the trained models for its generalization quality on unseen/test datasets.
If the FASTA file containing DNA sequences and its labels containing tabular file don't share any biological meaning, ML model will not do much and its prediction cannot be trusted. If random file is given that don't share biological meaning with labels, any performance will not make sense. Typically, it should give worse performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sooooo, does that mean the model performance doesn't matter to the user ? If not please mention in the readme what a good "performance" looks like and how that can be evaluated. If the user can't control the result then I'm not sure why we'd include the performance evaluation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if the data quality is low, performance will also be bad.
In the "Evaluation" section of the README, the metrics to look out for are listed. In general, model performance is not objective as it depends on several factors such as data quality, model architecture etc. A higher F1-score (closer to 1) usually indicate a high performance but it may not be achievable with all and every dataset - varies from dataset to dataset. I have added this information in the same "Evaluation" section.
User can control it by optimizing the model architecture - added a section "## Model optimisation" to the README.