LSMA

LONDON SCHOOL OF MULTIOMICS & AI

Free course

Free course

0 of 73 lessons

Lesson 1 of 12

Module 8 · AI for biology

Where AI fits in biology

Where AI fits in biology

Where AI fits in biology

For everyday tasks, from finding related sequences to designing CRISPR guides, see the established method and the AI method side by side. Learn what AI does well in biology, where it fails, and why data, labels and compute decide which to use.

⏱ 16 min readModule 8 · AI for biologyFree
Lesson at a glance6 steps · about 16 min
  1. What we mean by AI
  2. Four tasks, two methods each
  3. What AI is good at in biology
  4. What AI is bad at
  5. Data, labels and compute
  6. Where the field is heading

What we mean by AI

Module 7, From genes to function, took you from a list of genes to what they do: domains and families, folded structures, pathways and networks. Almost every method there was built on rules and statistics that people designed, such as profile HMMs, alignments and enrichment tests. This module asks where learned models now sit beside those methods, what they add, and how to tell when their results can be trusted.

"AI" is used loosely, so it helps to pin down three words before we start. Artificial intelligence is the broad goal of getting computers to do tasks that seem to need judgement. Machine learning is the part of AI that does this by learning from examples rather than from rules a person wrote down. Deep learning is machine learning with large neural networks: models built from many layers of simple calculations, each layer feeding the next.

A few more words recur in every lesson of this module. A model is the thing that makes predictions, for example "is this protein secreted?". Training is the process of adjusting the model's internal numbers, its parameters, until its predictions on known examples are as good as possible. A feature is a number the model is given about each example, such as the share of leucine in a protein. A label is the right answer for a training example, such as "secreted" or "mitochondrial".

Two more distinctions help you place any method you meet. When every training example has a label, the model is doing supervised learning: it learns to map features to answers. When there are no labels, as in the clustering of cells you will see later in this module, it is unsupervised learning: it looks for structure in the data by itself. And when the answer is a category ("secreted" or "not secreted") the task is classification; when it is a number, such as a melting temperature or an expression level, it is regression. Knowing which of these a paper is doing tells you what kind of score to expect and which checks matter.

Most of bioinformatics was built before machine learning became common, and much of it still works very well. This lesson places the two side by side: for four everyday tasks, the established method and the AI method that now sits beside it. The point is not that one replaces the other, but that each has a place.

The machine learning in this module is kept gentle. The ideas it relies on (training and test sets, scaling, measuring performance) are explained as they come up, above all in A first sequence classifier, evaluated honestly and Measuring a model honestly: confusion matrix, ROC, precision, recall and imbalance.

Where AI fits: traditional methods and AI methods side by side · LSMA free course Two rows. In the traditional route, an expert writes rules, a program applies them to new data and gives an answer. In the machine learning route, many labelled examples go into training, which produces a model; the model then gives answers for new data. The second route needs labelled data and computing power. 1 · TRADITIONAL: RULES WRITTEN BY PEOPLE Expert knowledge Program applies rules Answer for new data "a guide needs NGG after it" same steps every time easy to explain 2 · MACHINE LEARNING: RULES LEARNED FROM EXAMPLES Labelled examples Training → a model Answer for new data guides + measured activity parameters adjusted harder to explain Route 2 needs three things route 1 does not: data, labels and compute.
The same question can be answered by rules a person wrote or by rules a model learned from examples. Schematic.

How to read this figure

Read each row from left to right. In the top row, the knowledge comes from people: someone studied the biology and wrote it down as rules, and a program applies them. In the bottom row, the knowledge comes from data: a model is shown many examples with known answers and adjusts itself until it gets them right. Both rows end the same way, with an answer for data the method has not seen before. The difference is where the rules came from, and so how easy they are to check and explain.

A learned rule can also pick up things nobody intended. If, in the training data, most secreted proteins happen to come from one well-studied organism, the model may partly learn "looks like that organism" rather than "has a signal peptide". A written rule cannot drift in this way, because a person chose every part of it. This is why the lessons that follow spend as much time on how a model was tested as on how it was built.

Four tasks, two methods each

