File size: 2,156 Bytes
7a6e052 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
---
language:
- en
tags:
- biology
- genomics
- codon-optimization
- p-adic-math
- hyperbolic-geometry
- ddg-prediction
license: other
metrics:
- spearmanr
---
# Ternary Codon Encoder: P-adic Hyperbolic Embeddings
The Ternary Codon Encoder is a neural embedding model that maps the 64 genetic codons into a 16-dimensional hyperbolic space. It is the first model to explicitly use **3-adic valuation** as a mathematical prior to organize the genetic code's hierarchical structure.
## Model Description
- **Architecture:** MLP-based encoder (12-dim one-hot input $
ightarrow$ 16-dim hyperbolic output).
- **Mathematical Foundation:** Leverages 3-adic mathematics to represent the discrete hierarchy of the codon table.
- **Latent Space:** Poincaré ball where radial distance encodes 3-adic valuation (conservation/variability).
## Key Discoveries
- **Physics Dimension:** Latent dimension 13 correlates strongly ($
ho = -0.70$) with molecular mass, volume, and force constants ($k$).
- **Linear Stability Manifold:** Provides high-quality feature vectors for sequence-only protein stability ($\Delta\Delta G$) prediction.
- **Synonymous Cohesion:** Synonymous codons cluster together in hyperbolic space while maintaining clear boundaries between amino acid groups.
## Performance
- **DDG Spearman $
ho$:** 0.614 (Sequence-only benchmarking on diverse datasets).
- **Improvement:** +105% over baseline p-adic embedding models.
## Usage
```python
import torch
from trainable_codon_encoder import TrainableCodonEncoder
# Load model
encoder = TrainableCodonEncoder(latent_dim=16, hidden_dim=64)
checkpoint = torch.load("pytorch_model.bin", map_location="cpu")
encoder.load_state_dict(checkpoint["model_state_dict"])
encoder.eval()
# Get embedding for a codon (e.g., ATG index 14)
codon_idx = torch.tensor([14])
with torch.no_grad():
z_hyp = encoder(codon_idx)
print(f"Hyperbolic Embedding: {z_hyp}")
```
## Citation
```bibtex
@software{ternary_codon_2026,
author = {AI Whisperers},
title = {Ternary Codon Encoder: P-adic Hyperbolic Embeddings},
year = {2026},
url = {https://huggingface.co/ai-whisperers/ternary-codon-encoder}
}
```
|