AlphaFold confidence across a protein family

AlphaFold scores every residue it models with pLDDT, a confidence from 0 to 100 that AlphaFold DB bands as very high (above 90), confident (70 to 90), low (50 to 70) and very low (below 50). TDP-43, the protein the TARDBP gene encodes, has three folded domains and a 150-residue C-terminal region, so its models score at both ends of that range, and the folded domains should score high in every model. For fourteen vertebrate TDP-43 orthologs, we:

  • fetch the UniProt sequences, align them and infer a tree
  • read the pLDDT from each AlphaFold model and add the mean per column as a track in AlphaFold DB’s colors
  • mark the Pfam domains and add three rows’ own pLDDT as strips
  • count each row’s residues under 50 beside the tree
  • check two columns against the model files and open the result

Prerequisites

  • curl
  • ClustalW, apt install clustalw on Debian or Ubuntu, brew install clustal-w on macOS. ClustalW both aligns and infers a tree, so this page needs no other aligner.
  • python3, standard library only

The data

Fourteen UniProtKB entries and their AlphaFold models. AlphaFold DB is keyed on UniProt accession, so one accession fetches the sequence and the model both. Nothing to download: the commands below fetch these.

What it is File
Every sequence in one request, shown here with two of the fourteen accessions uniprotkb-accessions
One AlphaFold record per accession, which names its files, for example Q13148
The model that record names, whose B-factor column holds the pLDDT, for example AF-Q13148-F1-model_v6.pdb
The Pfam matches of the human sequence Q13148
The files this page writes, hosted for the figure links
What it is File
The row table the commands below start from tardbp-rows.tsv
The alignment they write tardbp.afa
Its tree tardbp.nwk
Each row’s mean pLDDT and count of residues under 50 tardbp-rowdata.json
The tracks, highlights and bar panel the links below carry tardbp-layers.json

1. Name the rows

Write one species per line: the label the viewer draws, then the UniProtKB accession. The label becomes the FASTA defline, the tree tip and the row of every layer.

Human	Q13148
Mouse	Q921F2
Cow	G3MX91
Elephant	G3TD75
Opossum	A0A5F8GU32
Platypus	F7EDX1
Chicken	Q5ZLN5
Turtle	K7FJ67
Lizard	A0A670IXJ6
Frog	Q28F51
Coelacanth	H3BC22
Zebrafish	Q802C7
Seabream	A0A671WI33
Ghostshark	A0A4W3GN84

Both teleost entries are the tardbpb paralog, which runs the full length of the protein.

2. Fetch the sequences

One request takes every accession, and a short script rewrites each defline to the species label:

accessions=$(awk -F'\t' '{printf "%s%s", sep, $2; sep=","}' rows.tsv)
curl -sf "https://rest.uniprot.org/uniprotkb/accessions?accessions=$accessions&format=fasta" \
  -o tardbp-uniprot.fasta
  Human        Q13148       414 aa
  Mouse        Q921F2       414 aa
  Cow          G3MX91       414 aa
  Elephant     G3TD75       414 aa
  Opossum      A0A5F8GU32   414 aa
  Platypus     F7EDX1       414 aa
  Chicken      Q5ZLN5       414 aa
  Turtle       K7FJ67       414 aa
  Lizard       A0A670IXJ6   415 aa
  Frog         Q28F51       409 aa
  Coelacanth   H3BC22       412 aa
  Zebrafish    Q802C7       412 aa
  Seabream     A0A671WI33   406 aa
  Ghostshark   A0A4W3GN84   404 aa

3. Align and infer a tree

ClustalW aligns the sequences in input order and infers a neighbor-joining tree:

clustalw -INFILE=tardbp.fasta -ALIGN -TYPE=PROTEIN -OUTORDER=INPUT \
  -OUTPUT=FASTA -OUTFILE=tardbp.afa
clustalw -INFILE=tardbp.afa -TREE -TYPE=PROTEIN -OUTPUTTREE=phylip
tr -d '[:space:]' < tardbp.ph > tardbp.nwk
14 rows, 431 columns
(((((Human:0.01799,((Chicken:0.01026,(Turtle:0.00330,Lizard:0.02575):0.00303):0.00546,
(Frog:0.07202,(Coelacanth:0.08469,((Zebrafish:0.08572,Seabream:0.08841):0.05655,
Ghostshark:0.07870):0.03228):0.01066):0.02077):0.01299):0.00134,Mouse:0.01773):0.00213,
Cow:0.00108):0.00132,Platypus:0.00236):0.00000,Elephant:0.00238,Opossum:0.00000);
Fourteen rows of 431 columns, 387 of which have a residue in every row. The gaps cluster in the right third, right of the C-terminal callout. The mammal rows sit on branches of 0.001 to 0.02 substitutions per site, and on those distances neighbor joining places Human beside the sauropsids, outside the other mammals.