The table below takes four tasks you have met, or will meet, in this course. For each, it gives the long-established method and the AI method that has grown up beside it.

TaskTraditional methodAI methodWhat the AI method adds
Find related sequencesAlignment search such as BLAST: score letter-by-letter matches against a databaseEmbedding search: turn each protein into a vector with a language model and look for near neighboursCan pick up distant relatives whose letters have drifted too far for alignment
Find genes in a genomeGene finders built on hidden Markov models, with statistics for codons, splice sites and start and stop signalsDeep models trained on well-annotated genomes, and splice-site predictors that read long stretches of sequenceUses more of the surrounding sequence; can learn signals no one wrote down
Predict a protein's 3D structureHomology modelling: copy the shape of a related protein whose structure is known (a template)AlphaFold and similar networks, trained on experimental structuresOften accurate even with no close template; gives a confidence score per residue
Design CRISPR guidesRules: an NGG PAM next to the target, moderate GC content, no run of four Ts, few near matches elsewhereLearned activity scores, trained on screens that measured thousands of guidesRanks guides that all pass the rules, by how well they are likely to cut

How to read this table

Read across each row: the task, how it has been done for years, how AI does it now, and what that gains. Some terms need a word of explanation.

  • Alignment search lines a query sequence up against each database sequence and scores the matches, mismatches and gaps. BLAST, which Module 4 covers, is the best-known tool. It works very well while the sequences still share a good fraction of their letters. Below about 30% identity, alignment scores become hard to tell apart from chance.
  • An embedding is a list of numbers (a vector) that a model produces to summarise a sequence. Proteins with similar vectors tend to be related, even when their letters differ a lot. Protein language models and embeddings builds embeddings for real proteins.
  • A hidden Markov model (HMM) is a statistical model that walks along a sequence, switching between hidden states such as "exon", "intron" and "between genes", each with its own typical letters. Classic gene finders use one. Its structure is designed by people; only its probabilities are learned.
  • Homology modelling builds a structure for a protein by borrowing the backbone of a related protein whose structure was solved by experiment. It needs such a template to exist. AlphaFold is a deep learning system that predicts structure from sequence and a set of related sequences. Its predictions for most known proteins are free to browse in the AlphaFold Protein Structure Database (Module 2).
  • A guide is the short RNA that leads the Cas9 enzyme to a DNA target. The PAM is a short motif Cas9 needs beside the target; for the commonly used Cas9 it is NGG, where N is any base. A run of four Ts can stop the guide being made from the usual promoter, which is why rule-based tools avoid it.

Notice the last column. In every row, the AI method does not throw the old one away. Embedding search sits beside BLAST. AlphaFold uses a set of related sequences, gathered by the same kind of search the traditional methods use. Learned guide scores are applied to guides that already passed the rules. In practice the two are layered.

You have already used the traditional column. In Finding genes and annotating a genome you met gene finders built on HMMs; in Protein families, domains and motifs you searched for domains with profile HMMs; and in Protein structure: from sequence to fold you saw how a template structure is borrowed. Those methods are fast, well understood and easy to explain, which is why they remain the first step in most pipelines. A sensible habit is to run the traditional method first, then ask what the AI method changes: does it agree, does it add a prediction where the old method was silent, or does it disagree? Disagreements are the cases worth looking at by hand.

BLAST was introduced by Altschul et al. 1990, Journal of Molecular Biology. The figure of about 30% identity comes from work on the "twilight zone" of alignments, especially Rost 1999, Protein Engineering, which showed that below roughly 20 to 35% identity, pairs with similar structures become hard to tell apart from unrelated pairs. Cite it with its caveat: the threshold depends on alignment length, and short alignments need higher identity to be meaningful. In practice, an E-value from the search is a better guide than a fixed percentage, because it accounts for length and database size.

