Exercise:AllergenicityPrediction: Difference between revisions

From 22145
Jump to navigation Jump to search
 
(34 intermediate revisions by the same user not shown)
Line 8: Line 8:


Food allergens are generally proteins that are recognized by the immune system and can trigger an inappropriate immune response in susceptible individuals. Experimental characterization of every protein in a new food source is expensive and time-consuming. Bioinformatics can therefore play an important role in identifying proteins with potential allergenic properties and prioritizing candidates for experimental investigation.
Food allergens are generally proteins that are recognized by the immune system and can trigger an inappropriate immune response in susceptible individuals. Experimental characterization of every protein in a new food source is expensive and time-consuming. Bioinformatics can therefore play an important role in identifying proteins with potential allergenic properties and prioritizing candidates for experimental investigation.
In this exercise, we will investigate the potential allergenicity of proteins from brown algae (Phaeophyceae, taxid: 2870), with particular attention to Ectocarpus siliculosus.
We will first explore how known allergens and sequence similarity can be used to assess potential allergenicity. We will then build our own machine-learning classifier for allergen prediction using a Random Forest. Finally, you will try to improve the predictor using alternative features, preprocessing strategies, machine-learning algorithms, or other approaches of your choice.


== Learning Objectives ==
== Learning Objectives ==
Line 18: Line 13:
After completing this exercise, you should be able to:
After completing this exercise, you should be able to:


* Identify appropriate databases and experimental evidence for investigating protein allergenicity
* Use biological databases and sequence similarity to investigate potential protein allergens


* Explain how sequence similarity to known allergens can provide evidence of potential cross-reactivity or sensitisation
* Explain how sequence similarity can provide evidence for potential allergenicity and cross-reactivity, and recognize its limitations


* Use sequence-search tools such as BLAST to investigate relationships between allergens
* Build and evaluate a simple machine-learning model for allergenicity prediction


* Explain how existing bioinformatics predictions can be used as proxies when a dedicated predictor is unavailable
* Identify limitations of a prediction model and explore strategies to improve its performance


* Describe the major steps required to construct a supervised machine-learning predictor from biological sequence data
== The research question ==


* Explain why sequence clustering is important when separating biological data into training and test sets
Researchers at DTU Food are interested in developing a high-protein food product based on brown algae. Before introducing a new protein source into the human diet, however, we need to consider its potential allergenicity.


* Train and evaluate a Random Forest classifier for protein allergenicity.
Your task is therefore to investigate:


* Interpret commonly used measures of predictive performance.
''' Could proteins from brown algae represent an allergenic risk, and how could we predict this risk computationally?'''


* Identify potential limitations of a machine-learning model and propose strategies for improving its performance.
We will focus particularly on ''Ectocarpus siliculosus'', a species belonging to the brown algae (Phaeophyceae, taxid: 2870).
 
* Design and evaluate an improved allergenicity-prediction strategy.


We will first explore how known allergens and sequence similarity can be used to assess potential allergenicity. We will then build our own machine-learning classifier for allergen prediction using a Random Forest. Finally, you will try to improve the predictor using alternative features, preprocessing strategies, machine-learning algorithms, or other approaches of your choice.


== PART A: Investigating Allergenicity ==
== PART A: Investigating Allergenicity ==


Imagine that researchers at DTU Food are developing a new high-protein food product based on brown algae.
'''Where Would You Start?'''


Before such a product could be considered safe for consumers, one important question would be whether proteins from the algae could potentially act as allergens or cross-react with allergens to which people are already exposed.
Every good bioinformatics investigation starts by asking what information is already available.


It is your job to investigate whether brown algae (Phaeophyceae, taxid: 2870), and in particular Ectocarpus siliculosus, contain proteins that could present an allergenic risk.
*'''Q1:''' What would be your first approach to determine whether brown algae contain potential allergens? Find one database containing experimentally characterized allergens. Consider what biological information you would search for and what properties of the proteins might provide evidence of allergenic potential.


