Skip to content
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
122 changes: 122 additions & 0 deletions workflows/machine-learning/dna-seq-classification-lstm/README.md
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.

Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "their labels" mean here ?

corresponding labels of DNA sequences.

Is this some kind of ML lingo that doesn't correspond to what a scientist would call "evaluate performance"

Yes, in the ML field, evaluate performance means testing the trained models for its generalization quality on unseen/test datasets.

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 ?

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.

Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that mean the model performance doesn't matter to the user ?

I mean if the data quality is low, performance will also be bad.

If not please mention in the readme what a good "performance" looks like and how that can be evaluated.

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.

If the user can't control the result then I'm not sure why we'd include the performance evaluation ?

User can control it by optimizing the model architecture - added a section "## Model optimisation" to the README.


### 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 ?

@anuprulez anuprulez May 28, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that what that blogpost describes

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).

This please edit the text so it says, "see here for how to produce a label file" ?

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this format ?

The (biological) labelled data for ML usually comes (publicly available for example) in tabular format, even genomic sequences -

seq_id,seq,label
0,CGTAT,0 (Neither)
1,TGATA,1 (Exon-Intron)
2,TTGTA,2 (Intro-Exon)

The sequence column are usually converted to k-mers (CGTAT -> CGT GTA TAT following 3-mers)
The above step requires DNA sequence in FASTA format

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.

Each line is a value per nucleotide

No, each label is for a sequence (CGTAT)

How does a user come across that file ?

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.

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 ?

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.

Add this also to the description of the label input in the workflow.

I think it is there in the workflow file. Do you mean somewhere else also?

"inputs": [
                {
                    "description": "",
                    "name": "Labels of DNA sequences"
                }
            ],


---

## 🔄 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.
How does one align labels with input sequences
Users don't have access to whether or not "GPU acceleration" is enabled and what does that even mean ? CUDA ? ROCm ? Metal ? What version ? Does it make sense to list that here at all ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

Updated it to "Ensure input datasets are in correct format: DNA sequences as FASTA and labels as tabular"

How does one align labels with input sequences

It comes alinged via published papers or public databases or huggingface datasets or Zenodo.

Users don't have access to whether or not "GPU acceleration" is enabled and what does that even mean ? CUDA ? ROCm ? Metal ? What version ? Does it make sense to list that here at all ?

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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"

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 ?

It comes alinged via published papers or public databases or huggingface datasets or Zenodo.

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 ?

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.

The text says GPU acceleration is enabled (if available), which contradictsw I do not enable it by default because a Galaxy server may not have a GPU. which one is it ? how does one enable it if it's not on by default with a CPU fallback? What's the expected speedup ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contigs or short read data or ... ?

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.

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 ?

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.

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 ?

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.

The text says GPU acceleration is enabled (if available), which contradictsw I do not enable it by default because a Galaxy server may not have a GPU. which one is it ?

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.

how does one enable it if it's not on by default with a CPU fallback?

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"."

What's the expected speedup ?

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already in the workflow and the dockstore file

@anuprulez anuprulez May 29, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outfile_predict.tabular isn't referenced, can you remove that file ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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"
Loading
Loading