What AI is good at in biology

  • Patterns in large, labelled data. When there are tens of thousands of examples with reliable answers, a model can pick up combinations of signals too subtle or too many for a person to write as rules.
  • Many features at once. A protein can be described by hundreds of numbers (Turning sequences into numbers: features for machine learning). Models handle that easily; a person cannot weigh them all by hand.
  • Speed once trained. Training can be slow, but a trained model often answers in a fraction of a second, so it can be run on every protein in a genome.
  • Using unlabelled sequence. Protein language models (Protein language models and embeddings) learn from raw sequences with no labels at all, and there are hundreds of millions of those.

A long-running example is the prediction of signal peptides, the short stretch at the start of a protein that sends it out of the cell. There is no single written rule for them: they vary in length and letters, and share only a loose pattern of a charged start, a run of water-avoiding residues and a cutting site. Tools such as SignalP have used neural networks trained on curated proteins with known signal peptides for this task since the 1990s, because it is exactly the kind of fuzzy, many-signal pattern that learning handles well.

What AI is bad at

  • Small data. With a few dozen examples, a flexible model can memorise them, noise included. It then looks perfect on its own examples and fails on new ones. This is called overfitting.
  • Cases unlike its training data. A model trained on human proteins may do poorly on proteins from a distant organism. Models are good at filling in between their examples and weak at going beyond them.
  • Explaining itself. A rule says why; a deep model mostly does not. Deep learning on sequences: what the model actually learns shows one way to look inside, but most of a large model stays hard to read.
  • Knowing when it is wrong. Many models give a confident answer for anything you feed them. Confidence scores, such as AlphaFold's, help but are themselves predictions.
  • Honest scores. If near-identical sequences sit in both the training and the test data, the reported accuracy is too high. This trap, homology leakage, is the subject of A first sequence classifier, evaluated honestly.

One more weakness is easy to miss: a model learns whatever separates the labels, not only the biology. If all the tumour samples in a dataset were sequenced in one batch and all the normal samples in another, a model can reach a high score by spotting the batch, with no help from the disease. The same happens with sequences when the positive examples come from one database and the negatives from another. Before trusting a score, ask what else, apart from the biology, differs between the groups.

Go deeper: always beat the simple baseline first

A new model should be compared with the simplest method that could do the same job. For many protein tasks, that baseline is label transfer by similarity: run BLAST, find the closest annotated protein, and copy its label. It needs no training and often scores well, because related proteins usually share functions.

If a deep model reaches 90% accuracy and the BLAST baseline reaches 88% on the same test proteins, the model has added little. If the baseline reaches 60%, the model has learned something extra. The comparison is most telling on test proteins with no close relative in the training data, which is where the baseline should struggle and a good model should still hold up. Papers that skip this baseline make it impossible to tell whether the model learned biology or simply rediscovered sequence similarity.

Data, labels and compute

Every AI method in the table rests on three things the traditional route did not need.

Data means examples, in large numbers and of good quality. The public archives of Module 2 are the reason biology could adopt AI at all: decades of shared sequences, structures and annotations.

Labels are the answers, and they are the scarce part. A structure predictor learns from experimentally solved structures, which took years of laboratory work each. A localisation predictor learns from curated database entries, which are only as good as the evidence behind them. Labels can be wrong, unevenly spread across protein families, or biased towards well-studied genes, and a model learns those flaws too.

Compute is computer power. Training a large model can take many specialised processors (GPUs, graphics processing units) for days or weeks, which only big groups can afford. Using a trained model is far cheaper: the small models in this module run on the free computers in Google Colab in seconds.

Labels also have a history worth checking. Many functional annotations in public databases were not measured but copied from a similar sequence; in Gene Ontology these carry the evidence code IEA, "inferred from electronic annotation". A model trained on such labels partly learns to repeat the similarity search that produced them, so its score can look good without it having learned anything new. Where you can, train and test on labels with experimental evidence, and say which evidence codes you kept.

Where AI fits: traditional methods and AI methods side by side · LSMA free course A two by two grid. The horizontal axis is the number of labelled examples, from few to many. The vertical axis is whether a clear rule is known. Clear rule with few examples: use the rule. Clear rule with many examples: rule first, then a learned score to rank. No clear rule with few examples: risky, gather more data or use a pretrained model. No clear rule with many examples: where machine learning shines. WHEN IS AI WORTH TRYING? Clear ruleknown No clearrule Use the rule Rule first, then learned score Risky: gather data, or use Where machine learning shines simple, explainable, enough e.g. CRISPR guides a pretrained model e.g. structure from sequence Few labelled examples Many labelled examples
A rough guide, not a law. The bottom-right box is where the big successes, such as structure prediction, sit. Schematic.