4. Read the pLDDT from the models

The AlphaFold API record for each accession names its model file. Send a User-Agent header, since the API answers a request without one with a 403:

url=$(curl -sf -A "$UA" "https://alphafold.ebi.ac.uk/api/prediction/Q13148" |
  python3 -c 'import json,sys; print(json.load(sys.stdin)[0]["pdbUrl"])')
curl -sf -A "$UA" "$url" -o models/Q13148.pdb

AlphaFold writes each residue’s pLDDT into the B-factor column of its CA atom, beside the residue name, so one pass reads the model’s sequence and confidence together:

def read_model(path):
    seq, plddt = '', []
    for line in open(path):
        if line.startswith('ATOM') and line[12:16].strip() == 'CA':
            seq += THREE_TO_ONE[line[17:20]]
            plddt.append(float(line[60:66]))
    return seq, plddt

A model follows the UniProt sequence of the day it was built, so the script compares it to the row letter by letter first:

  Human        Q13148       model 414 aa matches the row, mean pLDDT  65.2, 156 residues under 50
  Mouse        Q921F2       model 414 aa matches the row, mean pLDDT  63.8, 162 residues under 50
  Cow          G3MX91       model 414 aa matches the row, mean pLDDT  61.6, 172 residues under 50
  Elephant     G3TD75       model 414 aa matches the row, mean pLDDT  62.0, 178 residues under 50
  Opossum      A0A5F8GU32   model 414 aa matches the row, mean pLDDT  62.4, 169 residues under 50
  Platypus     F7EDX1       model 414 aa matches the row, mean pLDDT  61.9, 175 residues under 50
  Chicken      Q5ZLN5       model 414 aa matches the row, mean pLDDT  65.8, 155 residues under 50
  Turtle       K7FJ67       model 414 aa matches the row, mean pLDDT  61.4, 175 residues under 50
  Lizard       A0A670IXJ6   model 415 aa matches the row, mean pLDDT  62.3, 173 residues under 50
  Frog         Q28F51       model 409 aa matches the row, mean pLDDT  66.5, 156 residues under 50
  Coelacanth   H3BC22       model 412 aa matches the row, mean pLDDT  61.5, 167 residues under 50
  Zebrafish    Q802C7       model 412 aa matches the row, mean pLDDT  65.9, 149 residues under 50
  Seabream     A0A671WI33   model 406 aa matches the row, mean pLDDT  61.6, 170 residues under 50
  Ghostshark   A0A4W3GN84   model 404 aa matches the row, mean pLDDT  62.0, 172 residues under 50

Every model matches its row. The column track holds the rounded mean over the rows with a residue in each column:

means = [round(sum(values) / len(values)) for values in by_column]
columns by mean pLDDT band: 6 very high, 214 confident, 24 low, 187 very low

A threshold scale colors each bar by the band its value falls in. domain holds the three cuts and range the four colors AlphaFold DB draws its models in, lowest first, and legend.labels names the four intervals:

"encoding": {
  "y": { "scale": { "domainMax": 100 } },
  "color": {
    "scale": {
      "type": "threshold",
      "domain": [50, 70, 90],
      "range": ["#ff7d45", "#ffdb13", "#65cbf3", "#0053d6"]
    },
    "legend": {
      "title": "pLDDT",
      "labels": ["Very low", "Low", "Confident", "Very high"]
    }
  }
}

A range of any length but four draws what it can, and model.scaleProblems names the record and the member.

The mean pLDDT per column as bars in AlphaFold DB’s colors. Three light blue blocks of confident columns sit between two orange dips, and the columns from 272 to the right edge are very low.

5. Mark the Pfam domains

InterPro serves the Pfam matches of the human sequence in one request:

curl -sf https://www.ebi.ac.uk/interpro/api/entry/pfam/protein/uniprot/Q13148 \
  -o tardbp-pfam.json

The script writes each match as a highlight on the Human row, in that row’s residue numbering:

TDP43_N  PF18694 Human 4-77: columns 5-78, mean pLDDT  84.0
RRM1     PF00076 Human 106-164: columns 112-170, mean pLDDT  85.5
RRM2     PF00076 Human 193-241: columns 203-251, mean pLDDT  82.7
TDP43_C  PF20910 Human 262-371: columns 272-387, mean pLDDT  38.4
The four Pfam matches (TDP43_N, RRM1, RRM2 and TDP43_C) as blue bands over the alignment, under the mean pLDDT track. The first three bands sit under confident columns and the fourth under very low ones.

