AI for Genomic Medicine
Module: Healthcare AI | Difficulty: Advanced
Hardy-Weinberg Equilibrium
Polygenic Risk Score
where is the effect size and is the genotype dosage.
Phred-Scaled Quality Score
Genomic AI Applications
| Application | Method | Accuracy | Clinical Utility | |-------------|--------|----------|------------------| | Variant Calling | DeepVariant | 99.7% | Diagnostic | | PRS Calculation | LDpred2 | AUC 0.72 | Risk stratification | | Gene Expression | Enformer | r=0.85 | Functional annotation | | Splice Prediction | SpliceAI | 0.95 | Pathogenicity | | Regulatory Effects | Basset | 0.82 | Variant interpretation |
import torch
import torch.nn as nn
import numpy as np
class VariantCaller(nn.Module):
def __init__(self, input_dim=4, hidden_dim=128, num_classes=3):
super().__init__()
self.conv1 = nn.Conv1d(input_dim, 64, kernel_size=7, padding=3)
self.conv2 = nn.Conv1d(64, 128, kernel_size=5, padding=2)
self.conv3 = nn.Conv1d(128, hidden_dim, kernel_size=3, padding=1)
self.bn1 = nn.BatchNorm1d(64)
self.bn2 = nn.BatchNorm1d(128)
self.bn3 = nn.BatchNorm1d(hidden_dim)
self.classifier = nn.Linear(hidden_dim, num_classes)
def forward(self, x):
x = torch.relu(self.bn1(self.conv1(x)))
x = torch.relu(self.bn2(self.conv2(x)))
x = torch.relu(self.bn3(self.conv3(x)))
x = x.mean(dim=-1)
return self.classifier(x)
def compute_prs(effect_sizes, genotypes, ld_matrix=None):
if ld_matrix is not None:
ld_inv = np.linalg.inv(ld_matrix + 0.01 * np.eye(len(ld_matrix)))
adjusted_effects = ld_inv @ effect_sizes
else:
adjusted_effects = effect_sizes
return np.sum(adjusted_effects * genotypes)
def one_hot_encode(sequence):
mapping = {'A': [1,0,0,0], 'C': [0,1,0,0], 'G': [0,0,1,0], 'T': [0,0,0,1]}
encoded = np.zeros((4, len(sequence)))
for i, base in enumerate(sequence):
if base in mapping:
encoded[:, i] = mapping[base]
return encoded
model = VariantCaller(input_dim=4, hidden_dim=128, num_classes=3)
x = torch.randn(1, 4, 1000)
output = model(x)
print(f'Variant calling output: {output.shape}')
sequence = "ACGTACGTACGT"
encoded = one_hot_encode(sequence)
print(f'One-hot encoded shape: {encoded.shape}')
Research Insight: Large language models trained on genomic sequences can predict variant effects without requiring labeled training data. These models learn the grammar of DNA sequences and can identify pathogenic variants by measuring the likelihood of a variant occurring under the learned distribution.