How to read this figure

Place your problem in the grid by asking two questions. Across: how many examples with trustworthy answers do you have? Down: does biology already give a clear rule? If a good rule exists, start with it, whatever your data. If no rule exists and you have many labelled examples, a learned model is likely to help. The bottom-left box is the hard one: no rule and little data. There, a model trained on someone else's large dataset, such as the language model in Protein language models and embeddings, is often the best way in.

Where the field is heading

Publications that mention bioinformatics have grown very fast in recent years, and a growing share of them use machine learning. Three trends matter for this module. First, models trained on huge amounts of unlabelled sequence, in the style of the large language models used for text, are now a standard starting point for protein and DNA problems. Second, structure prediction has moved from single chains towards complexes and interactions. Third, cloud computing and shared notebooks have made it possible for anyone to run these models, as you will in this module. None of this removes the need to check results against biology and experiment.

One habit from the field is worth copying. Structure prediction improved partly because of CASP, a blind assessment held every two years in which groups predict structures that have been solved but not yet released, so nobody can tune their method to the answers. A fair test of any model has the same shape: the examples it is judged on must be kept from it until the end. You will apply this idea yourself in A first sequence classifier, evaluated honestly.

Worked example · enough data for a model?

An example project: a lab has measured 60 peptides, 30 that kill bacteria and 30 that do not, and wants a model that predicts activity from sequence. They plan to describe each peptide by its 400 dipeptide counts (Turning sequences into numbers: features for machine learning).

examples = 60 features per example = 400
features ÷ examples = 400 ÷ 60 ≈ 6.7
held-out test set (20%) = 0.2 × 60 = 12 peptides
one wrong test prediction = 1 ÷ 12 ≈ 8 percentage points

Step by step. Divide the number of features by the number of examples: 400 ÷ 60 is about 6.7, so there are almost seven numbers to learn from for every example. With more features than examples, a flexible model can always find some combination that separates the training peptides perfectly, even by chance. Next, set aside 20% as a test set: 0.2 × 60 = 12 peptides. Each test peptide is then worth 1 ÷ 12 of the score, about 8 percentage points, so the measured accuracy will swing a lot from one split to the next.

What the answer means. This project sits in the bottom-left box of the second figure. A perfect training score would mean little, and a test score from 12 peptides would be very uncertain. Sensible options are fewer, simpler features (20 composition values, or a few properties such as charge and hydrophobicity), cross-validation instead of a single split (A first sequence classifier, evaluated honestly), embeddings from a pretrained model (Protein language models and embeddings), or more measurements. "Can we use AI?" is often really "do we have enough labelled data?".

Key point

AI methods sit beside traditional ones, not instead of them. They shine when there is plenty of good labelled data and no simple rule, and they struggle with small data, unfamiliar cases and leaky evaluation.

A second example: to find the open reading frames in a newly sequenced virus, a simple rule (start codon, then codons until a stop) does the job, and anyone can check it. A model would add little. To predict which of those proteins will be secreted, there is no simple rule, but tens of thousands of curated human proteins with known locations exist, and a learned model is the natural choice, as long as it is tested honestly.

Further reading · Module 8AlphaFold Protein Structure Database FAQ: what the predictions are, and how to read their confidence scores. · scikit-learn: getting started: the Python library used for the classic models in this module. · All reading for this course

Check your understanding

1. A team wants to predict protein structure for a protein with no related structure in the PDB. Why is homology modelling a poor fit here?

2. A model scores 100% on its own 50 training examples, described by 500 features each, and 60% on new data. What is the most likely explanation?

3. Why do learned CRISPR guide scores not replace the traditional design rules?

Up next

Lesson 2

Turning sequences into numbers: features for machine learning

Ask BioTutor

Create a free website with Framer, the website builder loved by startups, designers and agencies.