6. Add three rows’ own pLDDT

A strip track with row set draws one cell per residue of that row, and the viewer places each cell through the row’s gaps. The script writes one for the reference row, the row with the fewest residues under 50 and the row with the longest run under 50, each reading the model’s pLDDT through the color object of step 4:

{'id': f'plddt-{label.lower()}', 'name': f'{label} pLDDT', 'kind': 'strip',
 'row': label, 'values': plddt[label], 'encoding': {'color': PLDDT}}
strips for Human, Zebrafish with the fewest residues under 50 and Ghostshark with the longest run under 50
  Human        runs of 5 or more under 50 at columns 87-93, 95-106, 188-197, 274-334, 347-378, 380-424
  Zebrafish    runs of 5 or more under 50 at columns 82-93, 95-106, 287-332, 347-427
  Ghostshark   runs of 5 or more under 50 at columns 81-106, 186-197, 274-431

The list keeps runs of five or more residues, so it leaves out the Zebrafish strip’s second dip, where one residue at or above 50 splits the run.

The Human, Zebrafish and Ghostshark models’ pLDDT as three strips under the mean, under one legend. All three turn orange where the mean dips and across the C-terminal region. There the Human and Zebrafish runs stop at columns 334 and 332 and start again at 347, and the Ghostshark run continues from column 274 to 431.

7. Count each row’s residues under 50

The script writes each row’s mean pLDDT and its count of residues under 50 to the row table:

{
  "Human": { "meanPlddt": 65.2, "under50": 156 },
  "Zebrafish": { "meanPlddt": 65.9, "under50": 149 }
}

A bar row panel draws one field of that table beside the tree, with its axis in the header band:

"rowPanels": [
  {
    "kind": "bar",
    "header": "residues < 50",
    "encoding": { "x": { "field": "under50" } },
    "width": 130
  }
]
Each row’s count of residues under 50 as a bar beside the tree. The counts run from 149 in Zebrafish to 178 in Elephant, within a fifth of each other.

8. Check two columns against the models

The script reads each model file at one column inside RRM1 and one inside the C-terminal region:

RRM1, alignment column 133 (Human residue 127):
  Human        F  86.4
  Mouse        F  87.6
  Cow          F  84.4
  Elephant     F  85.2
  Opossum      F  84.9
  Platypus     F  85.1
  Chicken      F  87.9
  Turtle       F  84.8
  Lizard       F  85.5
  Frog         F  88.2
  Coelacanth   F  82.8
  Zebrafish    F  87.3
  Seabream     F  82.4
  Ghostshark   F  85.2
TDP43_C, alignment column 316 (Human residue 303):
  Human        Q  47.4
  Mouse        Q  40.7
  Cow          Q  31.6
  Elephant     Q  30.5
  Opossum      Q  33.3
  Platypus     Q  32.8
  Chicken      Q  45.2
  Turtle       Q  31.9
  Lizard       Q  32.9
  Frog         Q  46.6
  Coelacanth   Q  34.5
  Zebrafish    S  39.3
  Seabream     T  30.9
  Ghostshark   P  48.8
The RRM1 column at residue resolution, every row compared with the Human row: a dot is the same residue, a letter a different one. The boxed column 133 is Human residue 127, phenylalanine in all fourteen rows, which score 82.4 to 88.2. At the right edge the mean and the three strips turn yellow and then orange, toward column 188, where the next Human run under 50 begins.
The TDP43_C column at residue resolution, where the boxed column 316, Human residue 303, sits under a very low mean and three very low strips. The rows score 30.5 to 48.8 there, and three have a different residue.

One stretch of the C-terminal region rises out of the very low band:

inside TDP43_C, columns 335-339 rise to a mean of 52, which is Human residues 320-324
Human residues 320 to 324, where the mean turns yellow. The Human and Zebrafish strips turn yellow over the same columns, and the Ghostshark strip stays orange. Conicella et al. 2016 measured a transient helix over Human residues 321 to 340 by NMR.

9. Open the result

The snapshot loads the three files by URL:

{
  "msaview": {
    "type": "MsaView",
    "colWidth": 3.2,
    "rowHeight": 22,
    "residueColor": { "scale": { "scheme": "clustalx_protein_dynamic" } },
    "msaFilehandle": { "uri": "https://example.org/tardbp.afa" },
    "treeFilehandle": { "uri": "https://example.org/tardbp.nwk" },
    "treeMetadataFilehandle": {
      "uri": "https://example.org/tardbp-rowdata.json"
    }
  }
}

Add the columnTracks, highlights and rowPanels entries from tardbp-layers.json beside them, URL-encode the object, and append it to the app URL as #data=, about 15,200 characters in all.

