-
Notifications
You must be signed in to change notification settings - Fork 6
Recoding PCA
Figure version 1.0.0, generated with CSUBST 1.15.0.
This comparison adds ProstT5-CNN and ESM3Di-35M to the original ProstT5 predictor, alongside the amino-acid recoding schemes. All three 3Di predictors use the same bundled PGK dataset: 33 sequences and 417 aligned codon positions.

Vector image (SVG) · PCA coordinates · Input features
The three panels show one PCA, with different axis ranges. The full view
retains srchisq6; the enlarged views make the other recodings and individual
3Di predictors readable. Adding predictors refits the PCA, so the axes and
coordinates need not match the old figure.
Each point represents one recoding scheme or one 3Di predictor. The 20 amino acids give 190 unordered pairs, excluding self-pairs:
- For fixed amino-acid recodings, each feature is 1 when the pair belongs to
the same recoded group, and 0 otherwise.
noleaves all 20 amino acids separate, giving an all-zero feature vector. - For 3Di, CSUBST counts amino-acid/3Di co-occurrences in the predicted tip
alignments, adds a pseudocount of
1e-6per state, and normalizes each amino-acid row. A pair's feature is the dot product of its two distributions over the 20 3Di states. Gaps and unknown symbols are excluded. -
srchisq6andkgbauto6are inferred from this PGK alignment, using the default seed 42 and 1,000 random starts.
PCA centers the 190 feature columns without variance scaling, then uses SVD. The plotted percentages give the variance explained by each component across all 14 points: PC1 explains 30.1% and PC2 19.4% (49.6% combined). Fixed recodings are binary partitions, whereas 3Di features are distribution similarities; that distinction contributes to their geometry.
This is a descriptive comparison of these features on PGK. Proximity does not establish equivalent 3Di predictions, reconstruction results, or accuracy. See Structural alphabet predictors for the models and their limitations.
The input is the trimmed PGK codon alignment, matching the earlier example's input convention. For this comparison, it is explicitly supplied as both the analysis and prediction input; all three predictors therefore see the same ungapped amino-acid sequences derived from these 417 codon positions. This is not a comparison using separately supplied complete proteins.
The following files are in assets/recoding-pca-pgk/ in the Wiki repository:
-
PGK.alignment.faandPGK.tree.nwk: exact inputs, copied from CSUBST commit dd37bee. -
infer.py: calls the production CSUBST recoding and 3Di feature helpers. -
fixed.json: inferred/fixed groups and all pair features. -
prostt5.json,prostt5-cnn.json,esm3di-35m.json: predicted AA/3Di alignments and pair features, with the input SHA-256. -
plot.py: regenerates the figure, feature CSV, coordinate CSV, andsummary.jsonfrom the saved JSON files, without model inference.
git clone https://github.com/kfuku52/csubst.wiki.git
cd csubst.wiki/assets/recoding-pca-pgk
# With CSUBST 1.15.0 and Matplotlib installed:
python plot.pyTo recompute predictions, install the 3di extra and prepare all three model
resources using csubst download. The original calculation used an RTX 6000
Ada GPU with PyTorch 2.6.0/CUDA 12.4, Transformers 5.16.1 and PEFT 0.20.0.
The prediction and recoding source files were verified to match commit
dd37bee. The model checkpoints are the pinned, validated defaults in that
version. Inference uses batches of up to four; ProstT5 uses greedy decoding.
python infer.py fixed
for backend in prostt5 prostt5-cnn esm3di-35m; do
python infer.py "$backend" --device cuda \
--model-dir /path/to/ProstT5 --cache-dir /path/to/resource-cache
done
python plot.pyThe old PGK image remains in issue #88 and the repository history. This page provides the expanded comparison in the Wiki.
The standard inspect plot includes the selected 3Di predictor when requested:
csubst inspect --alignment_file alignment.fa --rooted_tree_file tree.nwk \
--plot_nonsyn_recode_pca yes --plot_nonsyn_recode_pca_3di20 yes \
--sa_backend esm3di-35m --sa_device cpuThat command includes one 3Di point. The saved reproduction script above combines all three predictors into the same PCA for this comparison.