'''Where Would You Start?'''
We could try to run NetAllergen on our protein of interest, but the server will crash if too many people start to run jobs, instead we will follow an alternative approach


Every good bioinformatics investigation starts by asking what information is already available.
Now imagine that no computational predictor specifically designed for allergenicity has yet been developed. How could you attempt to predict allergenicity in silico? Which existing protein predictions or sequence properties could potentially be used as proxies for allergenicity? There is not necessarily a single correct solution here. Think about what biological properties characterize allergens and what computational tools could provide information about those properties.


'''Q1A:''' What would be your first approach to determine whether brown algae contain potential allergens?
'''Sequence Similarity and Cross-Reactivity'''


Consider what biological information you would search for and what properties of the proteins might provide evidence of allergenic potential.
Allergic reactions are not always restricted to the protein that originally caused sensitization. Antibodies recognizing one allergen may sometimes recognize structurally or evolutionarily related proteins from another organism. Is there any approach to search for sequence similarity to a known allergen? Is there another approaches to search than sequence similarity? What about structure


'''Q1B:''' Where would you look for experimental evidence that a protein has previously been associated with an allergic response?
*'''Q2:''' Based on the above is there any other tool beyond NetAllergen that can be used as a proxy to predict allergenicity in silico?  


Think about databases containing experimentally characterized allergens, epitopes, antibody responses, or other immunological measurements.
*'''Q3:''' Based on your investigation, could immunotherapy potentially reduce allergic responses to proteins found in brown algae? Use sequence or protein-family evidence to justify your answer. What would have to be true about the algal proteins for such cross-reactivity to be plausible?


Now imagine that no computational predictor specifically designed for allergenicity has yet been developed.
== PART B: Can you beat BLAST? ==