The final view, with the mean and the three row strips above the alignment, each row’s count of residues under 50 beside the tree, and the Pfam bands in blue.

ggmsaview reads the three hosted files and takes each pLDDT track’s values from tardbp-layers.json. plddt() draws one through AlphaFold DB’s threshold scale, kind = "bar" for the mean and kind = "strip" with row for a row’s own pLDDT, and geom_msa_bar() draws each row’s count under 50 beside the tree:

library(ggmsaview)
data <- "https://gmod.org/JBrowseMSA/demo/data/tdp43/"
layers <- jsonlite::fromJSON(paste0(data, "tardbp-layers.json"),
  simplifyVector = FALSE)
tracks <- setNames(layers$columnTracks,
  vapply(layers$columnTracks, `[[`, "", "id"))
plddt <- function(id, kind, ...) {
  track <- tracks[[id]]
  geom_msa_track(unlist(track$values), name = track$name, id = id,
    kind = kind, row = track$row, type = "threshold",
    domain = c(50, 70, 90),
    range = c("#ff7d45", "#ffdb13", "#65cbf3", "#0053d6"),
    labels = c("Very low", "Low", "Confident", "Very high"),
    title = "pLDDT", ...)
}
w <- msaview(
  msa = paste0(data, "tardbp.afa"),
  tree = paste0(data, "tardbp.nwk"),
  residue_color = "clustalx_protein_dynamic",
  row_data = jsonlite::fromJSON(paste0(data, "tardbp-rowdata.json")),
  highlights = layers$highlights
) +
  plddt("plddt-mean", "bar", domain_max = 100, height = 60) +
  plddt("plddt-human", "strip") +
  plddt("plddt-zebrafish", "strip") +
  plddt("plddt-ghostshark", "strip") +
  geom_msa_bar("under50", header = "residues < 50", width = 130)
w
ggplot2::ggsave("alphafold-confidence-r.png",
  msaview_plot(w, tracks = names(tracks)),
  width = 12, height = 7)
The 14 rows in ggplot2 under the mean pLDDT and the Human, Zebrafish and Ghostshark strips, all four colored by one threshold scale and listed under one legend. The mean stays confident over the N-terminal domain and the two RRMs and drops to very low across the C-terminal region. The bars beside the tree count each row’s residues under 50, and Zebrafish has the fewest. The Pfam matches print as labels over the alignment, where the viewer draws them as blue bands.

Reproduce it end to end

build_alphafold_confidence.sh runs the commands and the Python above in order:

  1. It fetches the fourteen sequences from UniProt and names each FASTA record by its species label, which every layer uses as the row name.
  2. ClustalW aligns the records and infers a neighbor-joining tree.
  3. It downloads each AlphaFold model and the human Pfam matches, and stops if a model’s sequence differs from its row.
  4. It writes the tracks, the highlights and the row table, then prints the residue check of step 8.

It needs the tools under Prerequisites.

curl -O https://raw.githubusercontent.com/GMOD/JBrowseMSA/main/docs/tutorials/scripts/build_alphafold_confidence.sh
bash build_alphafold_confidence.sh

With no arguments the script writes the row table above, builds every file beside it and prints every number on this page. For another family, pass a table of labels and UniProt accessions:

bash build_alphafold_confidence.sh my-rows.tsv out/

The script takes the first Human line as the reference row, and its SHORT map names the Pfam domains for the highlights.

See also

References

  • Jumper J, Evans R, Pritzel A, et al. Highly accurate protein structure prediction with AlphaFold. Nature 596:583-589.
  • Tunyasuvunakool K, Adler J, Wu Z, et al. Highly accurate protein structure prediction for the human proteome. Nature 596:590-596.
  • Varadi M, Anyango S, Deshpande M, et al. AlphaFold Protein Structure Database: massively expanding the structural coverage of protein-sequence space with high-accuracy models. Nucleic Acids Res 50:D439-D444.
  • Conicella AE, Zerze GH, Mittal J, Fawzi NL. ALS mutations disrupt phase separation mediated by alpha-helical structure in the TDP-43 low-complexity C-terminal domain. Structure 24:1537-1549.
  • Lukavsky PJ, Daujotyte D, Tollervey JR, et al. Molecular basis of UG-rich RNA recognition by the human splicing factor TDP-43. Nat Struct Mol Biol 20:1443-1449.
  • Thompson JD, Higgins DG, Gibson TJ. CLUSTAL W: improving the sensitivity of progressive multiple sequence alignment through sequence weighting, position-specific gap penalties and weight matrix choice. Nucleic Acids Res 22:4673-4680.