'''Q1C:''' How could you attempt to predict allergenicity in silico?
You will now develop your own allergenicity predictor using a Random Forest classifier in Google Colab. If you have not used Google Colab before, you can find an introduction [https://colab.research.google.com/notebooks/basic_features_overview.ipynb here]


Which existing protein predictions or sequence properties could potentially be used as proxies for allergenicity?
Open the notebook for this exercise:
[https://colab.research.google.com/drive/1vNR_jJeJrMdVoGcTL3iPCKKsXqPi62he?usp=sharing Notebook]


There is not necessarily a single correct solution here. Think about what biological properties characterize allergens and what computational tools could provide information about those properties.
Make a copy of the notebook in your own gmail account. Run the notebook step by step rather than simply selecting "Run all". Your goal is to understand what happens to the data at each stage.


Sequence Similarity and Cross-Reactivity
You will first need to upload the data to google Colab. The data is placed in DTU Learn as data.csv


Allergic reactions are not always restricted to the protein that originally caused sensitization. Antibodies recognizing one allergen may sometimes recognize structurally or evolutionarily related proteins from another organism.
*'''Q4:''' What will the model see? Inspect the data. How is the data structured? List the type of input features.


ALK has developed allergen immunotherapy treatments against house dust mites. One of the major allergens from Dermatophagoides pteronyssinus is Der p 1.
Now pick a random seed (replace the default 42) and run the feature-generation and Random Forest training steps in the notebook.


Following prolonged allergen immunotherapy, many patients show reduced allergic symptoms towards house dust mites. Interestingly, reductions in reactions to some other allergens have also been observed.
The notebook trains and tests the model using the different sequence partitions. For simplicity these partitions are provided to you in the data. However, remember that these are not random partitions of the data, instead the sequences have been clustered according to sequence homology so no similar proteins are contained across partitions. Predictions from the independent test partitions are then combined to obtain an overall evaluation of the model.


Let us investigate one possible explanation.
Run the evaluation section of the notebook.


Go to the NCBI BLAST server:
It will report several performance measures:


https://blast.ncbi.nlm.nih.gov/Blast.cgi
Accuracy — fraction of all predictions that are correct
Precision — fraction of proteins predicted as allergens that actually are allergens
Recall (sensitivity) — fraction of allergens correctly identified by the predictor
Specificity — fraction of non-allergens correctly identified.
MCC (Matthews Correlation Coefficient) — overall agreement between predictions and observations, taking all four outcomes of the confusion matrix into account.
ROC-AUC — ability of the model to discriminate allergens from non-allergens across different classification thresholds.


Retrieve the protein sequence of Der p 1 and investigate whether similar proteins occur among known allergens from other species.
*'''Q5:''' How well does it work? Report the performance of your predictor


In particular, consider allergens associated with papaya and pineapple (Ananas).
Inspect the '''confusion matrix''' produced by the notebook.


'''Q2:''' Can you identify a possible molecular explanation for cross-reactivity between these allergens?
The four possible outcomes are:


Consider:
True positive (TP): allergen → predicted allergen 
True negative (TN): non-allergen → predicted non-allergen 
False positive (FP):non-allergen → predicted allergen 
False negative (FN): allergen → predicted non-allergen


Sequence similarity.
*'''Q6:''' Where does the model make mistakes? Imagine that this predictor is being used as an initial "screening tool for proteins in a novel food".


Protein family and function.
'''Accuracy is not the whole story''' Two models can have similar accuracy while behaving differently towards allergens and non-allergens.


Conserved regions that could potentially be recognized by the same antibodies.
Inspect the '''ROC curve''' generated by the notebook. The diagonal line represents the performance expected from random classification. An AUC of approximately 0.5 corresponds to random discrimination, whereas a value approaching 1.0 indicates increasingly good separation between the two classes.  


Do your observations support the hypothesis that these proteins could exhibit immunological cross-reactivity? Explain your reasoning.
*'''Q7:''' Why it makes more sense to use AUC than accuracy to report performance. Record the AUC of your model.  


Back to Brown Algae
You now have a baseline model. Let's play with one of the random forest parameters. Number of estimators.


We can now return to our original food-safety problem.
*'''Q8:''' How the number of estimators 10, 100, 1000 affects model performance?


'''Q3:''' Based on your investigation, could an immunotherapy targeting an existing allergen potentially reduce allergic responses to proteins found in brown algae?
== PART C Can you beat the baseline? ==


Use sequence or protein-family evidence to justify your answer.
Now it is your turn. Modify the computational approach and determine whether you can improve allergenicity prediction.


What would have to be true about the algal proteins for such cross-reactivity to be plausible?
You are free to modify the pipeline. For example, you could investigate:


== PART B: Develop your own allergenicity prediction ==
* different Random Forest parameters
* alternative machine-learning algorithms
* feature selection or preprocessing
* strategies for dealing with class imbalance
* alternative sequence representations


Now we are going to develop an allergenicity predictor using random forest
You do '''not''' need to try everything. A well-motivated modification that you evaluate correctly is more interesting than testing many methods without understanding them.


Follow the code in google Colab. Here you will find some hints on how to use google colab: https://colab.research.google.com/notebooks/basic_features_overview.ipynb#scrollTo=WUtu4316QSHL
You may use '''ChatGPT or other language models''' to help you modify the code. However, you should understand what you changed and be able to explain why you expected it to help.


https://colab.research.google.com/drive/1vNR_jJeJrMdVoGcTL3iPCKKsXqPi62he?usp=sharing
*'''Q9:''' Provide a rationale for the change and report the new performance.


Note the different steps involved in the creation of the predictor.
*'''Q10:''' Did your modification improve allergenicity prediction?


:1. Data collection and filtering (Data upload)
== Conclusion ===
:2. Clustering
:3. Train and test data split
:4. Training
:5. Evaluation


Report the performance of your model.
You should now have experience with two complementary approaches to investigating protein allergenicity:


== PART C ==
Knowledge and similarity-based analysis: using experimental evidence, known allergens, sequence similarity, and biological knowledge to identify potential cross-reactivity.


Now it is your turn to improve the allergenicity prediction. Optimize the code to improve performance. Here you are allowed to use chatGPT and other language models so give your best hit, and try to beat the earliest performance. There are many things that can be improved such as changing the random forest for other machine learning architectures, add a regularization term to avoid overfitting, you can do some pre-processing of the data or be more creative and find other ways to improve allergenicity prediction. This is a potential project to continue in the mini research project of the second part of the group, and original projects are always evaluated extra-positively!
Machine-learning-based prediction: using protein sequence information to train a model that distinguishes allergens from non-allergens.


(Hint: If you are not very familiar with programming you can optimise the given code and asking chatgpt) Here you can find some documentation from sci-kit learn and examples: https://scikit-learn.org/stable/index.html
Most importantly, consider that predictive performance alone does not guarantee that a model has learned the underlying biology. Dataset construction, sequence redundancy, feature selection, and independent evaluation all strongly influence the apparent performance of a bioinformatics predictor.


In the hand in, share your code, and report the new performance.
Done!

Latest revision as of 22:39, 29 September 2026

Exercise written by Carolina Barra Quaglia

Introduction

Climate change and the increasing demand for sustainable food production are driving the search for alternative protein sources. Algae are particularly interesting because they are abundant, can be cultivated without agricultural land, and may provide a valuable source of proteins and other nutrients.

However, introducing a new protein source into the human diet also raises an important question: could some of these proteins cause allergic reactions?

Food allergens are generally proteins that are recognized by the immune system and can trigger an inappropriate immune response in susceptible individuals. Experimental characterization of every protein in a new food source is expensive and time-consuming. Bioinformatics can therefore play an important role in identifying proteins with potential allergenic properties and prioritizing candidates for experimental investigation.

Learning Objectives

After completing this exercise, you should be able to:

  • Use biological databases and sequence similarity to investigate potential protein allergens
  • Explain how sequence similarity can provide evidence for potential allergenicity and cross-reactivity, and recognize its limitations
  • Build and evaluate a simple machine-learning model for allergenicity prediction
  • Identify limitations of a prediction model and explore strategies to improve its performance

The research question

Researchers at DTU Food are interested in developing a high-protein food product based on brown algae. Before introducing a new protein source into the human diet, however, we need to consider its potential allergenicity.

Your task is therefore to investigate:

Could proteins from brown algae represent an allergenic risk, and how could we predict this risk computationally?

We will focus particularly on Ectocarpus siliculosus, a species belonging to the brown algae (Phaeophyceae, taxid: 2870).

We will first explore how known allergens and sequence similarity can be used to assess potential allergenicity. We will then build our own machine-learning classifier for allergen prediction using a Random Forest. Finally, you will try to improve the predictor using alternative features, preprocessing strategies, machine-learning algorithms, or other approaches of your choice.

PART A: Investigating Allergenicity

Where Would You Start?

Every good bioinformatics investigation starts by asking what information is already available.

  • Q1: What would be your first approach to determine whether brown algae contain potential allergens? Find one database containing experimentally characterized allergens. Consider what biological information you would search for and what properties of the proteins might provide evidence of allergenic potential.

We could try to run NetAllergen on our protein of interest, but the server will crash if too many people start to run jobs, instead we will follow an alternative approach

Now imagine that no computational predictor specifically designed for allergenicity has yet been developed. How could you attempt to predict allergenicity in silico? Which existing protein predictions or sequence properties could potentially be used as proxies for allergenicity? There is not necessarily a single correct solution here. Think about what biological properties characterize allergens and what computational tools could provide information about those properties.

Sequence Similarity and Cross-Reactivity

Allergic reactions are not always restricted to the protein that originally caused sensitization. Antibodies recognizing one allergen may sometimes recognize structurally or evolutionarily related proteins from another organism. Is there any approach to search for sequence similarity to a known allergen? Is there another approaches to search than sequence similarity? What about structure

  • Q2: Based on the above is there any other tool beyond NetAllergen that can be used as a proxy to predict allergenicity in silico?
  • Q3: Based on your investigation, could immunotherapy potentially reduce allergic responses to proteins found in brown algae? Use sequence or protein-family evidence to justify your answer. What would have to be true about the algal proteins for such cross-reactivity to be plausible?

PART B: Can you beat BLAST?

You will now develop your own allergenicity predictor using a Random Forest classifier in Google Colab. If you have not used Google Colab before, you can find an introduction here

Open the notebook for this exercise: Notebook

Make a copy of the notebook in your own gmail account. Run the notebook step by step rather than simply selecting "Run all". Your goal is to understand what happens to the data at each stage.

You will first need to upload the data to google Colab. The data is placed in DTU Learn as data.csv

  • Q4: What will the model see? Inspect the data. How is the data structured? List the type of input features.

Now pick a random seed (replace the default 42) and run the feature-generation and Random Forest training steps in the notebook.

The notebook trains and tests the model using the different sequence partitions. For simplicity these partitions are provided to you in the data. However, remember that these are not random partitions of the data, instead the sequences have been clustered according to sequence homology so no similar proteins are contained across partitions. Predictions from the independent test partitions are then combined to obtain an overall evaluation of the model.

Run the evaluation section of the notebook.

It will report several performance measures:

Accuracy — fraction of all predictions that are correct
Precision — fraction of proteins predicted as allergens that actually are allergens
Recall (sensitivity) — fraction of allergens correctly identified by the predictor
Specificity — fraction of non-allergens correctly identified.
MCC (Matthews Correlation Coefficient) — overall agreement between predictions and observations, taking all four outcomes of the confusion matrix into account.
ROC-AUC — ability of the model to discriminate allergens from non-allergens across different classification thresholds.
  • Q5: How well does it work? Report the performance of your predictor

Inspect the confusion matrix produced by the notebook.

The four possible outcomes are:

True positive (TP): allergen → predicted allergen  
True negative (TN): non-allergen → predicted non-allergen  
False positive (FP):non-allergen → predicted allergen  
False negative (FN): allergen → predicted non-allergen
  • Q6: Where does the model make mistakes? Imagine that this predictor is being used as an initial "screening tool for proteins in a novel food".

Accuracy is not the whole story Two models can have similar accuracy while behaving differently towards allergens and non-allergens.

Inspect the ROC curve generated by the notebook. The diagonal line represents the performance expected from random classification. An AUC of approximately 0.5 corresponds to random discrimination, whereas a value approaching 1.0 indicates increasingly good separation between the two classes.

  • Q7: Why it makes more sense to use AUC than accuracy to report performance. Record the AUC of your model.

You now have a baseline model. Let's play with one of the random forest parameters. Number of estimators.

  • Q8: How the number of estimators 10, 100, 1000 affects model performance?

PART C Can you beat the baseline?

Now it is your turn. Modify the computational approach and determine whether you can improve allergenicity prediction.

You are free to modify the pipeline. For example, you could investigate:

  • different Random Forest parameters
  • alternative machine-learning algorithms
  • feature selection or preprocessing
  • strategies for dealing with class imbalance
  • alternative sequence representations

You do not need to try everything. A well-motivated modification that you evaluate correctly is more interesting than testing many methods without understanding them.

You may use ChatGPT or other language models to help you modify the code. However, you should understand what you changed and be able to explain why you expected it to help.

  • Q9: Provide a rationale for the change and report the new performance.
  • Q10: Did your modification improve allergenicity prediction?

Conclusion =

You should now have experience with two complementary approaches to investigating protein allergenicity:

Knowledge and similarity-based analysis: using experimental evidence, known allergens, sequence similarity, and biological knowledge to identify potential cross-reactivity.

Machine-learning-based prediction: using protein sequence information to train a model that distinguishes allergens from non-allergens.

Most importantly, consider that predictive performance alone does not guarantee that a model has learned the underlying biology. Dataset construction, sequence redundancy, feature selection, and independent evaluation all strongly influence the apparent performance of a bioinformatics predictor.

Done!