GENETICS CBD: powerpoint: genetic imprinting 1. genome 2. histone organization and modifications 3. genomic imprinting 4. prader-willi syndrome 5. angelman syndrome powerpoint: multifactorial congenital malformations 6. multifactorial congenital malformations definition 7. neuropsychiatric disorders and bipolar disease 8. coronary artery disease 9. modifier genes 10. digenic inheritance powerpoint: autosomal recessive inheritance 11. autosomal recessive inheritance definitikn 12. cystic fibrosis 13. marfan syndrome 14. phenylketonuria 15. major phenotypic features for cystic fibrosis powerpoint: chromosomal anomalies 16. chromosomal anomalies definition 17. down syndrome or mongolism 18. jacob’s syndrome 19. Y linked diseases 20. X linked diseases

Reading File

Give all information in details

Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Searching the Web

Jacob's syndrome XYY karyotype clinical features genetics Y-linked X-linked diseases examples

Searching the Web

Marfan syndrome genetics phenylketonuria PKU autosomal recessive inheritance features modifier genes digenic inheritance

Reading File
Reading File
Searching the Web

Marfan syndrome FBN1 fibrillin genetics autosomal dominant features aorta lens dislocation

Reading File
Reading File
Here is the complete, detailed content for all 20 topics across your four PowerPoint presentations:

POWERPOINT 1: GENETIC IMPRINTING


SLIDE 1 - THE GENOME

Definition The genome is the complete set of genetic instructions in a cell - the totality of DNA, including all protein-coding genes, non-coding sequences, regulatory elements, and repetitive sequences.
Key Figures
  • Human genome: ~3.2 billion base pairs
  • ~20,000-25,000 protein-coding genes
  • Protein-coding sequences = only ~1.5% of the total genome
  • ~98.5% is non-coding (introns, regulatory regions, repetitive DNA, transposons)
Genome Organization
  • Nuclear genome: 22 pairs of autosomes + 2 sex chromosomes = 46 chromosomes (diploid)
  • Mitochondrial genome: ~16,569 bp circular DNA (maternally inherited)
  • The genome is packaged into chromatin (DNA + histones + non-histone proteins)
Functional Divisions
ComponentFunction
ExonsProtein-coding sequences
IntronsNon-coding, removed during splicing
Promoters/EnhancersRegulate gene expression
Repetitive DNAStructural; some has regulatory roles
lncRNAs / miRNAsNon-coding RNA with regulatory functions
Genomic Variation
  • SNPs (single nucleotide polymorphisms): ~10 million in the human genome
  • CNVs (copy number variants): deletions/duplications >1kb; major source of inter-individual variation
  • Indels, microsatellites, transposable elements also contribute
Source: Thompson & Thompson Genetics and Genomics in Medicine, 9th ed.; Emery's Elements of Medical Genetics and Genomics

SLIDE 2 - HISTONE ORGANIZATION AND MODIFICATIONS

Chromatin Structure
  • DNA is wound around octamers of histone proteins (H2A, H2B, H3, H4 - 2 copies each) forming the nucleosome core particle
  • 147 bp of DNA wrap ~1.65 turns around each histone octamer
  • H1 linker histone seals the DNA at the exit/entry point and assists in higher-order compaction
  • Nucleosomes are further compacted into 30nm fibers, loops, and ultimately metaphase chromosomes
Levels of Chromatin
LevelStructureState
EuchromatinLoosely packed, bead-on-stringTranscriptionally active
HeterochromatinTightly compactedTranscriptionally silenced
Constitutive heterochromatinPermanently condensed (centromeres, telomeres)Always silent
Facultative heterochromatinConditionally silencedCan be reactivated
Histone Modifications (Epigenetic Marks) Histones have flexible N-terminal tails that project outward and can be covalently modified post-translationally:
ModificationEnzymeEffect on Transcription
Acetylation (H3K9ac, H3K27ac)Histone acetyltransferases (HATs)Activation - opens chromatin
DeacetylationHistone deacetylases (HDACs)Repression - closes chromatin
Methylation (H3K4me3)Histone methyltransferasesActivation (active promoters)
Methylation (H3K27me3, H3K9me3)PRC2, SUV39HRepression
Phosphorylation (H3S10)Aurora kinasesChromosome condensation during mitosis
Ubiquitination (H2BK120ub)RNF20/40Elongation of transcription
SumoylationSUMO ligasesRepression
Histone Code Hypothesis Combinations of modifications at multiple residues act as a "code" read by effector proteins to determine transcriptional output. For example:
  • H3K4me3 + H3K27ac = active transcription start site
  • H3K9me3 = constitutive heterochromatin
  • H3K27me3 = polycomb-mediated silencing
Clinical Relevance
  • Abnormal histone acetylation is common in malignancies
  • HDAC inhibitors (e.g., vorinostat, romidepsin) are used in cancer therapy
  • Loss of H3K27me3 marks is seen in diffuse midline gliomas (H3K27M mutation)
Source: Rheumatology 2-Volume Set 2022; Fitzpatrick's Dermatology; Harrison's Principles of Internal Medicine 22E

SLIDE 3 - GENOMIC IMPRINTING

Definition Genomic imprinting is an epigenetic phenomenon whereby a gene is expressed in a parent-of-origin-specific manner - meaning only the maternal allele or only the paternal allele is expressed in a given tissue, regardless of DNA sequence.
Key Mechanism: DNA Methylation
  • Methylation occurs primarily at CpG dinucleotides (cytosine-phosphate-guanine sites)
  • The imprint (methyl mark) is applied to specific DNA sequences during gametogenesis
  • Differentially Methylated Regions (DMRs) control which allele is silenced
  • Imprinting Control Regions (ICRs) coordinate expression across entire imprinted domains
Scale
  • Fewer than 200 human genes are imprinted (estimated)
  • Most are clustered in imprinted domains, some spanning >1 Mb
  • Key imprinted clusters: chromosome 15q11-q13, chromosome 11p15
How Imprinting Works
  1. During gametogenesis, the maternal and paternal alleles acquire different epigenetic marks (methylation patterns)
  2. After fertilization, the soma maintains these parent-specific marks through all cell divisions
  3. In the germline of the offspring, the parental imprints are erased and reset according to the sex of the new individual
Consequences of Imprinting Disruption
DisruptionResult
Deletion of paternal allele (chr 15)Prader-Willi syndrome
Deletion of maternal allele (chr 15)Angelman syndrome
Maternal UPD (chr 15)Prader-Willi syndrome
Paternal UPD (chr 15)Angelman syndrome
Paternal UPD (chr 11p)Beckwith-Wiedemann syndrome
Uniparental Disomy (UPD)
  • Uniparental disomy = both copies of a chromosome pair inherited from the same parent
  • Isodisomy: two identical copies (nondisjunction in meiosis II)
  • Heterodisomy: two different homologs from same parent (nondisjunction in meiosis I)
  • UPD for an imprinted chromosome has the same phenotypic effect as a deletion on the opposite parental chromosome
Source: Thompson & Thompson Genetics 9th ed., p.113-115; Emery's Elements of Medical Genetics; Tietz Textbook of Laboratory Medicine 7th ed.

SLIDE 4 - PRADER-WILLI SYNDROME (PWS)

Definition / Overview
  • Incidence: ~1 in 20,000 births
  • Result of loss of paternally expressed genes on chromosome 15q11.2-q13
Genetic Mechanisms
MechanismFrequency
Paternal deletion of 15q11.2-q13~70-75%
Maternal uniparental disomy (UPD) of chr 15~20-25%
Imprinting center (IC) defect~1-3%
Balanced chromosomal rearrangementrare
  • The SNRPN gene and adjacent snoRNA genes (SNURF/SNRPN cluster, MKRN3) are paternally expressed and lost in PWS
  • Functionally: patients only have maternally derived genetic information at 15q11-q13
Clinical Features
  • Neonatal period: marked hypotonia, feeding difficulties, failure to thrive
  • Infancy/childhood: hyperphagia (insatiable appetite) leading to progressive obesity
  • Short stature with small hands and feet
  • Hypogonadism (cryptorchidism in males; hypoplastic labia/clitoris in females)
  • Mild to moderate intellectual disability
  • Characteristic facial features: almond-shaped eyes, narrow bifrontal diameter, downturned mouth
  • Behavioral problems: temper tantrums, obsessive-compulsive behaviors, skin picking
Diagnosis
  • DNA methylation analysis of 15q11-q13 (SNRPN locus) - detects ~99% of cases
  • FISH or chromosomal microarray for deletion detection
  • MS-MLPA or microsatellite analysis for UPD
Source: Emery's Elements of Medical Genetics, p.79; Thompson & Thompson Genetics 9th ed., p.114; Henry's Clinical Diagnosis 35th ed.

SLIDE 5 - ANGELMAN SYNDROME (AS)

Definition / Overview
  • Incidence: ~1 in 15,000 births
  • Caused by loss of maternally expressed genes on chromosome 15q11-q13 - specifically UBE3A
Genetic Mechanisms
MechanismFrequency
Maternal deletion of 15q11.2-q13~75%
Paternal UPD of chr 15~5%
IC defect (imprinting center mutation)~2-3%
UBE3A point mutation~10%
Unknown mechanism~10%
Key Gene: UBE3A
  • Encodes ubiquitin-protein ligase E3A
  • Imprinted exclusively in the brain (hippocampus, Purkinje cells of cerebellum)
  • In the brain, only the maternal copy is expressed - the paternal copy is silenced by antisense RNA from the SNURF/SNRPN locus
  • Loss of maternal UBE3A = Angelman syndrome
  • Mechanism: ubiquitin-mediated protein destruction in CNS development is disrupted
Clinical Features (the "happy puppet" syndrome)
  • Severe intellectual disability
  • Absent or near-absent speech (severe expressive language deficit)
  • Epilepsy (seizures, often severe; EEG shows characteristic pattern)
  • Ataxic gait (unsteady, jerky movements)
  • Happy, excitable demeanor with frequent inappropriate laughter and smiling
  • Fascination with water
  • Microcephaly (postnatal)
  • Fair pigmentation (relative to family)
  • Wide-spaced teeth, tongue protrusion
  • Characteristic facial appearance: wide mouth, widely spaced teeth, large lower jaw
Differentiation from PWS
FeaturePrader-WilliAngelman
Chromosome 15Paternal deletion/lossMaternal deletion/loss
Key geneSNRPN clusterUBE3A
Intellectual disabilityMild-moderateSevere
ObesityYesNo
SeizuresRareProminent
BehaviorOCD, irritabilityHappy, excitable
SpeechPresent (reduced)Absent/minimal
Source: Emery's Elements of Medical Genetics, p.80; Thompson & Thompson Genetics 9th ed., p.114-115

POWERPOINT 2: MULTIFACTORIAL CONGENITAL MALFORMATIONS


SLIDE 6 - MULTIFACTORIAL CONGENITAL MALFORMATIONS: DEFINITION

Definition Multifactorial inheritance refers to conditions caused by the interaction of multiple genes (polygenic) with environmental factors. No single gene or environmental factor alone is sufficient to cause the malformation - it is the combined threshold effect that produces the phenotype.
Threshold Model
  • The underlying genetic liability follows a normal (Gaussian) distribution in the population
  • Individuals with liability exceeding a certain threshold develop the malformation
  • Different thresholds for males vs females explain sex differences in prevalence (e.g., pyloric stenosis is 5x more common in males; congenital dislocation of hip is more common in females)
Characteristics of Multifactorial Inheritance
  1. Recurrence risk is higher in first-degree relatives (siblings, parents, children) than the general population
  2. Risk drops rapidly with decreasing degree of relationship (unlike single-gene disorders)
  3. Risk is higher if multiple family members are affected
  4. Risk is higher if the proband is of the less commonly affected sex (Carter effect)
  5. More severe the malformation, higher the recurrence risk
  6. No clear Mendelian pattern
Common Multifactorial Congenital Malformations
MalformationApprox. Population Incidence (per 1000)
Cleft lip ± cleft palate0.4-1.7
Cleft palate alone0.4
Congenital dislocation of hip2 (per 1000 females)
Congenital heart defects (all types)4-8
Ventricular septal defect1.7
Atrial septal defect1.0
Patent ductus arteriosus0.5
Neural tube defects (spina bifida, anencephaly)2-10 (variable by region)
Pyloric stenosis5 (per 1000 males)
Congenital Heart Defects (CHD) - Special Focus CHDs are the most common serious birth defect. 5 main developmental subtypes:
  1. Flow lesions (~50% of all CHD): hypoplastic left heart, coarctation of aorta, ASDs, pulmonary stenosis, VSD
  2. Defects in cell migration
  3. Defects in cell death
  4. Abnormalities in extracellular matrix
  5. Defects in targeted growth
Source: Thompson & Thompson Genetics 9th ed., p.181-182; Emery's Elements of Medical Genetics; Robbins & Kumar Basic Pathology

SLIDE 7 - NEUROPSYCHIATRIC DISORDERS AND BIPOLAR DISEASE

Overview Mental illnesses affect ~4% of the human population worldwide. The two most severe categories are schizophrenia and bipolar disorder (manic-depressive illness). Annual cost of care >$200 billion/year in the US alone.
SCHIZOPHRENIA
  • Prevalence: 1% of the world's population
  • Onset: typically late adolescence or young adulthood
  • Features: disordered thought, emotion, social relationships; delusions; hallucinations; disordered mood
Genetic Evidence for Schizophrenia
RelationshipRecurrence Risk (%)Relative Risk (λ)
Child of two schizophrenic parents4623
Child of one affected parent9-1611.5
Sibling8-1411
Nephew / niece1-42.5
Uncle / aunt22
First cousin2-64
General population11
  • MZ twin concordance: 40-60%
  • DZ twin concordance: 10-16%
  • Chromosomal association: ~25% of individuals with 22q11 deletion (velocardiofacial syndrome) develop schizophrenia
BIPOLAR DISORDER (Manic-Depressive Illness)
  • Prevalence: ~1-2% worldwide
  • Characterized by cycles of mania and depression
  • Strong familial aggregation
  • MZ twin concordance: ~40-70%
  • DZ twin concordance: ~15-25%
  • Heritability: ~70-80%
  • First-degree relatives of bipolar patients: ~10-fold increased risk vs general population
Genetics of Bipolar Disorder
  • Polygenic, with hundreds to thousands of contributing variants
  • GWAS has identified loci in genes including: CACNA1C, ANK3, NCAN, TRANK1, SYNE1
  • Overlap with schizophrenia: shared genetic architecture (cross-disorder genetics)
  • De novo CNVs implicated in a subset of cases
  • Gene-environment interaction: childhood trauma, sleep disruption are key environmental triggers
Treatment Genetics
  • Lithium response is itself partly heritable (GWAS loci identified near GNG7, NCAN)
Source: Thompson & Thompson Genetics 9th ed., p.182-183

SLIDE 8 - CORONARY ARTERY DISEASE (CAD)

Definition Coronary artery disease is a complex, multifactorial disease caused by atherosclerosis of the coronary arteries. It is the leading cause of death globally.
Genetic Evidence
  • Heritability of fatal MI: ~56% (from twin studies)
  • MZ twin concordance for fatal MI: 39% (males), 44% (females)
  • DZ twin concordance for fatal MI: 26% (males), 14% (females)
  • A male MZ twin has a 6-8-fold increased risk if his co-twin had early fatal MI
  • A female MZ twin has a 15-fold increased risk
Stepwise Development - Genetic Factors at Each Stage Genes involved in:
  1. Lipid transport and metabolism - APOE, APOC3, LDLR (LDL receptor), LPA (lipoprotein(a))
    • Familial hypercholesterolemia: LDLR mutations (autosomal dominant) dramatically raise LDL and CAD risk
    • Elevated LDL is a quantitative trait with significant heritability
  2. Vasoactivity - ACE (angiotensin-converting enzyme), AGTR1
  3. Coagulation - Factor V Leiden (Factor V R506Q), prothrombin G20210A
  4. Inflammation - IL-6, CRP, TNF-alpha loci
  5. Endothelial function - NOS3 (endothelial nitric oxide synthase)
Environmental Factors (interact with genes)
  • Diet (saturated fat, trans fats)
  • Physical inactivity
  • Smoking
  • Obesity and diabetes mellitus
  • Systemic inflammation
GWAS Findings
  • Over 300 loci identified for CAD by genome-wide association studies
  • 9p21.3 locus: first and strongest replicated CAD risk locus; near CDKN2A/CDKN2B
  • Most individual loci confer small effects; aggregate polygenic risk scores (PRS) show clinical utility
Intermediate Traits
  • Hypertension, hyperlipidemia, diabetes, and obesity are all intermediate traits with their own genetic architectures that compound CAD risk
Source: Thompson & Thompson Genetics 9th ed., p.183-184; Goldman-Cecil Medicine

SLIDE 9 - MODIFIER GENES

Definition Modifier genes are genes whose allelic variants affect the expression, severity, or phenotypic manifestations of a disease caused by mutations in a different (primary) gene. They do not cause the disease themselves but modulate its course.
Concept
  • Even classic Mendelian single-gene disorders show variable expressivity partly due to modifier genes
  • Modifiers can affect: age of onset, severity of specific organ involvement, rate of progression, response to treatment
Classic Example: Cystic Fibrosis (CF) The primary gene is CFTR, but:
  • Pancreatic insufficiency: explained well by CFTR genotype (Class I/II mutations = severe)
  • Pulmonary disease severity: poorly explained by CFTR genotype alone
    • Heritability of lung disease severity (FEV1%) in CF: ~50% (from MZ vs DZ twin studies in CF patients)
    • Two confirmed modifier loci:
      1. MBL2 (mannose-binding lectin): Low MBL2 alleles → reduced innate immunity → worse Pseudomonas containment → worse pulmonary outcomes
      2. TGFB1 (transforming growth factor-beta): High TGFβ alleles → increased lung fibrosis after inflammation → worse FEV1 decline
Other Examples
Primary DiseaseModifier GeneEffect
Cystic fibrosisMBL2Pulmonary severity
Cystic fibrosisTGFB1Pulmonary severity
Sickle cell diseaseHBF (fetal hemoglobin regulators)Severity of crises
Familial hypercholesterolemiaAPOECardiovascular severity
Huntington diseaseMSH3 (DNA mismatch repair)Age of onset
Significance for Genetics Counseling
  • Same primary mutation can produce very different phenotypes in different patients
  • Modifier genes explain variable expressivity within families
  • Identification of modifier genes offers potential drug targets (e.g., targeting TGFβ pathway in CF)
Source: Thompson & Thompson Genetics 9th ed., p.185

SLIDE 10 - DIGENIC INHERITANCE

Definition Digenic inheritance is the simplest form of multigenic inheritance - a disease requires pathogenic mutations in two different genes (at two different loci) to manifest the full phenotype. Heterozygous variants at each locus alone are insufficient to cause disease; only the combination of both mutations causes the disease.
Characteristics
  • Neither mutation alone is disease-causing (each heterozygote is asymptomatic or subclinical)
  • Disease only appears when both mutations are inherited together
  • Pedigree analysis shows seemingly "autosomal recessive-like" or "sporadic" patterns
  • Can masquerade as de novo or complex disease
Classic Examples
  1. Digenic Retinitis Pigmentosa
    • Mutations in ROM1 + PRPH2 (peripherin) together cause RP
    • Heterozygous ROM1 alone = normal; heterozygous PRPH2 alone = normal
    • Compound heterozygotes for both = retinitis pigmentosa
  2. Digenic Waardenburg Syndrome Type III
    • Combination of PAX3 heterozygosity + MITF heterozygosity
  3. Bartter Syndrome Type V / Digenic BSND
  4. Bardet-Biedl Syndrome (triallelic/tridigenic)
    • Some cases involve mutations at two BBS loci
    • Illustrates extension to oligogenic inheritance
Inheritance Pattern
  • Parents who are each heterozygous at different loci are unaffected
  • Children who inherit both mutations (25% chance if parents carry at different loci) are affected
  • Distinguish from AR inheritance: AR requires two mutations at the same locus; digenic requires one mutation at each of two different loci
Clinical Significance
  • Explains sporadic cases in consanguineous families
  • Explains cases where only one parent is a carrier of a known disease mutation
  • Example from CF: a child had CF born to a couple where only the mother was a carrier - due to paternal UPD for chromosome 7 (not true digenic but similar principle)
  • Important for genomic sequencing interpretation: variants of uncertain significance at two loci may be acting diigenically
Source: Emery's Elements of Medical Genetics (citing Schäffer AA, J Med Genet 2013); Thompson & Thompson Genetics 9th ed.

POWERPOINT 3: AUTOSOMAL RECESSIVE INHERITANCE


SLIDE 11 - AUTOSOMAL RECESSIVE INHERITANCE: DEFINITION

Definition Autosomal recessive (AR) inheritance is the pattern in which two pathogenic alleles (one from each parent) at the same autosomal locus are required for the phenotype to be expressed. Heterozygous individuals ("carriers") are clinically unaffected.
Key Characteristics of AR Inheritance
  1. Both sexes affected equally - the gene is autosomal, not sex-linked
  2. Parents of an affected individual are typically unaffected carriers (Aa x Aa)
  3. Carrier × Carrier cross yields:
    • 25% homozygous affected (aa)
    • 50% heterozygous carriers (Aa) - unaffected
    • 25% homozygous normal (AA) - unaffected
  4. Horizontal pattern: affected individuals appear in one generation (siblings), not vertical across generations
  5. Consanguinity increases risk: related parents share more alleles identical by descent (IBD)
  6. Rare diseases are enriched in isolated or consanguineous populations
Pedigree Rules
  • Unaffected parents → affected child = AR (not AD)
  • Skip generations is typical
  • Both sexes affected equally (unlike X-linked)
  • If parents are related → think AR
Molecular Basis
  • Homozygous loss-of-function: both alleles produce non-functional protein (most common)
  • Compound heterozygosity: two different pathogenic alleles at the same locus (e.g., one deletion + one missense)
  • Pseudodominance: can appear dominant if carrier marries affected individual
Carrier Frequency Estimation Using Hardy-Weinberg equilibrium:
  • If disease frequency = q² (e.g., CF: 1/2500), then q = 1/50
  • Carrier frequency = 2pq ≈ 2q = 1/25 (approximately 4% in Northern Europeans)
Source: Goldman-Cecil Medicine; Basic Medical Biochemistry 6th ed.; Dermatology 2-Volume Set 5th ed.

SLIDE 12 - CYSTIC FIBROSIS

Definition Cystic fibrosis is the most common life-shortening autosomal recessive genetic disease in White (Northern European) populations. It is caused by absent or reduced function of the CFTR (Cystic Fibrosis Transmembrane conductance Regulator) protein.
Genetics
  • Gene: CFTR (chromosome 7q31.2)
  • CFTR protein: 1480 amino acids; ABC (ATP-binding cassette) transporter superfamily
  • Most common mutation: F508del (deletion of phenylalanine at position 508, codon 508) - present in ~70% of all CF patients (at least one allele)
  • Over 2000 CFTR variants identified
CFTR Mutation Classes
ClassDefectCommon Mutations
INo synthesis / premature stopW1282X, G542X, R563X
IIProtein misfolding / degradationF508del, N1303K
IIIDefective gating / regulationG551D, G551S, G1349D
IVReduced chloride conductanceR117H, R334W, R347P
VReduced transcription / splicing3849+10kbC→T
VIUnstable protein / reduced surface expression4326delTC
Epidemiology
  • Northern Europe / Americas: 1:2,500-3,000 live births
  • US prevalence: ~1:10,000 (~35,000 cases)
  • Hispanic Americans: ~1:7,000
  • African Americans: ~1:12,000
  • Rare in Africa and Asia
Pathophysiology by Organ System
Lungs:
  • CFTR normally secretes Cl⁻/HCO₃⁻ into airway lumen while reducing Na⁺ absorption
  • In CF: reduced Cl⁻/HCO₃⁻ secretion + increased Na⁺ absorption → airway surface dehydration
  • Dehydrated, thick mucus → impaired mucociliary clearance → mucus plugging
  • Chronic bacterial infection: Staphylococcus aureus (early), Pseudomonas aeruginosa (later, most damaging)
  • Biofilm formation → antibiotic resistance
  • Chronic neutrophil inflammation → elastase release → bronchiectasis, airway destruction
Sweat Glands:
  • Sweat Cl⁻ ≥60 mEq/L (diagnostic threshold)
  • Normal: <20 mEq/L
  • Mechanism: CFTR normally reabsorbs NaCl as sweat travels to skin; lost in CF → isotonic sweat
Pancreas:
  • Exocrine pancreas: ducts cannot secrete bicarbonate/chloride → viscous secretions → autodigestion
  • Pancreatic insufficiency → malabsorption, fat-soluble vitamin deficiency (A, D, E, K)
  • Endocrine pancreas: progressive fibrosis → CF-related diabetes mellitus (CFRD)
Liver:
  • Biliary canaliculi obstruction → hepatic fibrosis → cirrhosis in ~5% of patients
Intestine:
  • Meconium ileus in newborns (15-20%)
  • Distal intestinal obstruction syndrome (DIOS) in older patients
Reproductive:
  • Males: congenital bilateral absence of vas deferens (CBAVD) → obstructive azoospermia → infertility (>95%)
  • Females: thick cervical mucus → reduced fertility
Source: Goldman-Cecil Medicine, p.3231-3290; Medical Physiology; Harrison's Principles 22E

SLIDE 13 - MARFAN SYNDROME

Note: Marfan syndrome is actually an autosomal dominant disorder. It is included here for comparison and to illustrate how a single-gene connective tissue disorder can present.
Definition Marfan syndrome (MFS) is an autosomal dominant connective tissue disorder with pleiotropic manifestations affecting primarily the cardiovascular, skeletal, and ocular systems.
Genetics
  • Gene: FBN1 (fibrillin-1), chromosome 15q21.1
  • Inheritance: Autosomal dominant (heterozygous pathogenic variant sufficient)
  • ~75% of cases: inherited from affected parent
  • ~25%: de novo mutation in a parent's egg or sperm
  • FBN1 encodes the glycoprotein fibrillin-1, a major building block of extracellular microfibrils
Pathophysiology
  • Fibrillin-1 is required for:
    1. Structural integrity of the aortic wall, lens zonules, ligaments, lung airways, spinal dura
    2. Regulation of TGF-β bioavailability (fibrillin sequesters TGF-β in ECM)
  • Mutant fibrillin-1 → weakened microfibrils → structural fragility + excess TGF-β signaling → aortic wall degradation and progressive dilatation
Cardinal Clinical Features (Ghent Criteria 2010) Cardiovascular (most dangerous):
  • Aortic root dilatation/aneurysm (Z-score ≥2.0) - most dangerous
  • Aortic dissection (Type A - emergency)
  • Mitral valve prolapse with/without regurgitation
  • Pulmonary artery dilatation
Ocular:
  • Ectopia lentis (lens subluxation) - upward displacement in 50-80%
  • High myopia
  • Increased risk of retinal detachment, glaucoma, cataracts
Skeletal:
  • Tall stature with disproportionately long limbs (dolichostenomelia)
  • Arachnodactyly (long, spider-like fingers; positive wrist and thumb signs)
  • Pectus excavatum or carinatum
  • Scoliosis
  • High, narrow palate
  • Flat feet
  • Joint hypermobility
Other:
  • Dural ectasia (widening of dural sac at lumbar spine)
  • Stretch marks (striae atrophicae)
  • Spontaneous pneumothorax
Diagnosis (Ghent 2010) Any one of:
  • Aortic root dilatation + ectopia lentis
  • Aortic root dilatation + FBN1 pathogenic variant
  • Ectopia lentis + FBN1 pathogenic variant (associated with aortic disease)
  • Systemic score ≥7 + aortic disease
Management
  • Beta-blockers (atenolol) or losartan (anti-TGF-β) to slow aortic dilatation
  • Elective aortic root repair when diameter reaches 4.5-5.0 cm
  • Annual echocardiography
  • Contact sports and high-intensity exercise restriction
Source: GeneReviews NBK1335; Medscape; Emery's Elements of Medical Genetics

SLIDE 14 - PHENYLKETONURIA (PKU)

Definition Phenylketonuria (PKU) is an autosomal recessive inborn error of phenylalanine metabolism caused by deficiency of the enzyme phenylalanine hydroxylase (PAH). It leads to accumulation of phenylalanine in blood, brain, and CSF.
Genetics
  • Gene: PAH (phenylalanine hydroxylase), chromosome 12q23.2
  • AR inheritance: homozygous or compound heterozygous PAH mutations required
  • Gene structure: 90 kb, 13 exons, 1359 bp coding sequence → 452 amino acid protein (52 kDa)
  • Over 1000 PAH variants described; classic PKU typically due to severe loss-of-function mutations
  • Rare variant: Tetrahydrobiopterin (BH4) deficiency → similar phenotype (hyperphenylalaninemia)
Epidemiology
  • Global prevalence: ~1:24,000 births
  • Regional variation: Turkey highest (~38:100,000); Eastern Europe ~1:7,000; US ~1:10,000-15,000; Thailand lowest (~0.3:100,000)
Biochemical Defect
  • Normal: phenylalanine → tyrosine (via PAH + cofactor BH4)
  • In PKU: PAH absent/deficient → phenylalanine accumulates → converted to phenylpyruvate, phenylacetate, phenyllactate
  • These metabolites are neurotoxic; phenylalanine competes with other large neutral amino acids at the blood-brain barrier
Clinical Phenotypes (without treatment)
PhenotypePlasma Phe (µmol/L)Intelligence Impact
Classic PKU>1200Severe intellectual disability
Moderate PKU600-1200Moderate ID
Mild PKU360-600Mild cognitive effects
Benign hyperphenylalaninemia<360Minimal/none
Untreated Features
  • Profound intellectual disability (IQ <50)
  • Epilepsy/seizures
  • Microcephaly (acquired)
  • Behavioral disorders (hyperactivity, autism-like behaviors)
  • Generalized hypopigmentation (reduced tyrosine → reduced melanin): blue eyes, fair hair, fair skin
  • Eczema
  • Mousy/musty odor (phenylacetate in urine and sweat)
Newborn Screening
  • Guthrie test (bacterial inhibition assay) → now replaced by tandem mass spectrometry (MS/MS)
  • Heel-prick blood spot on day 2-5 of life
Treatment
  • Low-phenylalanine diet (lifelong): restrict high-protein foods (meat, dairy, nuts, wheat)
  • Use of phenylalanine-free amino acid formula supplements
  • Sapropterin (BH4 analog, Kuvan): effective in BH4-responsive phenotypes (~30-50% of patients)
  • Pegvaliase (PEGylated phenylalanine ammonia lyase): for adults with classic PKU poorly controlled
  • Maternal PKU: women with PKU must control Phe strictly during pregnancy to prevent fetal teratogenesis (maternal PKU syndrome: microcephaly, cardiac defects, IUGR in fetus)
Source: Goldman-Cecil Medicine; Basic Medical Biochemistry 6th ed.; PubMed PMC9295449

SLIDE 15 - MAJOR PHENOTYPIC FEATURES OF CYSTIC FIBROSIS

Summary of Major Phenotypic Features
1. Pulmonary Disease (most common cause of death - ~90% of mortality)
  • Chronic cough, wheeze, dyspnea
  • Recurrent respiratory infections:
    • Early: Staphylococcus aureus (including MRSA)
    • Established: Pseudomonas aeruginosa (mucoid biofilm)
    • Also: Burkholderia cepacia complex, Stenotrophomonas, Achromobacter
  • Bronchiectasis (permanent, irreversible airway dilatation)
  • Air trapping, hyperinflation
  • Hemoptysis
  • Progressive respiratory failure, cor pulmonale
  • Pneumothorax
2. Pancreatic Disease
  • Exocrine pancreatic insufficiency (85-90% of patients): malabsorption (fat, protein), steatorrhea, fat-soluble vitamin deficiency (A, D, E, K)
  • Pancreatitis (in pancreatic-sufficient patients with milder mutations)
  • CF-related diabetes mellitus (CFRD) - develops in 20% by age 30, >50% by age 50
3. Sweat Glands
  • Elevated sweat chloride ≥60 mEq/L
  • Salt-wasting in hot weather → hyponatremic, hypochloremic, hypokalemic alkalosis
  • "Salty tasting skin" - classic parental complaint in infants
4. Liver/Biliary
  • Focal biliary cirrhosis (5-10% develop clinical liver disease)
  • Portal hypertension, varices
  • Gallstones (30% of adults)
5. Gastrointestinal
  • Meconium ileus at birth (15-20%): bowel obstruction in newborn
  • Distal intestinal obstruction syndrome (DIOS): equivalent of meconium ileus in older patients
  • Rectal prolapse (young children)
  • GERD, esophagitis
6. Reproductive
  • Males: CBAVD (congenital bilateral absence of vas deferens) → obstructive azoospermia → infertility (>95% of males with CF)
  • Females: reduced fertility (thick cervical mucus); pregnancy possible with modern treatment
7. Musculoskeletal
  • Short stature, delayed puberty
  • Reduced bone mineral density, osteoporosis (vitamin D malabsorption)
  • CF arthropathy
8. Sinuses
  • Chronic sinusitis (virtually all patients)
  • Nasal polyps (10-40%)
9. Clubbing of Digits
  • Sign of chronic hypoxia and bronchiectasis
Newborn Screening
  • Elevated immunoreactive trypsinogen (IRT) → confirmation with sweat chloride test + CFTR genotyping
Diagnostic Criteria
  • Sweat Cl⁻ ≥60 mEq/L on two occasions, OR
  • Two pathogenic CFTR mutations, OR
  • Abnormal nasal potential difference (NPD)
  • Plus at least one characteristic clinical feature or family history or positive newborn screen
Source: Goldman-Cecil Medicine p.3231-3290; Harrison's Principles of Internal Medicine 22E

POWERPOINT 4: CHROMOSOMAL ANOMALIES


SLIDE 16 - CHROMOSOMAL ANOMALIES: DEFINITION

Definition Chromosomal anomalies (chromosomal disorders) are conditions caused by abnormalities in chromosome number, structure, or both. They affect large segments of DNA and typically involve many genes simultaneously.
Classification of Chromosomal Anomalies
A. Numerical Abnormalities (Aneuploidy)
TypeDefinitionExample
Monosomy (2n-1)Loss of one chromosome45,X (Turner syndrome)
Trisomy (2n+1)Extra chromosome47,+21 (Down syndrome)
TetrasomyTwo extra chromosomes of same type48,XXXX
PolyploidyComplete extra setTriploidy (69, XXX) - lethal
B. Structural Abnormalities
TypeDefinitionExample
DeletionLoss of chromosomal segment5p- (Cri-du-chat)
DuplicationExtra copy of segmentDup 17p11.2 (CMT1A)
InversionReversed segmentinv(9)
Translocation - RobertsonianFusion of two acrocentricsrob(14;21) in Down syndrome
Translocation - ReciprocalExchange between non-homologous chromosomest(9;22) (Philadelphia chromosome)
Ring chromosomeEnd-to-end fusion of chromosome armsr(X)
IsochromosomeDuplication of one arm, mirror imagei(17q) in medulloblastoma
C. Special Categories
CategoryMechanismExample
Uniparental disomyBoth homologs from one parentPrader-Willi, Angelman
MosaicismTwo or more different cell linesMosaic Down syndrome
Genomic imprinting disordersAbnormal epigenetic regulationPWS/AS
Causes of Chromosomal Anomalies
  • Nondisjunction: failure of chromosomes to separate during meiosis or mitosis
    • Most common cause of trisomy
    • Meiosis I error: produces two chromosomes (heterodisomy)
    • Meiosis II error: produces identical duplicates (isodisomy)
  • Advanced maternal age: strongly associated with increased risk of nondisjunction for most trisomies
  • Chromosome breakage / translocation errors
Frequency
  • ~1 in 160 live births have a chromosomal abnormality
  • Chromosomal abnormalities are the most common known genetic cause of pregnancy loss (~50% of spontaneous abortions)
Source: Thompson & Thompson Genetics 9th ed.; Emery's Elements of Medical Genetics; Robbins & Kumar Pathologic Basis of Disease

SLIDE 17 - DOWN SYNDROME (MONGOLISM / TRISOMY 21)

Definition Down syndrome is the most common chromosomal disorder in humans and a major cause of intellectual disability. It is caused by trisomy of chromosome 21.
Incidence and Karyotypes
KaryotypeMechanismFrequency
47,XX or XY,+21 (Trisomy 21)Meiotic nondisjunction~95%
46 with Robertsonian translocation (e.g., 46,rob(14;21))Chromosomal translocation~4%
Mosaic (46/47 mixed lines)Mitotic nondisjunction in early embryo~1%
Incidence
  • Overall: 1 in 700 live births (United States)
  • Age 20 mothers: 1 in 1550 live births
  • Age 45 mothers: 1 in 25 live births
  • In 95% of trisomy 21: extra chromosome is of maternal origin
  • Extra chromosome 21 is maternally derived in 95% of cases; origin from failed meiotic separation
Characteristic Clinical Features Facial/Head:
  • Flat facial profile / flat occiput (brachycephaly)
  • Epicanthal folds
  • Upslanting palpebral fissures (mongoloid slant)
  • Brushfield spots on iris
  • Small ears, small mouth
  • Macroglossia (large tongue)
  • Single palmar crease (simian crease) - 50%
CNS / Development:
  • Moderate to mild intellectual disability (IQ typically 40-70)
  • Hypotonia (universal at birth)
  • Delayed developmental milestones
Cardiac (40% of patients):
  • Atrioventricular septal defect (AVSD): 43%
  • Ventricular septal defect: 32%
  • Atrial septal defect: 19%
  • Tetralogy of Fallot: 6%
  • Cardiac defects = most common cause of death in infancy
Gastrointestinal:
  • Duodenal atresia ("double bubble" on X-ray)
  • Hirschsprung disease
  • Esophageal atresia
Hematological:
  • 20-fold increased risk of precursor B-cell ALL (acute lymphoblastic leukemia)
  • 500-fold increased risk of AML (acute myeloid leukemia)
  • Transient myeloproliferative disorder in neonates (GATA1 mutation)
Immunological:
  • Defective T-cell function → susceptibility to respiratory infections
  • Autoimmune thyroiditis (hypothyroidism) in 15-20%
  • Celiac disease association
Neurodegeneration:
  • Alzheimer disease in virtually all patients with trisomy 21 by age 40: chromosome 21 carries the APP gene (amyloid precursor protein); 3 copies → overproduction of amyloid-β
Other:
  • Short stature
  • Clinodactyly (incurved 5th finger)
  • Wide gap between 1st and 2nd toes
  • Increased risk of atlanto-axial instability
Life Expectancy
  • Median age at death: 47 years (was 25 years in 1983)
  • Improved with better cardiac surgery and infection management
Prenatal Screening
  • Cell-free DNA (cfDNA) / NIPT: detects trisomy 21 with >99% sensitivity in high-risk pregnancies
  • First trimester: nuchal translucency + PAPP-A + beta-hCG
  • Second trimester: triple/quad screen (AFP, hCG, uE3, inhibin A)
  • Definitive diagnosis: amniocentesis or CVS with karyotyping
Source: Robbins & Kumar Pathologic Basis of Disease, p.163-165; Thompson & Thompson Genetics 9th ed., p.102-106; Emery's Elements of Medical Genetics

SLIDE 18 - JACOB'S SYNDROME (47, XYY)

Definition Jacob's syndrome (XYY syndrome) is a sex chromosome aneuploidy in which a genetic male has an additional Y chromosome, resulting in a 47,XYY karyotype.
Incidence
  • 1 in 1000 male births
  • ~5-10 boys with XYY born per day in the US
  • Many individuals are never diagnosed
Cause
  • Usually caused by nondisjunction during paternal meiosis II (failure of Y chromatids to separate)
    • Results in a YY sperm that fertilizes an X-bearing egg
  • Less commonly: mitotic nondisjunction during early embryonic development → mosaicism (46,XY/47,XYY)
  • The extra Y chromosome is always of paternal origin (100% paternal in origin - Table 3.4 from Emery's)
Clinical Features The phenotype is highly variable; many individuals have no significant findings.
Physical:
  • Tall stature (typically >6'3"/1.88m at final height)
  • Macrocephaly
  • Widely spaced eyes (orbital hypertelorism)
  • Weak muscle tone (hypotonia)
  • Clinodactyly of 5th finger
  • Macrodontia (larger-than-normal teeth)
  • Flat feet (pes planus)
  • Scoliosis
  • Underbite
  • Macroorchidism
Neurodevelopmental:
  • Intelligence generally within normal range, but slightly lower than siblings on average
  • Learning disabilities: language delay, reading difficulties (dyslexia)
  • Delayed motor development
  • ADHD
  • Autism spectrum disorder (increased risk)
  • Anxiety and depression
Behavioral:
  • Impulse control difficulties
  • Emotional dysregulation
  • Early studies in incarcerated males suggested link to aggression (largely discredited)
  • Increased risk for antisocial behavior but not criminal behavior per se
Medical:
  • Asthma (increased incidence)
  • Seizures/tremors
  • Genitourinary anomalies in some: cryptorchidism, hypospadias, micropenis
  • Infertility possible: oligospermia or sperm chromosomal abnormalities; many reproduce normally
Diagnosis
  • Prenatal: NIPT, amniocentesis, CVS
  • Postnatal: karyotype from blood lymphocytes
  • Median age of diagnosis ~17 years (often presenting with infertility concerns)
Management
  • Primarily supportive
  • Early speech/language therapy
  • Educational interventions for learning difficulties
  • Behavioral therapy
  • Occupational therapy for motor delays
  • Annual monitoring for tall stature complications (scoliosis)
Source: Cleveland Clinic; NCBI Books NBK557699; Medline Plus; Emery's Elements of Medical Genetics (Table 3.4)

SLIDE 19 - Y-LINKED DISEASES

Y-Linked (Holandric) Inheritance
  • Genes located on the Y chromosome are transmitted exclusively from father to son
  • Only males are affected
  • All sons of an affected male are affected; no daughters are affected
  • No female carriers
Y Chromosome Structure The Y chromosome is divided into:
  1. Pseudoautosomal regions (PAR1 and PAR2): pair with X chromosome during meiosis; genes here are NOT Y-linked exclusively
  2. Male-specific Y region (MSY): non-recombining region containing truly Y-specific genes
Truly Y-Linked (Holandric) Genes
GeneLocationFunctionDisease
SRYYp11.3Sex-determining region Y; initiates male sex determinationMutations → 46,XY sex reversal (female phenotype)
AZF (Azoospermia Factor) loci (AZFa, AZFb, AZFc)Yq11.2SpermatogenesisMicrodeletions → azoospermia / severe oligospermia → male infertility
DAZ (Deleted in Azoospermia)Yq11RNA binding in germ cellsDAZ deletions → azoospermia
RBMYYq11RNA binding; spermatogenesisDeletion → male infertility
USP9YYq11Ubiquitin-specific proteaseDeletions associated with infertility
Clinical Significance of Y Chromosome Microdeletions
  • Prevalence: ~7-10% of azoospermic men; ~5% of severely oligospermic men
  • AZFa deletion: Sertoli-cell-only syndrome (no germ cells); TESE unlikely to retrieve sperm
  • AZFb deletion: spermatogenic arrest; TESE unlikely to retrieve sperm
  • AZFc deletion: most common; variable severity; TESE often successful
Y-Linked Inherited Hairy Ears (Hypertrichosis Pinnae)
  • Classical teaching example of holandric trait
  • Father-to-all-sons transmission
  • Now debated whether truly Y-linked vs autosomal
Klinefelter Syndrome (47,XXY)
  • Not truly Y-linked, but involves extra sex chromosome
  • 1 in 500-1000 male births
  • Features: tall stature, small testes, azoospermia, gynecomastia, reduced testosterone, learning difficulties
  • Karyotype: 47,XXY (most common), or XXYY, XXXY, XXXXY (increasingly severe)
Source: Emery's Elements of Medical Genetics; Thompson & Thompson Genetics 9th ed.; NCBI/GeneReviews

SLIDE 20 - X-LINKED DISEASES

X-Linked Inheritance Principles Genes on the X chromosome follow hemizygous expression in males (one copy → full expression of recessive alleles). Females have two X chromosomes, so X-linked recessive alleles are typically masked by the normal allele unless the female is homozygous or a manifesting carrier (due to X-inactivation skewing).
X-Linked Recessive (XLR) - Rules
  1. Predominantly affects males
  2. Females are usually carriers (heterozygous, asymptomatic or mildly affected)
  3. Carrier mother → 50% of sons affected, 50% of daughters carriers
  4. Affected father → all daughters are carriers, no sons affected (father passes Y to sons)
  5. No male-to-male transmission (key distinguishing feature from AD)
  6. Rare affected females: Turner syndrome (45,X), homozygous XLR, skewed X-inactivation
Major X-Linked Recessive Diseases
DiseaseGeneChromosomeKey Features
Duchenne Muscular DystrophyDMD (dystrophin)Xp21.2Progressive muscle wasting from childhood; Gowers' sign; CK elevated; wheelchair-bound by teens; dilated cardiomyopathy
Becker Muscular DystrophyDMD (in-frame)Xp21.2Milder course than DMD
Hemophilia AF8 (Factor VIII)Xq28Severe bleeding; hemarthroses; reduced/absent FVIII activity
Hemophilia B (Christmas disease)F9 (Factor IX)Xq27.1Similar to Hemophilia A; reduced FIX activity
Color blindness (red-green)OPN1LW / OPN1MWXq28Most common XL condition; affects ~8% males
Fragile X SyndromeFMR1 (CGG repeat expansion)Xq27.3Most common inherited cause of intellectual disability; triplet repeat expansion; macroorchidism, large ears, autism
Fabry DiseaseGLA (alpha-galactosidase A)Xq22Lysosomal storage; angiokeratomas, acroparesthesia, renal failure, cardiac disease
G6PD DeficiencyG6PDXq28Hemolytic anemia triggered by drugs, infections, fava beans
Lesch-Nyhan SyndromeHPRT1Xq26Gout, intellectual disability, self-mutilation; HGPRT deficiency
Chronic Granulomatous DiseaseCYBB (gp91-phox)Xp21.1Recurrent catalase-positive infections; NBT test negative
Androgen Insensitivity Syndrome (AIS)AR (androgen receptor)Xq11-1246,XY female phenotype (complete AIS); pseudohermaphroditism
Wiskott-Aldrich SyndromeWASXp11.23Triad: eczema, thrombocytopenia, immunodeficiency
X-linked Agammaglobulinemia (XLA)BTK (Bruton's tyrosine kinase)Xq21.33Absent B cells; recurrent bacterial infections
Hunter Syndrome (MPS II)IDSXq28Lysosomal storage (iduronate sulfatase deficiency)
Menkes DiseaseATP7AXq21.1Copper transport defect; kinky hair, neurodegeneration
X-Linked Dominant (XLD) Diseases Less common; both males and females affected; males often more severely or lethally affected.
DiseaseGeneFeatures
Rett SyndromeMECP2Progressive neurological disorder; almost exclusively females (males die in utero)
Incontinentia PigmentiIKBKGSkin, dental, CNS, eye abnormalities; males die in utero
Hypophosphatemic Rickets (XLH)PHEXPhosphate-wasting rickets; affects both sexes
Vitamin D-resistant ricketsPHEXBone disease; dominant; females less severely affected
Lyon Hypothesis (X-Inactivation)
  • In females, one X chromosome in each somatic cell is randomly inactivated (Barr body)
  • Inactivation occurs at ~16 days post-fertilization
  • Inactivation is irreversible and clonally maintained
  • Normally, ~50% paternal X / ~50% maternal X inactivated
  • Skewed X-inactivation (>90:10): can cause manifesting carriers of X-linked recessive diseases (e.g., carrier female with hemophilia A who bleeds)
Source: Emery's Elements of Medical Genetics; Thompson & Thompson Genetics 9th ed.; Robbins & Kumar Pathologic Basis of Disease; Goldman-Cecil Medicine

SUMMARY TABLE: THE 4 POWERPOINTS AT A GLANCE

PPTTopicsKey Concept
1 - Genetic ImprintingGenome, Histones, Imprinting, PWS, AngelmanParent-of-origin gene expression via DNA methylation
2 - Multifactorial MalformationsDefinition, Neuropsychiatric, CAD, Modifier Genes, DigenicThreshold model; gene-gene-environment interactions
3 - Autosomal RecessiveAR definition, CF, Marfan, PKU, CF phenotypeTwo-hit recessive model; consanguinity; biochemical defects
4 - Chromosomal AnomaliesDefinitions, Down, Jacob's, Y-linked, X-linkedAneuploidy, structural rearrangements, sex-chromosome disorders
Key Textbook Sources:
  • Thompson & Thompson Genetics and Genomics in Medicine, 9th ed.
  • Emery's Elements of Medical Genetics and Genomics
  • Robbins & Kumar Pathologic Basis of Disease
  • Goldman-Cecil Medicine, International Edition
  • Harrison's Principles of Internal Medicine, 22nd ed.
  • Basic Medical Biochemistry - A Clinical Approach, 6th ed.

Generate PowerPoint presentations for all 4 topics with slides, diagrams, and references

Reading File
Reading File
Reading File
Running Command

mkdir -p /tmp/workspace/genetics-cbd && ls /tmp/workspace/

Writing File

~/genetics-cbd/make_ppt1.py

"""PPT 1: Genetic Imprinting - 7 slides with diagrams"""
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

# ── colour palette ──────────────────────────────────────────────────────────
C_NAVY   = RGBColor(0x0D, 0x2B, 0x6E)   # deep navy
C_TEAL   = RGBColor(0x00, 0x7B, 0x8A)   # teal accent
C_LIME   = RGBColor(0x6A, 0xB1, 0x87)   # soft green
C_ORANGE = RGBColor(0xE8, 0x8B, 0x2E)   # amber
C_WHITE  = RGBColor(0xFF, 0xFF, 0xFF)
C_LIGHT  = RGBColor(0xF0, 0xF6, 0xFB)   # pale-blue bg
C_DARK   = RGBColor(0x1A, 0x1A, 0x2E)   # near-black text
C_RED    = RGBColor(0xC0, 0x39, 0x2B)
C_GOLD   = RGBColor(0xF5, 0xCB, 0x5C)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide, color=C_LIGHT):
    bg = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0,
                                prs.slide_width, prs.slide_height)
    bg.fill.solid(); bg.fill.fore_color.rgb = color
    bg.line.fill.background(); bg.shadow.inherit = False

def header_bar(slide, title, subtitle="", bar_color=C_NAVY):
    bar = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0,
                                 prs.slide_width, Inches(1.25))
    bar.fill.solid(); bar.fill.fore_color.rgb = bar_color
    bar.line.fill.background(); bar.shadow.inherit = False
    tb = slide.shapes.add_textbox(Inches(0.3), Inches(0.05), Inches(12), Inches(0.7))
    tf = tb.text_frame; tf.word_wrap = False
    p = tf.paragraphs[0]; p.text = title
    r = p.runs[0]; r.font.size = Pt(28); r.font.bold = True
    r.font.color.rgb = C_WHITE; r.font.name = "Calibri"
    if subtitle:
        tb2 = slide.shapes.add_textbox(Inches(0.35), Inches(0.78), Inches(12), Inches(0.45))
        tf2 = tb2.text_frame
        p2 = tf2.paragraphs[0]; p2.text = subtitle
        r2 = p2.runs[0]; r2.font.size = Pt(15); r2.font.color.rgb = C_GOLD
        r2.font.name = "Calibri"; r2.font.bold = False

def txt_box(slide, text, x, y, w, h, size=14, bold=False,
            color=C_DARK, align=PP_ALIGN.LEFT, wrap=True, italic=False):
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame; tf.word_wrap = wrap
    p = tf.paragraphs[0]; p.text = text; p.alignment = align
    r = p.runs[0]; r.font.size = Pt(size); r.font.bold = bold
    r.font.color.rgb = color; r.font.name = "Calibri"; r.font.italic = italic
    return tb

def add_bullet_box(slide, items, x, y, w, h, title=None,
                   box_color=C_WHITE, title_color=C_NAVY, item_size=13, title_size=15):
    box = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(x), Inches(y), Inches(w), Inches(h))
    box.fill.solid(); box.fill.fore_color.rgb = box_color
    box.line.color.rgb = C_TEAL; box.line.width = Pt(1.5); box.shadow.inherit = False
    dy = y + 0.15
    if title:
        txt_box(slide, title, x+0.15, dy, w-0.3, 0.4, size=title_size, bold=True, color=title_color)
        dy += 0.4
    for item in items:
        txt_box(slide, f"  {item}", x+0.1, dy, w-0.2, 0.38, size=item_size, color=C_DARK)
        dy += 0.36

def color_box(slide, text, x, y, w, h, bg_c, txt_c=C_WHITE, size=13, bold=False):
    shp = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                                 Inches(x), Inches(y), Inches(w), Inches(h))
    shp.fill.solid(); shp.fill.fore_color.rgb = bg_c
    shp.line.fill.background(); shp.shadow.inherit = False
    tf = shp.text_frame; tf.word_wrap = True
    tf.vertical_anchor = MSO_ANCHOR.MIDDLE
    p = tf.paragraphs[0]; p.text = text; p.alignment = PP_ALIGN.CENTER
    r = p.runs[0]; r.font.size = Pt(size); r.font.color.rgb = txt_c
    r.font.bold = bold; r.font.name = "Calibri"

def footer(slide, ref):
    line = slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
        Inches(0.3), Inches(7.15), Inches(13), Inches(7.15))
    line.line.color.rgb = C_TEAL; line.line.width = Pt(1)
    txt_box(slide, ref, 0.3, 7.18, 12.7, 0.3, size=9, italic=True, color=RGBColor(0x55,0x55,0x55))

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 0 – TITLE SLIDE
# ════════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl, C_NAVY)
# decorative bar
dec = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.8), prs.slide_width, Inches(0.08))
dec.fill.solid(); dec.fill.fore_color.rgb = C_TEAL; dec.line.fill.background(); dec.shadow.inherit=False
dec2 = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.88), prs.slide_width, Inches(0.04))
dec2.fill.solid(); dec2.fill.fore_color.rgb = C_GOLD; dec2.line.fill.background(); dec2.shadow.inherit=False

txt_box(sl, "GENETICS CBD", 1, 1.2, 11, 0.7, size=22, bold=False, color=C_GOLD, align=PP_ALIGN.CENTER)
txt_box(sl, "GENETIC IMPRINTING", 0.5, 2.0, 12.3, 1.2, size=48, bold=True, color=C_WHITE, align=PP_ALIGN.CENTER)
txt_box(sl, "Genome  |  Histone Organization & Modifications  |  Genomic Imprinting",
        1, 3.1, 11.3, 0.6, size=16, color=C_GOLD, align=PP_ALIGN.CENTER)
txt_box(sl, "Prader-Willi Syndrome  |  Angelman Syndrome",
        1, 3.65, 11.3, 0.5, size=16, color=C_GOLD, align=PP_ALIGN.CENTER)
txt_box(sl, "Sources: Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics | Tietz Laboratory Medicine 7th ed.",
        1, 6.8, 11.3, 0.5, size=10, italic=True, color=RGBColor(0xAA,0xBB,0xCC), align=PP_ALIGN.CENTER)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 1 – THE GENOME
# ════════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
header_bar(sl, "1. The Genome", "Complete genetic instruction set of an organism")

# Left column – key facts
add_bullet_box(sl, [
    "~3.2 billion base pairs (haploid)",
    "~20,000–25,000 protein-coding genes",
    "Only ~1.5% of the genome codes for proteins",
    "~98.5% is non-coding (introns, regulatory, repeats)",
    "Nuclear + Mitochondrial (16,569 bp, maternal)",
    "Diploid somatic cells: 46 chromosomes (22 pairs autosomes + XX/XY)",
], 0.3, 1.35, 6.2, 3.0, title="Key Facts", box_color=C_WHITE)

# Right column – structural components as colour boxes
txt_box(sl, "Genome Components", 7.0, 1.35, 5.9, 0.4, size=15, bold=True, color=C_NAVY)
components = [
    ("Exons", "Protein-coding sequences", C_NAVY),
    ("Introns", "Non-coding; removed by splicing", C_TEAL),
    ("Promoters / Enhancers", "Regulate gene expression", C_LIME),
    ("Repetitive DNA", "Structural + some regulatory roles", C_ORANGE),
    ("lncRNA / miRNA", "Non-coding RNA; regulatory functions", RGBColor(0x7B,0x68,0xEE)),
]
for i,(name,desc,col) in enumerate(components):
    yp = 1.8 + i*0.88
    color_box(sl, name, 7.0, yp, 2.2, 0.55, col, size=12, bold=True)
    txt_box(sl, desc, 9.35, yp+0.05, 3.6, 0.5, size=12, color=C_DARK)

# Bottom bar – variation types
var_bar = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(0.3), Inches(6.15),
                               Inches(12.7), Inches(0.72))
var_bar.fill.solid(); var_bar.fill.fore_color.rgb = RGBColor(0xE8,0xF4,0xF8)
var_bar.line.color.rgb = C_TEAL; var_bar.line.width = Pt(1); var_bar.shadow.inherit=False
txt_box(sl, "Genomic Variation:  SNPs (~10 million) | CNVs (>1 kb deletions/duplications) | Indels | Microsatellites | Transposable elements",
        0.5, 6.22, 12.4, 0.5, size=12, color=C_NAVY)

footer(sl, "Thompson & Thompson Genetics and Genomics in Medicine, 9th ed. | Emery's Elements of Medical Genetics and Genomics")

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 2 – HISTONE ORGANIZATION & MODIFICATIONS
# ════════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
header_bar(sl, "2. Histone Organization & Modifications", "Epigenetic control of gene expression", bar_color=C_TEAL)

# Nucleosome diagram (schematic using shapes)
# DNA helix line
ln = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT, Inches(0.4), Inches(3.5), Inches(4.0), Inches(3.5))
ln.line.color.rgb = C_ORANGE; ln.line.width = Pt(4)
# Histone octamer
nuc = sl.shapes.add_shape(MSO_SHAPE.OVAL, Inches(1.2), Inches(2.8), Inches(1.4), Inches(1.4))
nuc.fill.solid(); nuc.fill.fore_color.rgb = C_TEAL; nuc.line.color.rgb = C_NAVY; nuc.line.width = Pt(2); nuc.shadow.inherit=False
tf = nuc.text_frame; tf.vertical_anchor = MSO_ANCHOR.MIDDLE
p = tf.paragraphs[0]; p.text = "Histone\nOctamer"; p.alignment = PP_ALIGN.CENTER
r = p.runs[0]; r.font.size = Pt(10); r.font.color.rgb = C_WHITE; r.font.bold = True
# Labels
txt_box(sl, "DNA (147 bp wrapped)", 0.3, 3.6, 2.5, 0.35, size=10, color=C_ORANGE, bold=True)
txt_box(sl, "H2A, H2B, H3, H4\n(2 copies each)", 2.7, 3.0, 1.8, 0.5, size=10, color=C_TEAL)
txt_box(sl, "H1 Linker\nHistone", 0.3, 2.4, 1.4, 0.5, size=10, color=RGBColor(0x7B,0x35,0x7B))

txt_box(sl, "Nucleosome = Basic Unit of Chromatin Packaging", 0.3, 4.05, 4.5, 0.4, size=12, bold=True, color=C_NAVY)

# Chromatin levels table
txt_box(sl, "Chromatin Compaction Levels", 4.8, 1.35, 8.2, 0.4, size=15, bold=True, color=C_NAVY)
levels = [
    ("Euchromatin","Loose (beads on string)","Transcriptionally ACTIVE", C_LIME),
    ("Heterochromatin (facultative)","Moderate compaction","Can be activated/silenced", C_ORANGE),
    ("Constitutive heterochromatin","Permanently condensed\n(centromeres, telomeres)","Always SILENT", C_RED),
]
for i,(name,struct,state,col) in enumerate(levels):
    yp = 1.82 + i*0.9
    color_box(sl, name, 4.8, yp, 2.5, 0.65, col, size=11, bold=True)
    txt_box(sl, struct, 7.4, yp+0.05, 2.7, 0.6, size=10, color=C_DARK)
    txt_box(sl, state, 10.2, yp+0.05, 2.8, 0.6, size=10, color=col, bold=True)

# Modification table
txt_box(sl, "Key Histone Modifications", 4.8, 4.65, 8.2, 0.38, size=14, bold=True, color=C_TEAL)
mods = [
    ("Acetylation (H3K9ac)","HATs","ACTIVATION – opens chromatin"),
    ("Deacetylation","HDACs","REPRESSION – closes chromatin"),
    ("Methylation H3K4me3","HMTs","ACTIVATION (active promoters)"),
    ("Methylation H3K27me3","PRC2","REPRESSION (polycomb)"),
    ("Phosphorylation H3S10","Aurora kinase","Chromosome condensation"),
]
for i,(mod,enz,effect) in enumerate(mods):
    yp = 5.1 + i*0.35
    col = C_LIME if "ACTIV" in effect else (C_RED if "REPRE" in effect else C_NAVY)
    txt_box(sl, mod, 4.8, yp, 3.0, 0.33, size=10, bold=True, color=col)
    txt_box(sl, enz, 7.85, yp, 1.8, 0.33, size=10, color=C_DARK)
    txt_box(sl, effect, 9.7, yp, 3.5, 0.33, size=10, color=col)

footer(sl, "Rheumatology 2-Volume Set 2022 | Fitzpatrick's Dermatology | Harrison's Principles of Internal Medicine 22E")

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 3 – GENOMIC IMPRINTING
# ════════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
header_bar(sl, "3. Genomic Imprinting", "Parent-of-origin epigenetic gene silencing", bar_color=C_NAVY)

txt_box(sl, "Definition: Epigenetic phenomenon where only the maternal or paternal allele of a gene is expressed, determined by the parent of origin — not the DNA sequence.",
        0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)

# Central mechanism diagram
# Maternal allele box
color_box(sl, "MATERNAL\nAllele\n(Methylated = SILENT)", 0.4, 2.15, 2.8, 1.5, RGBColor(0xE74C,0x3C,0x00)[:3] if False else RGBColor(0xE0,0x60,0x60), size=12, bold=True)
# Paternal allele box  
color_box(sl, "PATERNAL\nAllele\n(Unmethylated = ACTIVE)", 0.4, 3.85, 2.8, 1.5, C_TEAL, size=12, bold=True)
# Arrow to protein
arr = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT, Inches(3.2), Inches(4.65), Inches(4.0), Inches(4.65))
arr.line.color.rgb = C_TEAL; arr.line.width = Pt(3)
color_box(sl, "PROTEIN\nPRODUCT", 4.0, 4.3, 2.2, 0.8, C_LIME, size=12, bold=True, txt_c=C_DARK)

# X mark on maternal
x_box = sl.shapes.add_shape(MSO_SHAPE.OVAL, Inches(3.2), Inches(2.7), Inches(0.4), Inches(0.4))
x_box.fill.solid(); x_box.fill.fore_color.rgb = RGBColor(0xC0,0x39,0x2B)
x_box.line.fill.background(); x_box.shadow.inherit=False

# Key concepts panel
concepts = [
    ("DNA Methylation", "Primary mechanism — CpG dinucleotide methylation marks the silenced allele"),
    ("DMRs", "Differentially Methylated Regions — control which allele is silenced"),
    ("ICRs", "Imprinting Control Regions — coordinate entire imprinted gene domains"),
    ("Scale", "~200 human imprinted genes; clustered in domains (e.g., 15q11, 11p15)"),
    ("Reset", "Imprints erased in germline and reset per sex of new individual"),
    ("UPD", "Uniparental Disomy: both chromosomes from same parent — phenotypically equals deletion"),
]
txt_box(sl, "Key Concepts", 6.8, 2.05, 6.2, 0.38, size=14, bold=True, color=C_NAVY)
for i,(term,desc) in enumerate(concepts):
    yp = 2.5 + i*0.72
    color_box(sl, term, 6.8, yp, 2.0, 0.52, C_NAVY, size=11, bold=True)
    txt_box(sl, desc, 8.95, yp+0.04, 4.1, 0.5, size=11, color=C_DARK)

# Consequences table
txt_box(sl, "Consequences of Imprinting Disruption (Chromosome 15)", 0.3, 5.5, 7.5, 0.38, size=13, bold=True, color=C_TEAL)
rows = [("Paternal del 15q11-q13","Prader-Willi Syndrome"),("Maternal del 15q11-q13","Angelman Syndrome"),
        ("Maternal UPD chr 15","Prader-Willi Syndrome"),("Paternal UPD chr 15","Angelman Syndrome")]
for i,(mech,disease) in enumerate(rows):
    c = C_NAVY if "Prader" in disease else C_ORANGE
    color_box(sl, mech, 0.3+i*3.2, 5.95, 3.0, 0.5, C_WHITE, txt_c=C_DARK, size=11)
    color_box(sl, disease, 0.3+i*3.2, 6.5, 3.0, 0.45, c, size=11, bold=True)

footer(sl, "Thompson & Thompson Genetics 9th ed., p.113-115 | Emery's Elements of Medical Genetics | Tietz Laboratory Medicine 7th ed.")

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 4 – PRADER-WILLI SYNDROME
# ════════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
header_bar(sl, "4. Prader-Willi Syndrome (PWS)", "Incidence: ~1 in 20,000 births | Chromosome 15q11.2-q13", bar_color=C_ORANGE)

# Genetic mechanisms
txt_box(sl, "Genetic Mechanisms", 0.3, 1.35, 4.5, 0.4, size=14, bold=True, color=C_NAVY)
mechs = [("Paternal del 15q11.2-q13","~70–75%",C_RED),
         ("Maternal UPD chr 15","~20–25%",C_ORANGE),
         ("IC (imprinting center) defect","~1–3%",C_TEAL),
         ("Chromosomal rearrangement","rare",C_LIME)]
for i,(mech,pct,col) in enumerate(mechs):
    color_box(sl, pct, 0.3, 1.82+i*0.75, 0.9, 0.58, col, size=14, bold=True)
    txt_box(sl, mech, 1.3, 1.86+i*0.75, 3.4, 0.5, size=12, color=C_DARK)

# Key gene box
kg = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.3), Inches(4.95), Inches(4.5), Inches(0.7))
kg.fill.solid(); kg.fill.fore_color.rgb = RGBColor(0xE8,0xF4,0xF8); kg.line.color.rgb = C_TEAL; kg.line.width=Pt(1.5); kg.shadow.inherit=False
txt_box(sl, "Key: SNRPN gene cluster + snoRNA genes — paternally expressed\nResult: only MATERNAL 15q11-q13 information present → PWS", 0.4, 4.98, 4.3, 0.65, size=11, color=C_NAVY)

# Clinical features panels
txt_box(sl, "Clinical Features", 5.2, 1.35, 7.8, 0.4, size=14, bold=True, color=C_NAVY)
features = [
    ("Neonatal", C_TEAL, ["Marked hypotonia","Feeding difficulties","Failure to thrive"]),
    ("Childhood", C_ORANGE, ["Hyperphagia (insatiable appetite)","Progressive obesity","Short stature"]),
    ("Endocrine", RGBColor(0x7B,0x35,0x7B), ["Hypogonadism","Small hands & feet","Delayed puberty"]),
    ("Facial", C_NAVY, ["Almond-shaped eyes","Narrow bifrontal","Downturned mouth"]),
    ("Behavioral", C_RED, ["Temper tantrums","OCD behaviors","Skin picking"]),
    ("Cognitive", C_LIME, ["Mild-moderate intellectual disability","IQ typically 40-70","Learning difficulties"]),
]
for i,(cat,col,items) in enumerate(features):
    col_i = i % 3; row_i = i // 3
    xp = 5.2 + col_i*2.65; yp = 1.82 + row_i*2.1
    color_box(sl, cat, xp, yp, 2.4, 0.48, col, size=12, bold=True)
    for j,item in enumerate(items):
        txt_box(sl, f"• {item}", xp, yp+0.52+j*0.44, 2.4, 0.42, size=11, color=C_DARK)

# Diagnosis box
diag = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.3), Inches(5.72), Inches(4.5), Inches(1.05))
diag.fill.solid(); diag.fill.fore_color.rgb = C_NAVY; diag.line.fill.background(); diag.shadow.inherit=False
txt_box(sl, "Diagnosis", 0.45, 5.76, 1.5, 0.35, size=12, bold=True, color=C_GOLD)
txt_box(sl, "DNA methylation analysis (SNRPN locus) detects ~99% of cases\nFISH / CMA for deletions | MS-MLPA for UPD", 0.4, 6.1, 4.3, 0.6, size=11, color=C_WHITE)

footer(sl, "Emery's Elements of Medical Genetics, p.79 | Thompson & Thompson Genetics 9th ed., p.114 | Henry's Clinical Diagnosis 35th ed.")

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 5 – ANGELMAN SYNDROME
# ════════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
header_bar(sl, "5. Angelman Syndrome (AS)", "Incidence: ~1 in 15,000 births | UBE3A gene | Chr 15q11-q13", bar_color=RGBColor(0x7B,0x35,0x7B))

# Mechanisms
txt_box(sl, "Genetic Mechanisms", 0.3, 1.35, 4.5, 0.4, size=14, bold=True, color=C_NAVY)
mechs_as = [("Maternal del 15q11.2-q13","~75%",C_RED),
            ("Paternal UPD chr 15","~5%",C_ORANGE),
            ("IC defect","~2–3%",C_TEAL),
            ("UBE3A point mutation","~10%",RGBColor(0x7B,0x35,0x7B)),
            ("Unknown mechanism","~10%",C_LIME)]
for i,(mech,pct,col) in enumerate(mechs_as):
    color_box(sl, pct, 0.3, 1.82+i*0.68, 0.9, 0.55, col, size=13, bold=True)
    txt_box(sl, mech, 1.3, 1.86+i*0.68, 3.4, 0.48, size=12, color=C_DARK)

# UBE3A box
ub = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.3), Inches(5.28), Inches(4.5), Inches(0.95))
ub.fill.solid(); ub.fill.fore_color.rgb = RGBColor(0x7B,0x35,0x7B); ub.line.fill.background(); ub.shadow.inherit=False
txt_box(sl, "UBE3A Gene", 0.45, 5.32, 1.8, 0.35, size=12, bold=True, color=C_GOLD)
txt_box(sl, "Ubiquitin-protein ligase E3A\nBrain-specific imprinting (hippocampus, Purkinje cells)\nMaternal copy expressed in brain ONLY", 0.4, 5.65, 4.3, 0.55, size=11, color=C_WHITE)

# Clinical features
txt_box(sl, "Clinical Features  (\"Happy Puppet\" Syndrome)", 5.2, 1.35, 7.8, 0.4, size=14, bold=True, color=C_NAVY)
features_as = [
    ("Seizures", C_RED, "Epilepsy — often severe; characteristic EEG"),
    ("Intellectual", C_NAVY, "Severe intellectual disability; absent/near-absent speech"),
    ("Movement", C_TEAL, "Ataxic gait; jerky, unsteady movements"),
    ("Behavior", RGBColor(0x7B,0x35,0x7B), "Happy, excitable; frequent inappropriate laughter"),
    ("Facial", C_ORANGE, "Wide mouth; widely spaced teeth; tongue protrusion; microcephaly"),
    ("Other", C_LIME, "Fascination with water; fair pigmentation; postnatal microcephaly"),
]
for i,(cat,col,desc) in enumerate(features_as):
    yp = 1.82 + i*0.72
    color_box(sl, cat, 5.2, yp, 1.8, 0.52, col, size=12, bold=True)
    txt_box(sl, desc, 7.15, yp+0.06, 5.9, 0.48, size=12, color=C_DARK)

# Comparison table
txt_box(sl, "PWS vs AS Comparison", 0.3, 6.28, 5.0, 0.35, size=13, bold=True, color=C_NAVY)
pairs = [("Chr 15 loss","Paternal","Maternal"),("Key gene","SNRPN cluster","UBE3A"),
         ("Obesity","Yes","No"),("Seizures","Rare","Prominent"),("Behavior","OCD/irritable","Happy/excited")]
for i,(feat,pws,as_) in enumerate(pairs):
    xp = 0.3 + i*2.55
    color_box(sl, feat, xp, 6.65, 2.3, 0.38, C_NAVY, size=10, bold=True)
    color_box(sl, f"PWS: {pws}", xp, 7.05, 1.1, 0.3, C_ORANGE, size=9)
    color_box(sl, f"AS: {as_}", xp+1.15, 7.05, 1.1, 0.3, RGBColor(0x7B,0x35,0x7B), size=9)

footer(sl, "Emery's Elements of Medical Genetics, p.80 | Thompson & Thompson Genetics 9th ed., p.114-115")

# REFERENCES SLIDE
sl = prs.slides.add_slide(BLANK)
bg(sl, C_NAVY)
header_bar(sl, "References", "Genetic Imprinting", bar_color=C_TEAL)
refs = [
    "1. Thompson MW, McInnes RR, Willard HF. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Philadelphia: Elsevier; 2023.",
    "2. Turnpenny P, Ellard S, Cleaver R. Emery's Elements of Medical Genetics and Genomics. 16th ed. Elsevier; 2022.",
    "3. Rifai N et al. Tietz Textbook of Laboratory Medicine. 7th ed. Elsevier; 2023.",
    "4. Firestein GS et al. Kelley & Firestein's Textbook of Rheumatology. 11th ed. Elsevier; 2022.",
    "5. Henry JB. Henry's Clinical Diagnosis and Management by Laboratory Methods. 23rd ed. Elsevier; 2021.",
    "6. Ossa CA, Torres FA. Prader-Willi and Angelman syndromes: a review of their genetics. J Pediatr Genet. 2016;5(4):217-228.",
]
for i,r in enumerate(refs):
    txt_box(sl, r, 0.5, 1.4+i*0.75, 12.3, 0.65, size=12, color=C_WHITE)

buf = BytesIO(); prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT1_Genetic_Imprinting.pptx","wb") as f:
    f.write(buf.getvalue())
print("PPT1 saved")
Writing File

~/genetics-cbd/make_ppt2.py

"""PPT 2: Multifactorial Congenital Malformations"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide, color=C_LIGHT):
    s=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,0,prs.slide_width,prs.slide_height)
    s.fill.solid();s.fill.fore_color.rgb=color;s.line.fill.background();s.shadow.inherit=False

def hdr(slide, title, subtitle="", col=C_NAVY):
    b=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,0,prs.slide_width,Inches(1.25))
    b.fill.solid();b.fill.fore_color.rgb=col;b.line.fill.background();b.shadow.inherit=False
    tb=slide.shapes.add_textbox(Inches(0.3),Inches(0.05),Inches(12),Inches(0.7))
    tf=tb.text_frame;p=tf.paragraphs[0];p.text=title
    r=p.runs[0];r.font.size=Pt(28);r.font.bold=True;r.font.color.rgb=C_WHITE;r.font.name="Calibri"
    if subtitle:
        tb2=slide.shapes.add_textbox(Inches(0.35),Inches(0.78),Inches(12),Inches(0.45))
        p2=tb2.text_frame.paragraphs[0];p2.text=subtitle
        r2=p2.runs[0];r2.font.size=Pt(15);r2.font.color.rgb=C_GOLD;r2.font.name="Calibri"

def tb(slide,text,x,y,w,h,size=13,bold=False,color=C_DARK,align=PP_ALIGN.LEFT,italic=False,wrap=True):
    box=slide.shapes.add_textbox(Inches(x),Inches(y),Inches(w),Inches(h))
    tf=box.text_frame;tf.word_wrap=wrap
    p=tf.paragraphs[0];p.text=text;p.alignment=align
    r=p.runs[0];r.font.size=Pt(size);r.font.bold=bold
    r.font.color.rgb=color;r.font.name="Calibri";r.font.italic=italic

def cbox(slide,text,x,y,w,h,bg_c,tc=C_WHITE,size=12,bold=False,anchor=MSO_ANCHOR.MIDDLE):
    s=slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(x),Inches(y),Inches(w),Inches(h))
    s.fill.solid();s.fill.fore_color.rgb=bg_c;s.line.fill.background();s.shadow.inherit=False
    tf=s.text_frame;tf.word_wrap=True;tf.vertical_anchor=anchor
    p=tf.paragraphs[0];p.text=text;p.alignment=PP_ALIGN.CENTER
    r=p.runs[0];r.font.size=Pt(size);r.font.color.rgb=tc;r.font.bold=bold;r.font.name="Calibri"

def foot(slide,ref):
    ln=slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(0.3),Inches(7.15),Inches(13),Inches(7.15))
    ln.line.color.rgb=C_TEAL;ln.line.width=Pt(1)
    tb(slide,ref,0.3,7.18,12.7,0.3,size=9,italic=True,color=RGBColor(0x55,0x55,0x55))

# ── TITLE SLIDE ─────────────────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl,C_NAVY)
dec=sl.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,Inches(3.8),prs.slide_width,Inches(0.08))
dec.fill.solid();dec.fill.fore_color.rgb=C_TEAL;dec.line.fill.background();dec.shadow.inherit=False
dec2=sl.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,Inches(3.88),prs.slide_width,Inches(0.04))
dec2.fill.solid();dec2.fill.fore_color.rgb=C_GOLD;dec2.line.fill.background();dec2.shadow.inherit=False
tb(sl,"GENETICS CBD",1,1.2,11,0.7,size=22,color=C_GOLD,align=PP_ALIGN.CENTER)
tb(sl,"MULTIFACTORIAL CONGENITAL\nMALFORMATIONS",0.5,1.9,12.3,1.5,size=40,bold=True,color=C_WHITE,align=PP_ALIGN.CENTER)
tb(sl,"Definition  |  Neuropsychiatric & Bipolar  |  Coronary Artery Disease  |  Modifier Genes  |  Digenic Inheritance",
   1,3.6,11.3,0.6,size=15,color=C_GOLD,align=PP_ALIGN.CENTER)
tb(sl,"Sources: Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics",
   1,6.8,11.3,0.5,size=10,italic=True,color=RGBColor(0xAA,0xBB,0xCC),align=PP_ALIGN.CENTER)

# ── SLIDE 6 – DEFINITION ────────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"6. Multifactorial Congenital Malformations","Definition & Threshold Model",col=C_TEAL)

# Threshold model diagram
tb(sl,"Threshold Model",0.3,1.35,4.0,0.4,size=14,bold=True,color=C_NAVY)
# bell curve (fake with overlapping ellipses)
for i in range(5):
    w=0.6+i*0.5; xp=0.5+i*0.5; yp=3.8-i*0.22
    s=sl.shapes.add_shape(MSO_SHAPE.OVAL,Inches(xp),Inches(yp),Inches(w),Inches(0.35))
    alpha=180-i*30
    s.fill.solid();s.fill.fore_color.rgb=RGBColor(0,int(123*(alpha/180)),int(138*(alpha/180)))
    s.line.fill.background();s.shadow.inherit=False
# threshold line
ln=sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(3.2),Inches(2.1),Inches(3.2),Inches(4.5))
ln.line.color.rgb=C_RED;ln.line.width=Pt(3)
tb(sl,"Threshold",3.25,2.1,1.5,0.35,size=11,bold=True,color=C_RED)
tb(sl,"Below = Normal","1.0",2.5,1.5,0.35,size=10,color=C_DARK)
tb(sl,"← Normal","0.3",4.2,1.5,0.35,size=10,color=C_TEAL)
tb(sl,"Affected →","3.3",4.2,1.5,0.35,size=10,color=C_RED)
tb(sl,"Genetic Liability Distribution","0.3",4.55,4.0,0.35,size=11,italic=True,color=C_DARK)

# Characteristics
chars=[
    "1. Risk higher in 1st-degree relatives vs. general population",
    "2. Risk drops rapidly with decreasing degree of relationship",
    "3. Risk increases if multiple family members are affected",
    "4. Carter effect: if proband is the less-commonly affected sex, risk ↑",
    "5. More severe malformation → higher recurrence risk",
    "6. No single Mendelian pattern — polygenic + environmental",
]
tb(sl,"Key Characteristics of Multifactorial Inheritance",4.6,1.35,8.4,0.4,size=14,bold=True,color=C_NAVY)
for i,c in enumerate(chars):
    cbox(sl,c[0],4.6,1.82+i*0.71,0.5,0.52,C_TEAL,size=14,bold=True)
    tb(sl,c[3:],5.22,1.86+i*0.71,7.6,0.5,size=12,color=C_DARK)

# Malformations table
tb(sl,"Common Malformations (Incidence per 1000 births)",0.3,5.42,7.0,0.38,size=13,bold=True,color=C_TEAL)
items=[("Congenital heart defects","4–8"),("Neural tube defects","2–10"),("Cleft lip ± palate","0.4–1.7"),
       ("Pyloric stenosis (males)","5"),("Hip dislocation (females)","2"),("Ventricular septal defect","1.7")]
for i,(name,inc) in enumerate(items):
    col_i=i%3;row_i=i//3
    xp=0.3+col_i*4.3;yp=5.85+row_i*0.5
    cbox(sl,name,xp,yp,3.5,0.42,C_NAVY,size=10,bold=True)
    tb(sl,inc,xp+3.55,yp+0.05,0.7,0.35,size=12,bold=True,color=C_ORANGE)

foot(sl,"Thompson & Thompson Genetics 9th ed., p.181-182 | Emery's Elements of Medical Genetics | Robbins & Kumar Basic Pathology")

# ── SLIDE 7 – NEUROPSYCHIATRIC / BIPOLAR ───────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"7. Neuropsychiatric Disorders & Bipolar Disease","Schizophrenia and Bipolar Disorder — Multifactorial Complex Traits",col=C_PURPLE)

# Schizophrenia panel
cbox(sl,"SCHIZOPHRENIA",0.3,1.35,4.5,0.52,C_NAVY,size=16,bold=True)
tb(sl,"Prevalence: 1% worldwide | Onset: late adolescence/young adulthood",0.3,1.9,4.5,0.4,size=12,color=C_DARK)
tb(sl,"Features: disordered thought, emotion, social relationships; delusions; hallucinations",0.3,2.3,4.5,0.5,size=12,color=C_DARK)

# Recurrence table
tb(sl,"Recurrence Risks",0.3,2.88,4.5,0.38,size=13,bold=True,color=C_TEAL)
risks=[("2 affected parents","46%"),("Child of 1 affected","9–16%"),("Sibling","8–14%"),("Nephew/niece","1–4%")]
for i,(rel,risk) in enumerate(risks):
    yp=3.3+i*0.5
    cbox(sl,rel,0.3,yp,3.2,0.42,C_LIGHT,tc=C_DARK,size=11)
    cbox(sl,risk,3.55,yp,1.2,0.42,C_RED,size=12,bold=True)

# Twin concordance
tb(sl,"Twin Concordance:",0.3,5.42,4.5,0.35,size=12,bold=True,color=C_NAVY)
cbox(sl,"MZ: 40–60%",0.3,5.8,2.1,0.48,C_TEAL,size=12,bold=True)
cbox(sl,"DZ: 10–16%",2.5,5.8,2.1,0.48,C_ORANGE,size=12,bold=True)
tb(sl,"22q11 deletion → 25% risk of schizophrenia",0.3,6.35,4.5,0.4,size=11,italic=True,color=C_DARK)

# Bipolar panel
cbox(sl,"BIPOLAR DISORDER",5.1,1.35,7.9,0.52,C_ORANGE,size=16,bold=True,tc=C_DARK)
tb(sl,"Manic-Depressive Illness | Prevalence: ~1–2% worldwide",5.1,1.9,7.9,0.4,size=12,color=C_DARK)
tb(sl,"Cycles of mania and depression | Heritability: ~70–80%",5.1,2.3,7.9,0.4,size=12,color=C_DARK)

# Genetic evidence
tb(sl,"Genetic Evidence",5.1,2.78,7.9,0.38,size=13,bold=True,color=C_TEAL)
bp_data=[("MZ concordance","40–70%",C_ORANGE),("DZ concordance","15–25%",C_LIME),
         ("1st-degree relative risk","~10× general pop",C_RED),("Heritability","~70–80%",C_TEAL)]
for i,(label,val,col) in enumerate(bp_data):
    xp=5.1+i*2.0
    cbox(sl,label,xp,3.22,1.85,0.6,col,size=10,bold=True)
    tb(sl,val,xp,3.87,1.85,0.4,size=12,bold=True,color=col)

# GWAS loci
tb(sl,"GWAS Loci Identified (Bipolar)",5.1,4.42,7.9,0.38,size=13,bold=True,color=C_NAVY)
loci=["CACNA1C (voltage-gated Ca²⁺ channel)","ANK3 (ankyrin G, axon initial segment)","NCAN (neurocan — ECM glycoprotein)",
      "TRANK1 (tetratricopeptide repeat)","Cross-disorder overlap with schizophrenia (polygenic)"]
for i,l in enumerate(loci):
    tb(sl,f"• {l}",5.1,4.85+i*0.4,7.8,0.38,size=11,color=C_DARK)

# Gene-environment box
ge=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(6.72),Inches(12.7),Inches(0.5))
ge.fill.solid();ge.fill.fore_color.rgb=RGBColor(0xE8,0xF4,0xF8);ge.line.color.rgb=C_TEAL;ge.line.width=Pt(1);ge.shadow.inherit=False
tb(sl,"Gene × Environment Triggers: childhood trauma | sleep disruption | cannabis use | obstetric complications | urban birth",
   0.4,6.76,12.4,0.42,size=11,color=C_NAVY)

foot(sl,"Thompson & Thompson Genetics 9th ed., p.182-183 | Goldman-Cecil Medicine, International Edition")

# ── SLIDE 8 – CORONARY ARTERY DISEASE ──────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"8. Coronary Artery Disease (CAD)","Most common cause of death globally — complex multifactorial disease",col=C_RED)

# Genetic evidence
tb(sl,"Genetic Evidence from Twin Studies",0.3,1.35,6.2,0.4,size=14,bold=True,color=C_NAVY)
twin_data=[("Male MZ twins","39%","6–8×"),("Male DZ twins","26%","3×"),
           ("Female MZ twins","44%","15×"),("Female DZ twins","14%","2.6×")]
tb(sl,"Sex","0.3",1.8,1.2,0.38,size=12,bold=True,color=C_WHITE)
cbox(sl,"Sex",0.3,1.8,1.5,0.4,C_NAVY,size=12,bold=True)
cbox(sl,"Concordance",1.85,1.8,2.2,0.4,C_NAVY,size=12,bold=True)
cbox(sl,"Relative Risk vs. pop.",4.1,1.8,2.2,0.4,C_NAVY,size=12,bold=True)
for i,(sex,conc,rr) in enumerate(twin_data):
    yp=2.25+i*0.5
    cbox(sl,sex,0.3,yp,1.5,0.42,C_LIGHT,tc=C_DARK,size=11)
    cbox(sl,conc,1.85,yp,2.2,0.42,C_ORANGE,size=12,bold=True)
    cbox(sl,rr,4.1,yp,2.2,0.42,C_RED,size=12,bold=True)

# Stepwise pathway diagram
tb(sl,"Stepwise Pathway: Genetic Factors at Each Stage",0.3,4.5,6.2,0.4,size=13,bold=True,color=C_TEAL)
stages=[("Lipid metabolism","APOE, LDLR, APOC3, LPA",C_TEAL),
        ("Vasoactivity","ACE, AGTR1 (angiotensin)",C_ORANGE),
        ("Coagulation","Factor V Leiden, Prothrombin G20210A",C_RED),
        ("Inflammation","IL-6, CRP, TNF-α loci",C_PURPLE),
        ("Endothelial function","NOS3 (endothelial nitric oxide synthase)",C_LIME)]
for i,(stage,gene,col) in enumerate(stages):
    yp=4.95+i*0.38
    cbox(sl,stage,0.3,yp,2.0,0.33,col,size=10,bold=True)
    tb(sl,gene,2.35,yp+0.02,4.0,0.32,size=10,color=C_DARK)

# Right panel – environmental + GWAS
tb(sl,"Environmental Risk Factors",6.8,1.35,6.2,0.4,size=14,bold=True,color=C_NAVY)
env=["Diet: saturated/trans fats","Physical inactivity","Smoking","Obesity & type 2 diabetes","Systemic inflammation"]
for i,e in enumerate(env):
    cbox(sl,e,6.8,1.82+i*0.55,6.0,0.45,C_LIGHT,tc=C_DARK,size=12)

tb(sl,"Key GWAS Findings",6.8,4.65,6.2,0.4,size=14,bold=True,color=C_TEAL)
gwas=["9p21.3 locus — strongest replicated CAD risk locus (CDKN2A/CDKN2B region)",
      ">300 loci identified by GWAS",
      "Polygenic Risk Scores (PRS) now show clinical utility",
      "Familial Hypercholesterolaemia: LDLR mutations (AD) → dramatically elevated LDL",
      "Intermediate traits (hypertension, DM, obesity) each have their own genetic architecture"]
for i,g in enumerate(gwas):
    tb(sl,f"• {g}",6.8,5.1+i*0.42,6.2,0.4,size=11,color=C_DARK)

foot(sl,"Thompson & Thompson Genetics 9th ed., p.183-184 | Goldman-Cecil Medicine")

# ── SLIDE 9 – MODIFIER GENES ────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"9. Modifier Genes","Allelic variants at secondary loci that modulate disease severity",col=C_LIME if False else C_TEAL)

# Definition
tb(sl,"Definition: Modifier genes are genes whose allelic variants affect the expression, severity, or phenotype of a disease caused by mutations in a DIFFERENT primary gene. They do not cause the disease themselves.",
   0.3,1.35,12.7,0.65,size=13,color=C_DARK)

# CF as example
cbox(sl,"CLASSIC EXAMPLE: CYSTIC FIBROSIS",0.3,2.1,12.7,0.52,C_NAVY,size=15,bold=True)
tb(sl,"Primary gene: CFTR  |  Variable phenotype not fully explained by CFTR genotype alone",
   0.3,2.68,12.7,0.4,size=13,color=C_DARK)

# Two modifier loci
for i,(name,desc,effect,col) in enumerate([
    ("MBL2\n(Mannose-Binding Lectin)","Encodes innate immunity plasma protein that binds pathogens\nLow MBL2 alleles → reduced innate immunity → worse Pseudomonas containment",
     "Low MBL2 alleles → WORSE pulmonary outcome in CF",C_TEAL),
    ("TGFB1\n(Transforming Growth Factor β)","High TGFβ production alleles → increased lung scarring/fibrosis\nafter chronic inflammation in CF airways",
     "High TGFB1 alleles → WORSE FEV1 decline in CF",C_ORANGE),
]):
    xp=0.3+i*6.5
    cbox(sl,name,xp,3.18,2.2,0.8,col,size=13,bold=True)
    tb(sl,desc,xp+2.25,3.22,4.0,0.75,size=11,color=C_DARK)
    cbox(sl,effect,xp,4.05,6.1,0.5,C_LIGHT,tc=col,size=11,bold=True)

# Pulmonary heritability note
note=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(4.62),Inches(12.7),Inches(0.55))
note.fill.solid();note.fill.fore_color.rgb=RGBColor(0xE8,0xF4,0xF8);note.line.color.rgb=C_TEAL;note.line.width=Pt(1);note.shadow.inherit=False
tb(sl,"CF Lung Disease Heritability: ~50% (from MZ vs DZ twin comparison in CF patients) — independent of CFTR allele",
   0.4,4.67,12.4,0.42,size=12,bold=True,color=C_NAVY)

# Other examples table
tb(sl,"Additional Examples of Modifier Genes",0.3,5.28,12.7,0.38,size=14,bold=True,color=C_NAVY)
headers=["Primary Disease","Modifier Gene","Effect"]
for i,h in enumerate(headers):
    cbox(sl,h,0.3+i*4.2,5.7,4.0,0.4,C_NAVY,size=12,bold=True)
rows2=[("Cystic fibrosis","MBL2 / TGFB1","Pulmonary severity"),
       ("Sickle cell disease","HBF regulators (BCL11A, HBG)","Severity of crises"),
       ("Familial hypercholesterolaemia","APOE","Cardiovascular severity"),
       ("Huntington disease","MSH3 (mismatch repair)","Age of onset")]
for i,(pd,mg,eff) in enumerate(rows2):
    yp=6.15+i*0.32
    cols_=[C_LIGHT,RGBColor(0xD6,0xEA,0xF8),RGBColor(0xD5,0xF5,0xE3)]
    for j,(val,bgc) in enumerate(zip([pd,mg,eff],cols_)):
        cbox(sl,val,0.3+j*4.2,yp,4.0,0.3,bgc,tc=C_DARK,size=10)

foot(sl,"Thompson & Thompson Genetics 9th ed., p.185 | Goldman-Cecil Medicine | Harrison's Principles 22E")

# ── SLIDE 10 – DIGENIC INHERITANCE ─────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"10. Digenic Inheritance","Simplest form of multigenic inheritance — two loci required for disease",col=C_NAVY)

# Definition
tb(sl,"Definition: Disease requires pathogenic mutations at TWO DIFFERENT GENE LOCI. Heterozygous variants at each locus alone are insufficient; only the combination of both mutations causes the full phenotype.",
   0.3,1.35,12.7,0.65,size=13,color=C_DARK)

# Diagram
cbox(sl,"Gene A\nHeterozygous\n(Carrier — unaffected)",0.4,2.15,2.8,1.1,C_TEAL,size=12,bold=True)
cbox(sl,"+",3.3,2.45,0.6,0.55,C_WHITE,tc=C_DARK,size=20,bold=True)
cbox(sl,"Gene B\nHeterozygous\n(Carrier — unaffected)",4.0,2.15,2.8,1.1,C_ORANGE,size=12,bold=True)
cbox(sl,"=",6.9,2.45,0.6,0.55,C_WHITE,tc=C_DARK,size=20,bold=True)
cbox(sl,"DISEASE\n(Both mutations present)",7.6,2.15,2.8,1.1,C_RED,size=13,bold=True)
# arrows
for x1,x2,y in [(3.2,3.3,2.7),(6.8,6.9,2.7)]:
    ln2=sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(x1),Inches(y),Inches(x2),Inches(y))
    ln2.line.color.rgb=C_DARK;ln2.line.width=Pt(2)

# Characteristics
tb(sl,"Key Characteristics",0.3,3.42,5.5,0.38,size=14,bold=True,color=C_NAVY)
chars2=["Neither mutation alone causes disease",
        "Parents carrying one mutation each are UNAFFECTED",
        "Child inheriting BOTH mutations (25% chance) is AFFECTED",
        "Appears as sporadic/recessive-like in pedigrees",
        "Distinguishable from AR: AR = 2 mutations at SAME locus;\n  Digenic = 1 mutation at each of 2 DIFFERENT loci"]
for i,c in enumerate(chars2):
    cbox(sl,str(i+1),0.3,3.88+i*0.56,0.42,0.45,C_TEAL,size=13,bold=True)
    tb(sl,c,0.82,3.9+i*0.56,4.8,0.5,size=11,color=C_DARK)

# Examples panel
tb(sl,"Clinical Examples",6.8,1.35,6.2,0.38,size=14,bold=True,color=C_NAVY)
examples=[
    ("Digenic Retinitis Pigmentosa",C_RED,"ROM1 + PRPH2 (peripherin)\nEither alone = normal; both together = RP"),
    ("Waardenburg Syndrome Type III",C_PURPLE,"PAX3 + MITF heterozygosity"),
    ("Bardet-Biedl Syndrome",C_ORANGE,"BBS gene loci (triallelic/oligogenic)\nMutations at 2+ BBS loci"),
    ("Hereditary Deafness (GJB2/GJB6)",C_TEAL,"Connexin 26 + Connexin 30"),
]
for i,(name,col,desc) in enumerate(examples):
    yp=1.82+i*1.2
    cbox(sl,name,6.8,yp,6.2,0.5,col,size=12,bold=True)
    tb(sl,desc,6.9,yp+0.55,6.0,0.55,size=11,color=C_DARK)

# Clinical significance box
cs=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(6.58),Inches(12.7),Inches(0.55))
cs.fill.solid();cs.fill.fore_color.rgb=C_NAVY;cs.line.fill.background();cs.shadow.inherit=False
tb(sl,"Clinical Significance: Explains sporadic cases, single-carrier families; critical for genomic sequencing interpretation — VUS at two loci may act diigenically",
   0.4,6.63,12.4,0.42,size=12,color=C_WHITE)

foot(sl,"Emery's Elements of Medical Genetics (citing Schäffer, J Med Genet 2013) | Thompson & Thompson Genetics 9th ed.")

# REFERENCES SLIDE
sl=prs.slides.add_slide(BLANK);bg(sl,C_NAVY)
hdr(sl,"References","Multifactorial Congenital Malformations",col=C_TEAL)
refs=["1. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
      "2. Turnpenny P, Ellard S. Emery's Elements of Medical Genetics and Genomics. 16th ed. Elsevier; 2022.",
      "3. Goldman L, Schafer AI. Goldman-Cecil Medicine. 27th ed. International ed. Elsevier; 2024.",
      "4. Loscalzo J et al. Harrison's Principles of Internal Medicine. 22nd ed. McGraw-Hill; 2025.",
      "5. Robbins R, Kumar V. Robbins & Kumar Basic Pathology. 11th ed. Elsevier; 2023.",
      "6. Schäffer AA. Digenic inheritance in medical genetics. J Med Genet. 2013;50:641-652.",
      "7. Marchenko ME. Genetic susceptibility to death from coronary heart disease in a study of twins. NEJM 1994;330:1041-1046."]
for i,r in enumerate(refs):
    tb(sl,r,0.5,1.4+i*0.72,12.3,0.65,size=12,color=C_WHITE)

buf=BytesIO();prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT2_Multifactorial_Malformations.pptx","wb") as f:
    f.write(buf.getvalue())
print("PPT2 saved")
Writing File

~/genetics-cbd/make_ppt3.py

"""PPT 3: Autosomal Recessive Inheritance"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)
C_GREEN  = RGBColor(0x1A,0x7A,0x4A)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide,color=C_LIGHT):
    s=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,0,prs.slide_width,prs.slide_height)
    s.fill.solid();s.fill.fore_color.rgb=color;s.line.fill.background();s.shadow.inherit=False

def hdr(slide,title,subtitle="",col=C_NAVY):
    b=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,0,prs.slide_width,Inches(1.25))
    b.fill.solid();b.fill.fore_color.rgb=col;b.line.fill.background();b.shadow.inherit=False
    tb2=slide.shapes.add_textbox(Inches(0.3),Inches(0.05),Inches(12),Inches(0.7))
    tf=tb2.text_frame;p=tf.paragraphs[0];p.text=title
    r=p.runs[0];r.font.size=Pt(28);r.font.bold=True;r.font.color.rgb=C_WHITE;r.font.name="Calibri"
    if subtitle:
        tb3=slide.shapes.add_textbox(Inches(0.35),Inches(0.78),Inches(12),Inches(0.45))
        p2=tb3.text_frame.paragraphs[0];p2.text=subtitle
        r2=p2.runs[0];r2.font.size=Pt(15);r2.font.color.rgb=C_GOLD;r2.font.name="Calibri"

def tb(slide,text,x,y,w,h,size=13,bold=False,color=C_DARK,align=PP_ALIGN.LEFT,italic=False,wrap=True):
    box=slide.shapes.add_textbox(Inches(x),Inches(y),Inches(w),Inches(h))
    tf=box.text_frame;tf.word_wrap=wrap
    p=tf.paragraphs[0];p.text=text;p.alignment=align
    r=p.runs[0];r.font.size=Pt(size);r.font.bold=bold
    r.font.color.rgb=color;r.font.name="Calibri";r.font.italic=italic

def cbox(slide,text,x,y,w,h,bg_c,tc=C_WHITE,size=12,bold=False):
    s=slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(x),Inches(y),Inches(w),Inches(h))
    s.fill.solid();s.fill.fore_color.rgb=bg_c;s.line.fill.background();s.shadow.inherit=False
    tf=s.text_frame;tf.word_wrap=True;tf.vertical_anchor=MSO_ANCHOR.MIDDLE
    p=tf.paragraphs[0];p.text=text;p.alignment=PP_ALIGN.CENTER
    r=p.runs[0];r.font.size=Pt(size);r.font.color.rgb=tc;r.font.bold=bold;r.font.name="Calibri"

def foot(slide,ref):
    ln=slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(0.3),Inches(7.15),Inches(13),Inches(7.15))
    ln.line.color.rgb=C_TEAL;ln.line.width=Pt(1)
    tb(slide,ref,0.3,7.18,12.7,0.3,size=9,italic=True,color=RGBColor(0x55,0x55,0x55))

# ── TITLE ───────────────────────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl,C_NAVY)
dec=sl.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,Inches(3.8),prs.slide_width,Inches(0.1))
dec.fill.solid();dec.fill.fore_color.rgb=C_TEAL;dec.line.fill.background();dec.shadow.inherit=False
dec2=sl.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,Inches(3.9),prs.slide_width,Inches(0.04))
dec2.fill.solid();dec2.fill.fore_color.rgb=C_GOLD;dec2.line.fill.background();dec2.shadow.inherit=False
tb(sl,"GENETICS CBD",1,1.2,11,0.7,size=22,color=C_GOLD,align=PP_ALIGN.CENTER)
tb(sl,"AUTOSOMAL RECESSIVE\nINHERITANCE",0.5,1.9,12.3,1.5,size=44,bold=True,color=C_WHITE,align=PP_ALIGN.CENTER)
tb(sl,"Definition  |  Cystic Fibrosis  |  Marfan Syndrome  |  Phenylketonuria  |  CF Phenotypic Features",
   1,3.65,11.3,0.6,size=15,color=C_GOLD,align=PP_ALIGN.CENTER)
tb(sl,"Sources: Goldman-Cecil Medicine | Harrison's Principles 22E | Thompson & Thompson Genetics 9th ed.",
   1,6.8,11.3,0.5,size=10,italic=True,color=RGBColor(0xAA,0xBB,0xCC),align=PP_ALIGN.CENTER)

# ── SLIDE 11 – AR DEFINITION ────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"11. Autosomal Recessive Inheritance","Two pathogenic alleles required; heterozygotes (carriers) are unaffected",col=C_NAVY)

# Pedigree diagram (schematic)
tb(sl,"Carrier × Carrier Cross (Aa × Aa)",0.3,1.38,5.5,0.38,size=14,bold=True,color=C_NAVY)
# Father circle / mother circle
for x,lbl,col in [(0.7,"Father (Carrier)\nAa",C_TEAL),(2.6,"Mother (Carrier)\nAa",C_TEAL)]:
    cbox(sl,lbl,x,1.82,1.6,0.8,col,size=11,bold=True)
ln=sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(2.3),Inches(2.22),Inches(2.6),Inches(2.22))
ln.line.color.rgb=C_DARK;ln.line.width=Pt(2)
# line down
ln2=sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(2.4),Inches(2.62),Inches(2.4),Inches(3.05))
ln2.line.color.rgb=C_DARK;ln2.line.width=Pt(2)
# offspring
offspring=[("AA\n(25%)\nNormal",C_LIME,C_DARK),("Aa\n(50%)\nCarrier",C_TEAL,C_WHITE),
           ("Aa\n(50%)\nCarrier",C_TEAL,C_WHITE),("aa\n(25%)\nAFFECTED",C_RED,C_WHITE)]
for i,(lbl,col,tc) in enumerate(offspring):
    cbox(sl,lbl,0.3+i*1.35,3.12,1.2,0.95,col,tc=tc,size=10,bold=True)

# Key rules
tb(sl,"Rules of AR Inheritance",0.3,4.25,5.5,0.38,size=14,bold=True,color=C_TEAL)
rules=["1. Both sexes equally affected (autosomal gene)",
       "2. Parents are typically unaffected carriers (Aa × Aa)",
       "3. Horizontal pattern: affected siblings in one generation",
       "4. Consanguinity increases risk (IBD alleles)",
       "5. No male-to-male (or male-to-female) vertical pattern",
       "6. Compound heterozygosity: two different pathogenic alleles (same locus)"]
for i,r in enumerate(rules):
    tb(sl,r,0.3,4.68+i*0.38,5.3,0.36,size=11,color=C_DARK)

# Hardy-Weinberg box
hw=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(6.82),Inches(5.5),Inches(0.52))
hw.fill.solid();hw.fill.fore_color.rgb=RGBColor(0xD5,0xF5,0xE3);hw.line.color.rgb=C_GREEN;hw.line.width=Pt(1.5);hw.shadow.inherit=False
tb(sl,"Hardy-Weinberg: If disease freq = q² (e.g. CF: 1/2500), q = 1/50, carrier freq 2pq ≈ 1/25 (~4%)",
   0.4,6.87,5.3,0.42,size=11,color=C_DARK)

# Right panel – comparisons
tb(sl,"Comparison: AR vs AD vs X-linked Recessive",5.9,1.38,7.1,0.38,size=14,bold=True,color=C_NAVY)
headers=["Feature","AR","AD","XLR"]
col_widths=[2.8,1.4,1.4,1.4]
x_starts=[5.9,8.75,10.2,11.65]
for i,(h,xp) in enumerate(zip(headers,x_starts)):
    cbox(sl,h,xp,1.82,col_widths[i],0.42,C_NAVY,size=11,bold=True)
rows3=[("Both sexes","Equal","Equal","Males mainly"),
       ("Carrier parents","Unaffected","—","Unaffected females"),
       ("Skip generations","Yes","No","Yes"),
       ("Consanguinity","Increases risk","No effect","No effect"),
       ("Male→son trans.","Possible","Possible","NEVER")]
for i,(feat,ar,ad,xlr) in enumerate(rows3):
    yp=2.3+i*0.58
    cols=[C_LIGHT,RGBColor(0xD6,0xEA,0xF8),RGBColor(0xFD,0xED,0xEC),RGBColor(0xD5,0xF5,0xE3)]
    for j,(val,xp,cw,bgc) in enumerate(zip([feat,ar,ad,xlr],x_starts,col_widths,cols)):
        cbox(sl,val,xp,yp,cw,0.5,bgc,tc=C_DARK,size=11)

# Examples
tb(sl,"Common AR Diseases",5.9,5.35,7.1,0.38,size=13,bold=True,color=C_TEAL)
ar_diseases=["Cystic Fibrosis (CFTR, chr 7q31)","Phenylketonuria (PAH, chr 12q23)",
             "Sickle Cell Disease (HBB, chr 11p15)","Thalassaemia (HBA/HBB)",
             "Wilson's Disease (ATP7B)","Haemochromatosis (HFE, C282Y)","Spinal Muscular Atrophy (SMN1)"]
for i,d in enumerate(ar_diseases):
    tb(sl,f"• {d}",5.9,5.75+i*0.32,7.1,0.3,size=11,color=C_DARK)

foot(sl,"Goldman-Cecil Medicine | Basic Medical Biochemistry 6th ed. | Dermatology 2-Volume Set 5th ed.")

# ── SLIDE 12 – CYSTIC FIBROSIS ──────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"12. Cystic Fibrosis","AR | CFTR gene, Chr 7q31.2 | Most common life-shortening AR disease in White populations",col=C_TEAL)

# Mutation classes
tb(sl,"CFTR Mutation Classes",0.3,1.35,5.0,0.4,size=14,bold=True,color=C_NAVY)
classes=[("I","No synthesis (stop)","W1282X, G542X",C_RED),
         ("II","Misfolding/degradation","F508del (70%!), N1303K",C_ORANGE),
         ("III","Defective gating","G551D, G551S",C_PURPLE),
         ("IV","Reduced Cl⁻ conductance","R117H, R334W",C_TEAL),
         ("V","Reduced transcripts","3849+10kbC→T",C_GREEN),
         ("VI","Unstable protein","4326delTC",C_LIME if False else RGBColor(0x2E,0x86,0xAB))]
for i,(cls,defect,muts,col) in enumerate(classes):
    cbox(sl,f"Class {cls}",0.3,1.82+i*0.62,1.0,0.52,col,size=12,bold=True)
    tb(sl,defect,1.4,1.86+i*0.62,1.9,0.5,size=11,color=C_DARK)
    tb(sl,muts,3.35,1.86+i*0.62,1.9,0.5,size=10,color=col,bold=True)

# Epidemiology
epi=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(5.72),Inches(4.85),Inches(0.7))
epi.fill.solid();epi.fill.fore_color.rgb=RGBColor(0xE8,0xF4,0xF8);epi.line.color.rgb=C_TEAL;epi.line.width=Pt(1);epi.shadow.inherit=False
tb(sl,"Epidemiology:",0.4,5.76,1.2,0.3,size=11,bold=True,color=C_NAVY)
tb(sl,"Northern Europe/Americas: 1:2,500–3,000 | USA: 1:10,000 | Hispanic: 1:7,000 | African American: 1:12,000",
   0.4,6.05,4.7,0.3,size=10,color=C_DARK)

# Organ system pathophysiology
tb(sl,"Pathophysiology by Organ System",5.4,1.35,7.6,0.4,size=14,bold=True,color=C_NAVY)
organs=[
    ("LUNGS\n(~90% mortality)","Reduced Cl⁻/HCO₃⁻ secretion → airway dehydration → mucus plugging → chronic Pseudomonas → bronchiectasis",C_RED),
    ("SWEAT GLANDS","Sweat Cl⁻ ≥60 mEq/L (diagnostic) | Salt wasting in hot weather | Hyponatremia risk",C_TEAL),
    ("PANCREAS","Exocrine insufficiency → steatorrhea, vitamin malabsorption | CFRD (CF-related diabetes)",C_ORANGE),
    ("LIVER","Biliary canalicular obstruction → cirrhosis in ~5% | Gallstones 30%",RGBColor(0x5D,0x6D,0x7E)),
    ("GI TRACT","Meconium ileus (15–20% neonates) | DIOS in older patients | GERD",C_PURPLE),
    ("REPRODUCTIVE","Males: CBAVD → azoospermia → infertility (>95%) | Females: thick cervical mucus",C_GREEN),
]
for i,(organ,desc,col) in enumerate(organs):
    yp=1.82+i*0.82
    cbox(sl,organ,5.4,yp,2.0,0.65,col,size=10,bold=True)
    tb(sl,desc,7.5,yp+0.06,5.5,0.62,size=10,color=C_DARK)

foot(sl,"Goldman-Cecil Medicine, p.3231-3290 | Harrison's Principles of Internal Medicine 22E | Medical Physiology")

# ── SLIDE 13 – MARFAN SYNDROME ──────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"13. Marfan Syndrome","Autosomal DOMINANT | FBN1 gene, Chr 15q21.1 | Connective tissue disorder",col=C_ORANGE)

# Note banner
note=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(1.35),Inches(12.7),Inches(0.45))
note.fill.solid();note.fill.fore_color.rgb=RGBColor(0xFE,0xF9,0xE7);note.line.color.rgb=C_ORANGE;note.line.width=Pt(2);note.shadow.inherit=False
tb(sl,"NOTE: Marfan syndrome is AUTOSOMAL DOMINANT — included here for differential comparison with AR connective tissue disorders",
   0.4,1.4,12.4,0.37,size=11,bold=True,color=RGBColor(0x78,0x3F,0x04))

# Genetics
cbox(sl,"Gene: FBN1 (Fibrillin-1)\nChromosome 15q21.1\nAutosomal Dominant\n~75% inherited | ~25% de novo",
     0.3,1.88,4.5,1.1,C_NAVY,size=12,bold=True)

# Pathophysiology
tb(sl,"Pathophysiology",0.3,3.1,4.5,0.38,size=14,bold=True,color=C_TEAL)
path=["Fibrillin-1: major building block of extracellular microfibrils",
      "Microfibrils provide structural integrity to: aortic wall, lens zonules, ligaments, lung airways, spinal dura",
      "Mutant FBN1 → weakened microfibrils + excess TGF-β signaling",
      "Excess TGF-β → progressive aortic wall degradation & dilatation"]
for i,p in enumerate(path):
    tb(sl,f"• {p}",0.3,3.52+i*0.45,4.5,0.43,size=11,color=C_DARK)

# Ghent criteria diagnosis
dbox=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(5.52),Inches(4.5),Inches(1.2))
dbox.fill.solid();dbox.fill.fore_color.rgb=RGBColor(0xD5,0xF5,0xE3);dbox.line.color.rgb=C_GREEN;dbox.line.width=Pt(1.5);dbox.shadow.inherit=False
tb(sl,"Ghent Criteria 2010 (any one):",0.4,5.57,4.3,0.35,size=12,bold=True,color=C_GREEN)
tb(sl,"• Aortic root dilatation + ectopia lentis\n• Aortic dilatation + FBN1 pathogenic variant\n• Ectopia lentis + FBN1 variant + aortic disease\n• Systemic score ≥7 + aortic disease",
   0.4,5.95,4.3,0.73,size=11,color=C_DARK)

# Clinical features – 3 body systems
tb(sl,"Cardinal Clinical Features",5.0,1.38,8.0,0.38,size=14,bold=True,color=C_NAVY)
systems=[
    ("CARDIOVASCULAR\n(Most Dangerous)", C_RED,
     ["Aortic root dilatation/aneurysm (Z≥2.0)","Aortic dissection (Type A — emergency)",
      "Mitral valve prolapse ± regurgitation","Pulmonary artery dilatation"]),
    ("OCULAR", C_TEAL,
     ["Ectopia lentis (upward subluxation — 50–80%)","High myopia","Retinal detachment risk","Glaucoma, cataracts"]),
    ("SKELETAL", C_ORANGE,
     ["Tall stature; dolichostenomelia (long limbs)","Arachnodactyly (positive wrist & thumb signs)",
      "Pectus excavatum/carinatum","Scoliosis | Dural ectasia | Flat feet"]),
]
for i,(sys,col,items) in enumerate(systems):
    xp=5.0+i*2.75
    cbox(sl,sys,xp,1.85,2.5,0.75,col,size=11,bold=True)
    for j,item in enumerate(items):
        tb(sl,f"• {item}",xp,2.65+j*0.45,2.5,0.42,size=10,color=C_DARK)

# Management
mbox=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(5.0),Inches(5.52),Inches(8.0),Inches(1.2))
mbox.fill.solid();mbox.fill.fore_color.rgb=C_NAVY;mbox.line.fill.background();mbox.shadow.inherit=False
tb(sl,"Management",5.1,5.57,2.0,0.35,size=12,bold=True,color=C_GOLD)
tb(sl,"• Beta-blockers (atenolol) or losartan (anti-TGF-β) to slow aortic dilatation\n• Elective aortic root repair when diameter reaches 4.5–5.0 cm\n• Annual echocardiography | Restrict contact sports & high-intensity exercise",
   5.1,5.95,7.8,0.73,size=11,color=C_WHITE)

foot(sl,"GeneReviews NBK1335 | Medscape; Emery's Elements of Medical Genetics | Thompson & Thompson Genetics 9th ed.")

# ── SLIDE 14 – PHENYLKETONURIA ──────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"14. Phenylketonuria (PKU)","AR | PAH gene, Chr 12q23.2 | Inborn error of phenylalanine metabolism",col=C_PURPLE)

# Genetics
cbox(sl,"Gene: PAH (Phenylalanine Hydroxylase)\nChr 12q23.2 | 90 kb | 13 exons\nAR — homozygous or compound heterozygous",
     0.3,1.38,4.5,0.95,C_PURPLE,size=12,bold=True)

# Biochemical defect diagram
tb(sl,"Biochemical Pathway",0.3,2.45,4.5,0.38,size=13,bold=True,color=C_NAVY)
cbox(sl,"Phenylalanine\n(diet)",0.3,2.9,2.1,0.7,C_TEAL,size=12,bold=True)
arr=sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(2.4),Inches(3.25),Inches(2.8),Inches(3.25))
arr.line.color.rgb=C_GREEN;arr.line.width=Pt(3)
cbox(sl,"PAH + BH4\n(cofactor)",2.8,2.9,1.7,0.7,C_GREEN,size=11,bold=True)
arr2=sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(4.5),Inches(3.25),Inches(4.85),Inches(3.25))
arr2.line.color.rgb=C_GREEN;arr2.line.width=Pt(3)
cbox(sl,"Tyrosine",4.85,2.9,1.5,0.7,C_LIME,size=12,bold=True,tc=C_DARK)

# X mark / deficiency
x2=sl.shapes.add_shape(MSO_SHAPE.OVAL,Inches(2.85),Inches(2.6),Inches(0.4),Inches(0.4))
x2.fill.solid();x2.fill.fore_color.rgb=C_RED;x2.line.fill.background();x2.shadow.inherit=False
tf2=x2.text_frame;tf2.vertical_anchor=MSO_ANCHOR.MIDDLE
p2=tf2.paragraphs[0];p2.text="X";p2.alignment=PP_ALIGN.CENTER
r2=p2.runs[0];r2.font.size=Pt(12);r2.font.color.rgb=C_WHITE;r2.font.bold=True

cbox(sl,"PAH absent/deficient → Phe accumulates → toxic metabolites\n(phenylpyruvate, phenylacetate, phenyllactate)",
     0.3,3.68,4.5,0.65,C_RED,size=11,bold=True)

# Phenotypes table
tb(sl,"Clinical Phenotypes (without treatment)",0.3,4.42,4.5,0.38,size=13,bold=True,color=C_TEAL)
phenos=[("Classic PKU",">1200 µmol/L","Severe ID (IQ<50)",C_RED),
        ("Moderate PKU","600–1200","Moderate ID",C_ORANGE),
        ("Mild PKU","360–600","Mild cognitive effects",C_LIME if False else RGBColor(0xE8,0x8B,0x2E)),
        ("Benign hyperphe.","<360","Minimal",C_LIME)]
for i,(ptype,phe,iq,col) in enumerate(phenos):
    cbox(sl,ptype,0.3,4.85+i*0.44,1.8,0.38,col,size=10,bold=True)
    tb(sl,f"Phe: {phe}",2.15,4.87+i*0.44,1.4,0.35,size=10,color=C_DARK)
    tb(sl,iq,3.6,4.87+i*0.44,1.2,0.35,size=10,color=col,bold=True)

# Epidemiology bar
ep2=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(6.7),Inches(4.5),Inches(0.52))
ep2.fill.solid();ep2.fill.fore_color.rgb=RGBColor(0xE8,0xF4,0xF8);ep2.line.color.rgb=C_TEAL;ep2.line.width=Pt(1);ep2.shadow.inherit=False
tb(sl,"Prevalence: ~1:24,000 globally | Turkey highest (~38:100,000) | US ~1:10,000–15,000",
   0.4,6.75,4.3,0.42,size=11,color=C_DARK)

# Right panel: clinical features + treatment
tb(sl,"Clinical Features (Untreated)",5.1,1.38,8.0,0.38,size=14,bold=True,color=C_NAVY)
uf=["Profound intellectual disability (IQ <50)","Epilepsy / seizures",
    "Acquired microcephaly","Behavioral disorders (hyperactivity, autism-like)",
    "Generalized hypopigmentation: blue eyes, fair hair, fair skin (↓ tyrosine → ↓ melanin)",
    "Eczema","Mousy/musty odor (phenylacetate in urine and sweat)"]
for i,f in enumerate(uf):
    cbox(sl,str(i+1),5.1,1.82+i*0.48,0.4,0.4,C_PURPLE,size=12,bold=True)
    tb(sl,f,5.6,1.84+i*0.48,7.3,0.42,size=11,color=C_DARK)

# Treatment
tb(sl,"Treatment",5.1,5.42,8.0,0.38,size=14,bold=True,color=C_TEAL)
txts=[("Low-Phe diet (lifelong)","Restrict proteins; phenylalanine-free amino acid formula",C_TEAL),
      ("Sapropterin (Kuvan)","BH4 analog — effective in ~30–50% of pts (BH4-responsive)",C_ORANGE),
      ("Pegvaliase","PEGylated PAL for adults with poorly controlled classic PKU",C_PURPLE),
      ("Newborn screening","MS/MS on heel-prick blood spot day 2–5 | Early treatment = normal IQ",C_GREEN)]
for i,(name,desc,col) in enumerate(txts):
    cbox(sl,name,5.1,5.85+i*0.38,2.4,0.32,col,size=10,bold=True)
    tb(sl,desc,7.6,5.87+i*0.38,5.4,0.32,size=10,color=C_DARK)

foot(sl,"Goldman-Cecil Medicine | Basic Medical Biochemistry 6th ed. | PMC9295449 (PKU genetics review)")

# ── SLIDE 15 – MAJOR PHENOTYPIC FEATURES OF CF ─────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"15. Major Phenotypic Features: Cystic Fibrosis","Multisystem disease — CFTR dysfunction affects every exocrine gland",col=C_TEAL)

# Body system boxes in a grid
systems_cf=[
    ("PULMONARY\n~90% mortality","Chronic cough | Bronchiectasis | Chronic Pseudomonas/Staph infection | Hemoptysis | Respiratory failure | Cor pulmonale",C_RED),
    ("SWEAT\nGLANDS","Cl⁻ ≥60 mEq/L (DIAGNOSTIC) | Salt wasting | Hyponatremic alkalosis | 'Salty tasting skin'",C_TEAL),
    ("PANCREAS","Exocrine insufficiency → steatorrhea | Fat-soluble vitamin deficiency (A,D,E,K) | CFRD in ~50% by age 50",C_ORANGE),
    ("LIVER &\nBILIARY","Biliary obstruction → focal cirrhosis (5–10%) | Portal hypertension | Gallstones (30%)",RGBColor(0x5D,0x6D,0x7E)),
    ("GI TRACT","Meconium ileus (15–20% neonates) | DIOS in older pts | Rectal prolapse | GERD",C_PURPLE),
    ("REPRODUCTIVE","Males: CBAVD → obstructive azoospermia → infertility >95%\nFemales: thick cervical mucus → ↓ fertility",C_GREEN),
    ("SINUSES","Chronic sinusitis (virtually all) | Nasal polyps (10–40%)",C_NAVY),
    ("BONE","Osteoporosis/osteopenia | Short stature | Delayed puberty | CF arthropathy",C_LIME if False else RGBColor(0x2E,0x86,0xAB)),
    ("CLUBBING\n& SKIN","Digit clubbing (chronic hypoxia/bronchiectasis) | Wrinkling of hands/feet | Hypochloremic alkalosis",C_ORANGE if False else RGBColor(0x7B,0x68,0xEE)),
]
for i,(name,desc,col) in enumerate(systems_cf):
    col_i=i%3; row_i=i//3
    xp=0.3+col_i*4.3; yp=1.35+row_i*1.72
    cbox(sl,name,xp,yp,2.0,0.65,col,size=11,bold=True)
    tb(sl,desc,xp+2.05,yp+0.06,2.2,0.62,size=9,color=C_DARK)

# Diagnostic criteria
dcs=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(6.6),Inches(12.7),Inches(0.62))
dcs.fill.solid();dcs.fill.fore_color.rgb=C_NAVY;dcs.line.fill.background();dcs.shadow.inherit=False
tb(sl,"Diagnostic Criteria (any ONE):",0.4,6.65,2.5,0.35,size=12,bold=True,color=C_GOLD)
tb(sl,"Sweat Cl⁻ ≥60 mEq/L (×2) OR Two pathogenic CFTR mutations OR Abnormal nasal potential difference PLUS ≥1 clinical feature/family Hx/positive newborn screen",
   2.95,6.65,9.9,0.52,size=11,color=C_WHITE)

foot(sl,"Goldman-Cecil Medicine, p.3231-3290 | Harrison's Principles of Internal Medicine 22E")

# REFERENCES
sl=prs.slides.add_slide(BLANK);bg(sl,C_NAVY)
hdr(sl,"References","Autosomal Recessive Inheritance",col=C_TEAL)
refs2=["1. Goldman L, Schafer AI. Goldman-Cecil Medicine. 27th ed. (International). Elsevier; 2024.",
       "2. Loscalzo J et al. Harrison's Principles of Internal Medicine. 22nd ed. McGraw-Hill; 2025.",
       "3. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
       "4. Lieberman M, Peet A. Basic Medical Biochemistry: A Clinical Approach. 6th ed. Wolters Kluwer; 2024.",
       "5. GeneReviews: FBN1-Related Marfan Syndrome. NBK1335. NCBI Bookshelf.",
       "6. Stenson PD et al. The Human Gene Mutation Database (HGMD). Nucleic Acids Res. 2020;48(D1):D895-D900.",
       "7. Vockley J et al. Phenylalanine hydroxylase deficiency. Genet Med. 2014;16(2):188-200."]
for i,r in enumerate(refs2):
    tb(sl,r,0.5,1.4+i*0.72,12.3,0.65,size=12,color=C_WHITE)

buf=BytesIO();prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT3_Autosomal_Recessive.pptx","wb") as f:
    f.write(buf.getvalue())
print("PPT3 saved")
Writing File

~/genetics-cbd/make_ppt4.py

"""PPT 4: Chromosomal Anomalies"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)
C_GREEN  = RGBColor(0x1A,0x7A,0x4A)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide,color=C_LIGHT):
    s=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,0,prs.slide_width,prs.slide_height)
    s.fill.solid();s.fill.fore_color.rgb=color;s.line.fill.background();s.shadow.inherit=False

def hdr(slide,title,subtitle="",col=C_NAVY):
    b=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,0,prs.slide_width,Inches(1.25))
    b.fill.solid();b.fill.fore_color.rgb=col;b.line.fill.background();b.shadow.inherit=False
    tb2=slide.shapes.add_textbox(Inches(0.3),Inches(0.05),Inches(12),Inches(0.7))
    tf=tb2.text_frame;p=tf.paragraphs[0];p.text=title
    r=p.runs[0];r.font.size=Pt(28);r.font.bold=True;r.font.color.rgb=C_WHITE;r.font.name="Calibri"
    if subtitle:
        tb3=slide.shapes.add_textbox(Inches(0.35),Inches(0.78),Inches(12),Inches(0.45))
        p2=tb3.text_frame.paragraphs[0];p2.text=subtitle
        r2=p2.runs[0];r2.font.size=Pt(15);r2.font.color.rgb=C_GOLD;r2.font.name="Calibri"

def tb(slide,text,x,y,w,h,size=13,bold=False,color=C_DARK,align=PP_ALIGN.LEFT,italic=False,wrap=True):
    box=slide.shapes.add_textbox(Inches(x),Inches(y),Inches(w),Inches(h))
    tf=box.text_frame;tf.word_wrap=wrap
    p=tf.paragraphs[0];p.text=text;p.alignment=align
    r=p.runs[0];r.font.size=Pt(size);r.font.bold=bold
    r.font.color.rgb=color;r.font.name="Calibri";r.font.italic=italic

def cbox(slide,text,x,y,w,h,bg_c,tc=C_WHITE,size=12,bold=False):
    s=slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(x),Inches(y),Inches(w),Inches(h))
    s.fill.solid();s.fill.fore_color.rgb=bg_c;s.line.fill.background();s.shadow.inherit=False
    tf=s.text_frame;tf.word_wrap=True;tf.vertical_anchor=MSO_ANCHOR.MIDDLE
    p=tf.paragraphs[0];p.text=text;p.alignment=PP_ALIGN.CENTER
    r=p.runs[0];r.font.size=Pt(size);r.font.color.rgb=tc;r.font.bold=bold;r.font.name="Calibri"

def foot(slide,ref):
    ln=slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,Inches(0.3),Inches(7.15),Inches(13),Inches(7.15))
    ln.line.color.rgb=C_TEAL;ln.line.width=Pt(1)
    tb(slide,ref,0.3,7.18,12.7,0.3,size=9,italic=True,color=RGBColor(0x55,0x55,0x55))

# ── TITLE ───────────────────────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl,C_NAVY)
dec=sl.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,Inches(3.8),prs.slide_width,Inches(0.1))
dec.fill.solid();dec.fill.fore_color.rgb=C_TEAL;dec.line.fill.background();dec.shadow.inherit=False
dec2=sl.shapes.add_shape(MSO_SHAPE.RECTANGLE,0,Inches(3.9),prs.slide_width,Inches(0.04))
dec2.fill.solid();dec2.fill.fore_color.rgb=C_GOLD;dec2.line.fill.background();dec2.shadow.inherit=False
tb(sl,"GENETICS CBD",1,1.2,11,0.7,size=22,color=C_GOLD,align=PP_ALIGN.CENTER)
tb(sl,"CHROMOSOMAL ANOMALIES",0.5,2.0,12.3,1.1,size=46,bold=True,color=C_WHITE,align=PP_ALIGN.CENTER)
tb(sl,"Definition  |  Down Syndrome  |  Jacob's Syndrome  |  Y-Linked Diseases  |  X-Linked Diseases",
   1,3.22,11.3,0.6,size=15,color=C_GOLD,align=PP_ALIGN.CENTER)
tb(sl,"Sources: Robbins & Kumar Basic Pathology | Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics",
   1,6.8,11.3,0.5,size=10,italic=True,color=RGBColor(0xAA,0xBB,0xCC),align=PP_ALIGN.CENTER)

# ── SLIDE 16 – DEFINITION ───────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"16. Chromosomal Anomalies: Definition","Abnormalities of chromosome number, structure, or both",col=C_NAVY)

# Numerical anomalies
tb(sl,"A. Numerical Abnormalities (Aneuploidy)",0.3,1.35,6.2,0.38,size=14,bold=True,color=C_NAVY)
numerical=[("Monosomy (2n-1)","Loss of 1 chromosome","45,X — Turner syndrome",C_RED),
           ("Trisomy (2n+1)","Extra chromosome","47,+21 — Down syndrome",C_ORANGE),
           ("Tetrasomy","Two extra of same type","48,XXXX",C_PURPLE),
           ("Polyploidy","Complete extra set (lethal)","Triploidy (69,XXX)",RGBColor(0x5D,0x6D,0x7E))]
for i,(name,def_,ex,col) in enumerate(numerical):
    yp=1.82+i*0.68
    cbox(sl,name,0.3,yp,2.2,0.55,col,size=11,bold=True)
    tb(sl,def_,2.6,yp+0.06,2.0,0.45,size=11,color=C_DARK)
    tb(sl,ex,4.65,yp+0.06,1.65,0.45,size=10,color=col,bold=True)

# Structural anomalies
tb(sl,"B. Structural Abnormalities",0.3,4.65,6.2,0.38,size=14,bold=True,color=C_TEAL)
structural=[("Deletion","Loss of segment","5p- (Cri-du-chat)",C_RED),
            ("Duplication","Extra copy","Dup 17p11.2 (CMT1A)",C_ORANGE),
            ("Translocation (Rob.)","Fusion of 2 acrocentrics","rob(14;21) in Down syndrome",C_TEAL),
            ("Translocation (Recip.)","Exchange between non-homologs","t(9;22) — Philadelphia chr",C_NAVY),
            ("Inversion","Reversed segment","inv(9)",C_PURPLE)]
for i,(name,def_,ex,col) in enumerate(structural):
    yp=5.1+i*0.38
    cbox(sl,name,0.3,yp,2.2,0.32,col,size=10,bold=True)
    tb(sl,def_,2.6,yp+0.02,2.0,0.32,size=10,color=C_DARK)
    tb(sl,ex,4.65,yp+0.02,1.65,0.32,size=9,color=col)

# Right panel – causes and frequency
tb(sl,"C. Special Categories",6.8,1.35,6.2,0.38,size=14,bold=True,color=C_NAVY)
special=[("Uniparental Disomy (UPD)","Both homologs from one parent","PWS/Angelman",C_ORANGE),
         ("Mosaicism","Two+ different cell lines","Mosaic Down",C_TEAL),
         ("Genomic imprinting","Epigenetic regulation disruption","PWS/AS",C_PURPLE)]
for i,(name,mech,ex,col) in enumerate(special):
    yp=1.82+i*0.78
    cbox(sl,name,6.8,yp,2.2,0.62,col,size=11,bold=True)
    tb(sl,mech,9.1,yp+0.06,2.5,0.55,size=11,color=C_DARK)
    tb(sl,ex,11.65,yp+0.06,1.5,0.55,size=10,color=col,bold=True)

# Causes
tb(sl,"Causes",6.8,4.22,6.2,0.38,size=14,bold=True,color=C_TEAL)
causes=["Nondisjunction (most common): failure of chromosomes to separate during meiosis I or II",
        "Advanced maternal age: strongly associated with most trisomies",
        "Chromosome breakage: radiation, chemical mutagens, errors in repair",
        "Unequal recombination at segmental duplications (e.g., 15q11-q13)"]
for i,c in enumerate(causes):
    tb(sl,f"• {c}",6.8,4.65+i*0.45,6.2,0.42,size=11,color=C_DARK)

freq=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(6.8),Inches(6.55),Inches(6.2),Inches(0.62))
freq.fill.solid();freq.fill.fore_color.rgb=C_NAVY;freq.line.fill.background();freq.shadow.inherit=False
tb(sl,"Frequency: ~1 in 160 live births have a chromosomal abnormality | ~50% of spontaneous abortions are chromosomally abnormal",
   6.9,6.6,6.0,0.52,size=11,color=C_WHITE)

foot(sl,"Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics | Robbins & Kumar Pathologic Basis of Disease")

# ── SLIDE 17 – DOWN SYNDROME ────────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"17. Down Syndrome (Trisomy 21 / Mongolism)","Most common chromosomal disorder | 1 in 700 live births",col=C_TEAL)

# Karyotype types
tb(sl,"Karyotype Types",0.3,1.35,5.5,0.38,size=14,bold=True,color=C_NAVY)
kary=[("47,XX or XY,+21\n(Free trisomy)","~95%","Meiotic nondisjunction\n95% maternal origin",C_RED),
      ("46 with Robertsonian translocation","~4%","rob(14;21) — familial in some\nMaternal carrier 45,XX,rob(14;21)",C_ORANGE),
      ("Mosaic (46/47)","~1%","Mitotic nondisjunction in early embryo\nMilder phenotype possible",C_TEAL)]
for i,(ktype,pct,mech,col) in enumerate(kary):
    yp=1.82+i*1.0
    cbox(sl,ktype,0.3,yp,2.5,0.72,col,size=11,bold=True)
    cbox(sl,pct,2.88,yp+0.1,0.7,0.52,col,size=14,bold=True)
    tb(sl,mech,3.65,yp+0.1,2.0,0.52,size=10,color=C_DARK)

# Maternal age risk
tb(sl,"Maternal Age Risk",0.3,4.95,5.5,0.38,size=13,bold=True,color=C_TEAL)
age_risks=[("<20 yrs","1:1,550",C_LIME if False else C_GREEN),
           ("30 yrs","1:900",C_ORANGE),("35 yrs","1:385",C_ORANGE),
           ("40 yrs","1:100",C_RED),("≥45 yrs","1:25",C_RED)]
for i,(age,risk,col) in enumerate(age_risks):
    cbox(sl,age,0.3+i*1.08,5.38,0.9,0.45,C_NAVY,size=10,bold=True)
    cbox(sl,risk,0.3+i*1.08,5.88,0.9,0.45,col,size=10,bold=True)

# Clinical features
tb(sl,"Clinical Features",5.9,1.35,7.1,0.38,size=14,bold=True,color=C_NAVY)
cf_down=[
    ("FACIAL","Flat face, epicanthal folds, upslanting palpebral fissures\nBrushfield spots, macroglossia, small ears",C_TEAL),
    ("CNS","Moderate-mild intellectual disability (IQ 40–70)\nHypotonia (universal at birth)",C_NAVY),
    ("CARDIAC\n(40% affected)","AVSD 43% | VSD 32% | ASD 19% | ToF 6%\nLeading cause of death in infancy",C_RED),
    ("GI","Duodenal atresia ('double bubble') | Hirschsprung disease",C_ORANGE),
    ("HAEMATOLOGY","20× ALL risk | 500× AML risk | Transient myeloproliferative disorder",C_PURPLE),
    ("NEURODEGENERATION","Alzheimer disease in virtually ALL patients >40 yrs\n(APP gene × 3 → excess amyloid-β)",RGBColor(0x5D,0x6D,0x7E)),
    ("IMMUNOLOGY","Defective T-cell function → infections | Thyroid autoimmunity 15–20%",RGBColor(0x2E,0x86,0xAB)),
    ("LIFE EXPECTANCY","Median 47 years (was 25 yrs in 1983)\nImproved with cardiac surgery",C_GREEN),
]
for i,(sys,desc,col) in enumerate(cf_down):
    col_i=i%2; row_i=i//2
    xp=5.9+col_i*3.55; yp=1.82+row_i*1.18
    cbox(sl,sys,xp,yp,1.8,0.58,col,size=10,bold=True)
    tb(sl,desc,xp+1.85,yp+0.05,1.6,0.55,size=9,color=C_DARK)

# Prenatal screening
ps=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(6.48),Inches(5.5),Inches(0.7))
ps.fill.solid();ps.fill.fore_color.rgb=C_NAVY;ps.line.fill.background();ps.shadow.inherit=False
tb(sl,"Prenatal Screening:",0.4,6.53,2.0,0.3,size=12,bold=True,color=C_GOLD)
tb(sl,"cfDNA/NIPT (>99% sensitivity) | 1st trimester: NT + PAPP-A + β-hCG | 2nd trimester: Quad screen | Confirm: amniocentesis/CVS + karyotype",
   0.4,6.82,5.3,0.32,size=10,color=C_WHITE)

foot(sl,"Robbins & Kumar Pathologic Basis of Disease, p.163-165 | Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics")

# ── SLIDE 18 – JACOB'S SYNDROME ────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"18. Jacob's Syndrome (47,XYY)","Sex chromosome aneuploidy | Extra Y chromosome | 1 in 1000 male births",col=C_ORANGE)

# Core facts
cbox(sl,"Karyotype: 47,XYY\nIncidence: 1 in 1,000 males\nCause: Nondisjunction in PATERNAL meiosis II\n(100% paternal origin — Y chromatids fail to separate)",
     0.3,1.35,4.5,1.35,C_NAVY,size=12,bold=True)

# Mosaicism note
ms=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(2.78),Inches(4.5),Inches(0.5))
ms.fill.solid();ms.fill.fore_color.rgb=RGBColor(0xFE,0xF9,0xE7);ms.line.color.rgb=C_ORANGE;ms.line.width=Pt(1.5);ms.shadow.inherit=False
tb(sl,"Mosaicism (46,XY/47,XYY): post-zygotic mitotic error — ~10% of cases; milder phenotype",
   0.4,2.83,4.3,0.4,size=11,color=C_DARK)

# Clinical features – 4 domains
tb(sl,"Clinical Features",0.3,3.38,4.5,0.38,size=14,bold=True,color=C_NAVY)
domains=[
    ("Physical",C_TEAL,["Tall stature (>1.88m at final height)",
                        "Macrocephaly | Hypertelorism","Clinodactyly (5th finger)",
                        "Macroorchidism | Macrodontia","Flat feet (pes planus) | Scoliosis"]),
    ("Neurodevelopment",C_ORANGE,["Normal IQ (slightly ↓ vs siblings)",
                                   "Language/reading delays (dyslexia)","Delayed motor milestones",
                                   "ADHD | Anxiety | Depression","Autism spectrum disorder risk"]),
    ("Medical",C_RED,["Asthma (increased incidence)","Seizures / tremors",
                       "Genitourinary anomalies (some)",
                       "Infertility: oligospermia (some)","Most reproduce with normal offspring karyotype"]),
    ("Behavioral",C_PURPLE,["Impulse control difficulties","Emotional dysregulation",
                              "Early studies: antisocial link (now questioned)",
                              "NOT necessarily violent/criminal","Many individuals fully normal"]),
]
for i,(dom,col,items) in enumerate(domains):
    col_i=i%2; row_i=i//2
    xp=0.3+col_i*2.25; yp=3.82+row_i*1.6
    cbox(sl,dom,xp,yp,2.0,0.45,col,size=11,bold=True)
    for j,item in enumerate(items):
        tb(sl,f"• {item}",xp,yp+0.5+j*0.28,2.1,0.26,size=9,color=C_DARK)

# Diagnosis & management
tb(sl,"Diagnosis & Management",5.0,1.35,8.0,0.38,size=14,bold=True,color=C_NAVY)
dm=[("Prenatal","NIPT, amniocentesis, CVS — karyotype 47,XYY confirmed"),
    ("Postnatal","Karyotype from blood lymphocytes | Median Dx age: ~17 yrs (infertility concern)"),
    ("Speech therapy","Early language/speech intervention for language delays"),
    ("Educational","Individualized educational support for learning difficulties"),
    ("Behavioral","CBT, behavioral therapy for impulse control"),
    ("Occupational","Therapy for motor delays"),
    ("Monitoring","Annual check for scoliosis | Endocrine evaluation if growth concerns"),
    ("Genetic counseling","Most offspring have normal karyotype; ART if infertile")]
for i,(cat,desc) in enumerate(dm):
    cbox(sl,cat,5.0,1.82+i*0.62,1.8,0.48,C_TEAL,size=10,bold=True)
    tb(sl,desc,6.9,1.86+i*0.62,6.2,0.46,size=10,color=C_DARK)

foot(sl,"NCBI Bookshelf NBK557699 | Cleveland Clinic | MedlinePlus Genetics | Emery's Elements of Medical Genetics")

# ── SLIDE 19 – Y-LINKED DISEASES ───────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"19. Y-Linked (Holandric) Diseases","Genes on the Y chromosome — father to ALL sons | NO daughters affected",col=C_GREEN)

# Definition box
cbox(sl,"Y-Linked Inheritance Rules:\n• Transmitted exclusively father → son (holandric)\n• ALL sons of affected father are affected\n• NO daughters affected (ever)\n• No female carriers",
     0.3,1.35,5.5,1.1,C_NAVY,size=12,bold=True)

# Y chromosome structure
tb(sl,"Y Chromosome Structure",0.3,2.55,5.5,0.38,size=13,bold=True,color=C_TEAL)
cbox(sl,"PAR1\n(Pseudoautosomal\nRegion 1)",0.3,2.98,1.8,0.85,C_TEAL,size=10,bold=True)
cbox(sl,"MSY\nMale-Specific\nY Region\n(Non-recombining)",2.2,2.98,1.8,0.85,C_NAVY,size=10,bold=True)
cbox(sl,"PAR2\n(Pseudoautosomal\nRegion 2)",4.1,2.98,1.5,0.85,C_TEAL,size=10,bold=True)
tb(sl,"PAR1/2: pair with X during meiosis — NOT truly Y-specific",0.3,3.9,5.5,0.35,size=10,italic=True,color=C_DARK)

# Key Y-linked genes
tb(sl,"Key Y-Linked Genes & Diseases",0.3,4.32,5.5,0.38,size=13,bold=True,color=C_NAVY)
y_genes=[("SRY","Yp11.3","Sex determination\n→ initiates male sex development","SRY mutations → 46,XY sex reversal (female phenotype)",C_RED),
         ("AZFa/b/c\n(Azoospermia\nFactor loci)","Yq11.2","Spermatogenesis — RNA binding\n(DAZ, RBMY, USP9Y)","Microdeletions → azoospermia/oligospermia → male infertility",C_ORANGE),
         ("Hypertrichosis\npinnae","Y (debated)","Hairy ear pinna — classical holandric teaching example","Father-to-all-sons transmission (now debated vs autosomal)",C_TEAL)]
for i,(gene,loc,func,dis,col) in enumerate(y_genes):
    cbox(sl,gene,0.3,4.78+i*0.62,1.1,0.52,col,size=10,bold=True)
    tb(sl,f"Loc: {loc}",1.48,4.8+i*0.62,0.9,0.25,size=9,color=C_DARK)
    tb(sl,func,1.48,5.0+i*0.62,2.2,0.35,size=9,color=C_DARK)
    tb(sl,dis,3.75,4.82+i*0.62,1.95,0.5,size=9,color=col,bold=True)

# Right panel – AZF deletions + Klinefelter
tb(sl,"Y Chromosome Microdeletions (Infertility)",5.9,1.35,7.1,0.38,size=14,bold=True,color=C_NAVY)
azf=[("AZFa deletion","Sertoli-cell-only syndrome — NO germ cells\nTESE: sperm retrieval UNLIKELY",C_RED),
     ("AZFb deletion","Spermatogenic arrest\nTESE: sperm retrieval UNLIKELY",C_ORANGE),
     ("AZFc deletion","Most common (50–60% of AZF dels)\nVariable severity — TESE often SUCCESSFUL",C_TEAL)]
for i,(del_,desc,col) in enumerate(azf):
    yp=1.82+i*1.0
    cbox(sl,del_,5.9,yp,2.3,0.55,col,size=11,bold=True)
    tb(sl,desc,8.3,yp+0.05,4.6,0.52,size=11,color=C_DARK)

# Prevalence
prev=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(5.9),Inches(4.95),Inches(7.1),Inches(0.5))
prev.fill.solid();prev.fill.fore_color.rgb=RGBColor(0xD5,0xF5,0xE3);prev.line.color.rgb=C_GREEN;prev.line.width=Pt(1.5);prev.shadow.inherit=False
tb(sl,"AZF deletion prevalence: ~7–10% of azoospermic men | ~5% of severely oligospermic men",
   6.0,5.0,6.9,0.4,size=11,bold=True,color=C_DARK)

# Klinefelter
tb(sl,"Klinefelter Syndrome (47,XXY) — for comparison",5.9,5.55,7.1,0.38,size=13,bold=True,color=C_NAVY)
kf=["Karyotype: 47,XXY (most common); XXYY, XXXY, XXXXY (increasingly severe)",
    "Incidence: 1 in 500–1,000 male births",
    "Features: tall stature | small testes | azoospermia | gynecomastia | ↓ testosterone | learning difficulties",
    "NOT Y-linked inheritance — involves extra sex chromosome; often de novo nondisjunction"]
for i,k in enumerate(kf):
    tb(sl,f"• {k}",5.9,5.98+i*0.3,7.1,0.28,size=10,color=C_DARK)

foot(sl,"Emery's Elements of Medical Genetics | Thompson & Thompson Genetics 9th ed. | NCBI/GeneReviews")

# ── SLIDE 20 – X-LINKED DISEASES ────────────────────────────────────────────
sl=prs.slides.add_slide(BLANK);bg(sl)
hdr(sl,"20. X-Linked Diseases","Genes on the X chromosome — hemizygous expression in males",col=C_RED)

# Lyon hypothesis box
lh=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(1.35),Inches(12.7),Inches(0.52))
lh.fill.solid();lh.fill.fore_color.rgb=RGBColor(0xFD,0xED,0xEC);lh.line.color.rgb=C_RED;lh.line.width=Pt(2);lh.shadow.inherit=False
tb(sl,"Lyon Hypothesis (X-Inactivation): In females, one X is randomly inactivated per somatic cell at ~16 days post-fertilization → Barr body. Skewed X-inactivation (>90:10) can cause manifesting carriers.",
   0.4,1.4,12.4,0.42,size=11,color=C_DARK)

# XLR rules
tb(sl,"X-Linked RECESSIVE (XLR) Key Rules",0.3,1.97,5.5,0.38,size=13,bold=True,color=C_NAVY)
xlr_rules=["Predominantly affects MALES (hemizygous)",
           "Females usually asymptomatic CARRIERS (heterozygous)",
           "Carrier mother: 50% sons affected | 50% daughters carriers",
           "Affected father: ALL daughters carriers | NO sons affected",
           "NO male-to-male transmission (KEY feature)",
           "Rare affected females: Turner syndrome, homozygous XLR, skewed X-inactivation"]
for i,r in enumerate(xlr_rules):
    cbox(sl,str(i+1),0.3,2.42+i*0.44,0.4,0.37,C_RED,size=12,bold=True)
    tb(sl,r,0.82,2.44+i*0.44,4.8,0.36,size=10,color=C_DARK)

# XLD box
xld=sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,Inches(0.3),Inches(5.12),Inches(5.5),Inches(1.6))
xld.fill.solid();xld.fill.fore_color.rgb=RGBColor(0xD5,0xF5,0xE3);xld.line.color.rgb=C_GREEN;xld.line.width=Pt(1.5);xld.shadow.inherit=False
tb(sl,"X-Linked DOMINANT (XLD):",0.4,5.17,3.0,0.35,size=12,bold=True,color=C_GREEN)
xld_ex=[("Rett Syndrome","MECP2 — progressive neurological disorder; almost exclusively females (males lethal)"),
         ("Incontinentia Pigmenti","IKBKG — skin/dental/CNS/eye; males die in utero"),
         ("Hypophosphatemic Rickets","PHEX — phosphate-wasting; affects both sexes")]
for i,(name,desc) in enumerate(xld_ex):
    tb(sl,f"• {name}:",0.4,5.56+i*0.36,2.1,0.33,size=10,bold=True,color=C_GREEN)
    tb(sl,desc,2.5,5.56+i*0.36,3.2,0.33,size=10,color=C_DARK)

# Right panel – major XLR diseases table
tb(sl,"Major X-Linked Recessive Diseases",5.9,1.97,7.1,0.38,size=13,bold=True,color=C_NAVY)
xlr_diseases=[
    ("Duchenne MD","DMD (dystrophin) Xp21.2","Progressive muscle wasting; Gowers' sign; wheelchair teens; dilated CM",C_RED),
    ("Haemophilia A","F8 (Factor VIII) Xq28","Severe bleeding; haemarthroses; ↓/absent FVIII",C_RED),
    ("Haemophilia B","F9 (Factor IX) Xq27.1","Christmas disease; similar to Hemo A",C_ORANGE),
    ("Fragile X Syndrome","FMR1 (CGG repeat exp.) Xq27.3","Most common inherited ID; macroorchidism; autism; large ears",C_PURPLE),
    ("Colour blindness","OPN1LW/MW Xq28","Most common XL; ~8% males; red-green deficiency",C_TEAL),
    ("G6PD Deficiency","G6PD Xq28","Haemolytic anaemia: drugs/infections/fava beans",C_ORANGE),
    ("Fabry Disease","GLA (α-galactosidase A) Xq22","Lysosomal storage; angiokeratomas; renal failure; cardiac",C_NAVY),
    ("Lesch-Nyhan","HPRT1 Xq26","Gout + ID + self-mutilation; HGPRT deficiency",C_RED),
    ("X-linked Agammaglob.","BTK (Bruton's TK) Xq21.33","Absent B cells; recurrent bacterial infections",C_GREEN),
    ("Wiskott-Aldrich","WAS Xp11.23","Triad: eczema + thrombocytopenia + immunodeficiency",C_PURPLE),
]
for i,(disease,gene,features,col) in enumerate(xlr_diseases):
    col_i=i%2; row_i=i//2
    xp=5.9+col_i*3.55; yp=2.42+row_i*0.92
    cbox(sl,disease,xp,yp,2.0,0.5,col,size=10,bold=True)
    tb(sl,gene,xp+2.05,yp+0.01,1.3,0.28,size=8,color=col,bold=True)
    tb(sl,features,xp+2.05,yp+0.26,1.45,0.32,size=8,color=C_DARK)

foot(sl,"Emery's Elements of Medical Genetics | Thompson & Thompson Genetics 9th ed. | Robbins & Kumar Pathologic Basis of Disease")

# REFERENCES
sl=prs.slides.add_slide(BLANK);bg(sl,C_NAVY)
hdr(sl,"References","Chromosomal Anomalies",col=C_TEAL)
refs3=["1. Robbins R, Kumar V. Robbins & Kumar Basic Pathology. 11th ed. Elsevier; 2023. p.163-165.",
       "2. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
       "3. Turnpenny P, Ellard S. Emery's Elements of Medical Genetics and Genomics. 16th ed. Elsevier; 2022.",
       "4. Bull MJ. Down syndrome. N Engl J Med. 2020;382:2344-2352.",
       "5. Tartaglia NR et al. 47,XYY syndrome. StatPearls/NCBI Bookshelf NBK557699. 2023.",
       "6. Cleveland Clinic. 47,XYY Syndrome (Jacobs Syndrome). my.clevelandclinic.org. 2024.",
       "7. GeneReviews: 47,XYY Syndrome. MedlinePlus Genetics. NIH.",
       "8. Vogt PH et al. Human Y chromosome azoospermia factors (AZF). Hum Reprod. 1996;11:1459-1466."]
for i,r in enumerate(refs3):
    tb(sl,r,0.5,1.4+i*0.65,12.3,0.58,size=12,color=C_WHITE)

buf=BytesIO();prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT4_Chromosomal_Anomalies.pptx","wb") as f:
    f.write(buf.getvalue())
print("PPT4 saved")
Running Command

cd /tmp/workspace/genetics-cbd && python make_ppt1.py && python make_ppt2.py && python make_ppt3.py && python make_ppt4.py

Editing File

~/genetics-cbd/make_ppt2.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/genetics-cbd/make_ppt2.py'
Running Command

cd /tmp/workspace/genetics-cbd && python make_ppt2.py && python make_ppt3.py && python make_ppt4.py

Editing File

~/genetics-cbd/make_ppt2.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/genetics-cbd/make_ppt2.py'
Running Command

cd /tmp/workspace/genetics-cbd && python make_ppt2.py && python make_ppt3.py && python make_ppt4.py && echo "ALL DONE" && ls -lh *.pptx

Running Command

grep -n '"[0-9]' /tmp/workspace/genetics-cbd/make_ppt2.py | head -30

Again

Running Command

ls /tmp/workspace/genetics-cbd/

Writing File

~/genetics-cbd/make_ppt2.py

"""PPT 2: Multifactorial Congenital Malformations - clean version"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)
C_GREEN  = RGBColor(0x1A,0x7A,0x4A)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide, color=C_LIGHT):
    s = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height)
    s.fill.solid(); s.fill.fore_color.rgb = color
    s.line.fill.background(); s.shadow.inherit = False

def hdr(slide, title, subtitle="", col=C_NAVY):
    b = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(1.25))
    b.fill.solid(); b.fill.fore_color.rgb = col
    b.line.fill.background(); b.shadow.inherit = False
    t = slide.shapes.add_textbox(Inches(0.3), Inches(0.05), Inches(12), Inches(0.7))
    p = t.text_frame.paragraphs[0]; p.text = title
    r = p.runs[0]; r.font.size = Pt(28); r.font.bold = True
    r.font.color.rgb = C_WHITE; r.font.name = "Calibri"
    if subtitle:
        t2 = slide.shapes.add_textbox(Inches(0.35), Inches(0.78), Inches(12), Inches(0.45))
        p2 = t2.text_frame.paragraphs[0]; p2.text = subtitle
        r2 = p2.runs[0]; r2.font.size = Pt(15); r2.font.color.rgb = C_GOLD; r2.font.name = "Calibri"

def add_text(slide, text, x, y, w, h, size=13, bold=False, color=C_DARK,
             align=PP_ALIGN.LEFT, italic=False, wrap=True):
    box = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = box.text_frame; tf.word_wrap = wrap
    p = tf.paragraphs[0]; p.text = text; p.alignment = align
    r = p.runs[0]; r.font.size = Pt(size); r.font.bold = bold
    r.font.color.rgb = color; r.font.name = "Calibri"; r.font.italic = italic

def cbox(slide, text, x, y, w, h, bg_c, tc=C_WHITE, size=12, bold=False):
    s = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                               Inches(x), Inches(y), Inches(w), Inches(h))
    s.fill.solid(); s.fill.fore_color.rgb = bg_c
    s.line.fill.background(); s.shadow.inherit = False
    tf = s.text_frame; tf.word_wrap = True; tf.vertical_anchor = MSO_ANCHOR.MIDDLE
    p = tf.paragraphs[0]; p.text = text; p.alignment = PP_ALIGN.CENTER
    r = p.runs[0]; r.font.size = Pt(size); r.font.color.rgb = tc
    r.font.bold = bold; r.font.name = "Calibri"

def foot(slide, ref):
    ln = slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                                    Inches(0.3), Inches(7.15), Inches(13), Inches(7.15))
    ln.line.color.rgb = C_TEAL; ln.line.width = Pt(1)
    add_text(slide, ref, 0.3, 7.18, 12.7, 0.3, size=9, italic=True,
             color=RGBColor(0x55, 0x55, 0x55))

# ── TITLE ────────────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
dec = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.8), prs.slide_width, Inches(0.1))
dec.fill.solid(); dec.fill.fore_color.rgb = C_TEAL
dec.line.fill.background(); dec.shadow.inherit = False
dec2 = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.9), prs.slide_width, Inches(0.04))
dec2.fill.solid(); dec2.fill.fore_color.rgb = C_GOLD
dec2.line.fill.background(); dec2.shadow.inherit = False
add_text(sl, "GENETICS CBD", 1, 1.2, 11, 0.6, size=22, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "MULTIFACTORIAL CONGENITAL\nMALFORMATIONS",
         0.5, 1.85, 12.3, 1.5, size=40, bold=True, color=C_WHITE, align=PP_ALIGN.CENTER)
add_text(sl, "Definition  |  Neuropsychiatric & Bipolar Disease  |  Coronary Artery Disease  |  Modifier Genes  |  Digenic Inheritance",
         1, 3.6, 11.3, 0.6, size=15, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "Sources: Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics | Goldman-Cecil Medicine",
         1, 6.8, 11.3, 0.5, size=10, italic=True,
         color=RGBColor(0xAA, 0xBB, 0xCC), align=PP_ALIGN.CENTER)

# ── SLIDE 6: DEFINITION ──────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "6. Multifactorial Congenital Malformations",
    "Polygenic + environmental threshold model", col=C_TEAL)

add_text(sl,
    "Definition: Conditions caused by interaction of MULTIPLE GENES (polygenic) with ENVIRONMENTAL FACTORS. "
    "No single gene or environmental exposure alone is sufficient — disease appears only when combined liability exceeds a THRESHOLD.",
    0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)

# Threshold model diagram (abstract bell shape with colour blocks)
add_text(sl, "Threshold Model of Liability", 0.3, 2.1, 5.5, 0.38, size=14, bold=True, color=C_NAVY)
# simulate a bell-curve with stacked ovals
for i, (yw, xo, col) in enumerate([
    (0.22, 1.3, RGBColor(0xD6,0xEA,0xF8)),
    (0.30, 1.0, RGBColor(0xA9,0xCC,0xE3)),
    (0.36, 0.7, RGBColor(0x5D,0xAD,0xE8)),
    (0.30, 1.0, RGBColor(0xA9,0xCC,0xE3)),
    (0.22, 1.3, RGBColor(0xD6,0xEA,0xF8)),
]):
    s = sl.shapes.add_shape(MSO_SHAPE.OVAL, Inches(0.4 + xo), Inches(2.55 + i*0.28),
                            Inches(3.8 - xo*0.5), Inches(yw))
    s.fill.solid(); s.fill.fore_color.rgb = col
    s.line.fill.background(); s.shadow.inherit = False
# threshold line
ln = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                              Inches(3.4), Inches(2.5), Inches(3.4), Inches(4.05))
ln.line.color.rgb = C_RED; ln.line.width = Pt(3)
add_text(sl, "THRESHOLD", 3.45, 2.52, 1.8, 0.35, size=11, bold=True, color=C_RED)
add_text(sl, "Normal population",  0.4, 4.1, 2.2, 0.35, size=11, italic=True, color=C_TEAL)
add_text(sl, "Affected", 3.5, 4.1, 1.5, 0.35, size=11, italic=True, color=C_RED)
add_text(sl, "Liability (genes + environment) →", 0.4, 4.5, 5.0, 0.35, size=11, color=C_DARK)

# Characteristics
add_text(sl, "Key Characteristics", 6.1, 1.35, 6.9, 0.38, size=14, bold=True, color=C_NAVY)
chars = [
    "Risk is HIGHER in 1st-degree relatives than the general population",
    "Risk DROPS RAPIDLY with decreasing degree of relationship",
    "Risk INCREASES if multiple family members are affected",
    "Carter Effect: higher risk if proband is the less-commonly affected sex",
    "More severe the malformation → higher recurrence risk",
    "No single Mendelian pattern — polygenic + multifactorial",
]
for i, c in enumerate(chars):
    cbox(sl, str(i+1), 6.1, 1.82 + i*0.72, 0.45, 0.55, C_TEAL, size=13, bold=True)
    add_text(sl, c, 6.65, 1.86 + i*0.72, 6.4, 0.52, size=12, color=C_DARK)

# Table of malformations
add_text(sl, "Common Malformations with Multifactorial Inheritance",
         0.3, 5.02, 5.5, 0.38, size=13, bold=True, color=C_TEAL)
items = [
    ("Congenital heart defects (all)", "4–8 per 1000"),
    ("Neural tube defects", "2–10 per 1000"),
    ("Cleft lip ± palate", "0.4–1.7 per 1000"),
    ("Pyloric stenosis (males)", "5 per 1000"),
    ("Hip dislocation (females)", "2 per 1000"),
    ("Ventricular septal defect", "1.7 per 1000"),
]
for i, (name, inc) in enumerate(items):
    ci = i % 3; ri = i // 2
    xp = 0.3 + ci * 1.75; yp = 5.48 + ri * 0.55
    cbox(sl, name, xp, yp, 1.6, 0.45, C_NAVY, size=9, bold=True)
    add_text(sl, inc, xp, yp + 0.47, 1.6, 0.3, size=9, color=C_ORANGE, bold=True)

foot(sl, "Thompson & Thompson Genetics 9th ed., p.181-182 | Emery's Elements of Medical Genetics | Robbins & Kumar Basic Pathology")

# ── SLIDE 7: NEUROPSYCHIATRIC / BIPOLAR ──────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "7. Neuropsychiatric Disorders & Bipolar Disease",
    "Schizophrenia and Bipolar Disorder — complex multifactorial traits", col=C_PURPLE)

# Schizophrenia
cbox(sl, "SCHIZOPHRENIA", 0.3, 1.35, 6.0, 0.52, C_NAVY, size=16, bold=True)
add_text(sl, "Prevalence: 1% worldwide | Onset: late adolescence/young adulthood",
         0.3, 1.92, 6.0, 0.38, size=12, color=C_DARK)
add_text(sl, "Features: disordered thought, emotion, social relationships; delusions; hallucinations",
         0.3, 2.3, 6.0, 0.4, size=12, color=C_DARK)

add_text(sl, "Recurrence Risks in Schizophrenia", 0.3, 2.82, 6.0, 0.35, size=13, bold=True, color=C_TEAL)
risks = [
    ("Child of 2 affected parents", "46%", C_RED),
    ("Child of 1 affected parent",  "9–16%", C_ORANGE),
    ("Sibling",                     "8–14%", C_ORANGE),
    ("Nephew / niece",              "1–4%",  C_TEAL),
    ("First cousin",                "2–6%",  C_LIME),
]
for i, (rel, risk, col) in enumerate(risks):
    yp = 3.22 + i * 0.5
    cbox(sl, rel,  0.3, yp, 4.2, 0.42, C_LIGHT, tc=C_DARK, size=11)
    cbox(sl, risk, 4.6, yp, 1.6, 0.42, col,     size=13, bold=True)

# Twin concordance
cbox(sl, "MZ: 40–60%", 0.3, 5.75, 2.8, 0.48, C_TEAL, size=13, bold=True)
cbox(sl, "DZ: 10–16%", 3.2, 5.75, 2.8, 0.48, C_ORANGE, size=13, bold=True)
add_text(sl, "22q11 deletion: 25% lifetime risk of schizophrenia",
         0.3, 6.3, 6.0, 0.38, size=11, italic=True, color=C_DARK)

# Bipolar
cbox(sl, "BIPOLAR DISORDER (Manic-Depressive Illness)", 6.5, 1.35, 6.5, 0.52, C_ORANGE, size=14, bold=True, tc=C_DARK)
add_text(sl, "Prevalence: 1–2% worldwide | Heritability: ~70–80%\nCycles of mania and depression",
         6.5, 1.92, 6.5, 0.55, size=12, color=C_DARK)

add_text(sl, "Genetic Evidence", 6.5, 2.6, 6.5, 0.35, size=13, bold=True, color=C_NAVY)
bp = [
    ("MZ concordance",          "40–70%",            C_ORANGE),
    ("DZ concordance",          "15–25%",            C_LIME),
    ("1st-degree relative risk","~10× general pop",  C_RED),
    ("Heritability",            "~70–80%",           C_TEAL),
]
for i, (label, val, col) in enumerate(bp):
    xp = 6.5 + (i % 2) * 3.2; yp = 3.02 + (i // 2) * 0.72
    cbox(sl, label, xp, yp, 2.9, 0.45, col, size=11, bold=True)
    add_text(sl, val, xp + 0.1, yp + 0.48, 2.8, 0.3, size=12, bold=True, color=col)

add_text(sl, "GWAS Loci (Bipolar Disorder)", 6.5, 4.62, 6.5, 0.35, size=13, bold=True, color=C_NAVY)
loci = [
    "CACNA1C — voltage-gated calcium channel",
    "ANK3 — ankyrin G, axon initial segment",
    "NCAN — neurocan ECM glycoprotein",
    "TRANK1 | SYNE1 — risk loci",
    "Overlapping genetic architecture with schizophrenia (cross-disorder genetics)",
]
for i, l in enumerate(loci):
    add_text(sl, f"• {l}", 6.5, 5.02 + i * 0.38, 6.5, 0.36, size=11, color=C_DARK)

ge = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(6.78), Inches(12.7), Inches(0.42))
ge.fill.solid(); ge.fill.fore_color.rgb = RGBColor(0xE8, 0xF4, 0xF8)
ge.line.color.rgb = C_TEAL; ge.line.width = Pt(1); ge.shadow.inherit = False
add_text(sl, "Gene × Environment Triggers: childhood trauma | sleep disruption | cannabis | obstetric complications | urban birth",
         0.4, 6.82, 12.4, 0.35, size=11, color=C_NAVY)

foot(sl, "Thompson & Thompson Genetics 9th ed., p.182-183 | Goldman-Cecil Medicine, International Edition")

# ── SLIDE 8: CORONARY ARTERY DISEASE ─────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "8. Coronary Artery Disease (CAD)",
    "Most common cause of death globally — complex multifactorial disease", col=C_RED)

add_text(sl, "Genetic Evidence from Twin Studies", 0.3, 1.35, 6.2, 0.38, size=14, bold=True, color=C_NAVY)
headers = ["Twin pair", "Concordance", "Relative risk vs. pop."]
for i, h in enumerate(headers):
    cbox(sl, h, 0.3 + i*2.0, 1.82, 1.85, 0.42, C_NAVY, size=11, bold=True)
twin_data = [
    ("Male MZ twins",   "39%", "6–8×"),
    ("Male DZ twins",   "26%", "3×"),
    ("Female MZ twins", "44%", "15×"),
    ("Female DZ twins", "14%", "2.6×"),
]
for i, (pair, conc, rr) in enumerate(twin_data):
    yp = 2.3 + i * 0.5
    bg_cols = [C_LIGHT, C_ORANGE, C_RED]
    for j, (val, bgc) in enumerate(zip([pair, conc, rr], bg_cols)):
        cbox(sl, val, 0.3 + j*2.0, yp, 1.85, 0.42, bgc,
             tc=C_DARK if bgc == C_LIGHT else C_WHITE, size=11, bold=(j > 0))

add_text(sl, "Stepwise Pathway — Genetic Factors", 0.3, 4.62, 6.2, 0.38, size=13, bold=True, color=C_TEAL)
stages = [
    ("Lipid metabolism",    "APOE, LDLR, APOC3, LPA (lipoprotein(a))",              C_TEAL),
    ("Vasoactivity",        "ACE (angiotensin-converting enzyme), AGTR1",            C_ORANGE),
    ("Coagulation",         "Factor V Leiden (R506Q), Prothrombin G20210A",          C_RED),
    ("Inflammation",        "IL-6, CRP, TNF-alpha loci",                             C_PURPLE),
    ("Endothelial function","NOS3 (endothelial nitric oxide synthase)",              C_GREEN),
]
for i, (stage, genes, col) in enumerate(stages):
    yp = 5.05 + i * 0.38
    cbox(sl, stage, 0.3, yp, 2.0, 0.32, col, size=10, bold=True)
    add_text(sl, genes, 2.4, yp + 0.02, 4.1, 0.3, size=10, color=C_DARK)

# Right panel
add_text(sl, "Environmental Risk Factors", 6.6, 1.35, 6.4, 0.38, size=14, bold=True, color=C_NAVY)
env = ["Diet: saturated fats, trans fats",
       "Physical inactivity",
       "Smoking",
       "Obesity & type 2 diabetes mellitus",
       "Systemic inflammation"]
for i, e in enumerate(env):
    cbox(sl, e, 6.6, 1.82 + i*0.55, 6.2, 0.45, C_LIGHT, tc=C_DARK, size=12)

add_text(sl, "Key GWAS Findings", 6.6, 4.65, 6.4, 0.38, size=14, bold=True, color=C_TEAL)
gwas = [
    "9p21.3 locus — strongest replicated CAD locus (CDKN2A/CDKN2B)",
    ">300 independent loci identified genome-wide",
    "Polygenic Risk Scores (PRS) show clinical utility",
    "Familial Hypercholesterolaemia: LDLR mutations (AD) → markedly elevated LDL",
    "Intermediate traits (HTN, DM, obesity) each have additional genetic architecture",
]
for i, g in enumerate(gwas):
    add_text(sl, f"• {g}", 6.6, 5.1 + i*0.42, 6.4, 0.4, size=11, color=C_DARK)

foot(sl, "Thompson & Thompson Genetics 9th ed., p.183-184 | Goldman-Cecil Medicine")

# ── SLIDE 9: MODIFIER GENES ──────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "9. Modifier Genes",
    "Secondary gene loci that modulate disease severity without causing the disease", col=C_TEAL)

add_text(sl,
    "Definition: Modifier genes are genes whose allelic variants affect the EXPRESSION, SEVERITY, or PHENOTYPE "
    "of a disease caused by mutations in a DIFFERENT primary gene. They do not cause the disease themselves.",
    0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)

cbox(sl, "CLASSIC EXAMPLE: CYSTIC FIBROSIS (CF)",
     0.3, 2.1, 12.7, 0.52, C_NAVY, size=15, bold=True)
add_text(sl, "Primary gene: CFTR  |  Variable phenotype NOT fully explained by CFTR genotype alone",
         0.3, 2.68, 12.7, 0.38, size=13, color=C_DARK)

for i, (name, desc, effect, col) in enumerate([
    ("MBL2\n(Mannose-Binding Lectin 2)",
     "Innate immunity plasma protein — binds pathogens, aids phagocytosis & complement activation\n"
     "Low MBL2 alleles → reduced innate immunity → worse Pseudomonas containment in CF airways",
     "Low MBL2 alleles → WORSE pulmonary outcome in CF", C_TEAL),
    ("TGFB1\n(Transforming Growth Factor-β)",
     "High TGFβ-producing alleles → increased lung fibrosis/scarring\n"
     "after chronic neutrophilic inflammation in CF airways",
     "High TGFB1 alleles → WORSE FEV1 decline in CF", C_ORANGE),
]):
    xp = 0.3 + i * 6.4
    cbox(sl, name, xp, 3.18, 2.3, 0.85, col, size=12, bold=True)
    add_text(sl, desc, xp + 2.4, 3.22, 3.8, 0.8, size=11, color=C_DARK)
    cbox(sl, effect, xp, 4.1, 6.2, 0.48, C_LIGHT, tc=col, size=11, bold=True)

note = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(0.3), Inches(4.68), Inches(12.7), Inches(0.52))
note.fill.solid(); note.fill.fore_color.rgb = RGBColor(0xE8, 0xF4, 0xF8)
note.line.color.rgb = C_TEAL; note.line.width = Pt(1); note.shadow.inherit = False
add_text(sl,
    "CF Lung Disease Heritability: ~50% (MZ vs DZ twins in CF patients) — INDEPENDENT of CFTR allele; "
    "confirms ~50% of lung disease severity is due to genes OTHER than CFTR",
    0.4, 4.73, 12.4, 0.42, size=11, bold=True, color=C_NAVY)

add_text(sl, "Further Examples of Modifier Genes", 0.3, 5.32, 12.7, 0.38, size=14, bold=True, color=C_NAVY)
headers2 = ["Primary Disease", "Modifier Gene", "Effect on Phenotype"]
for i, h in enumerate(headers2):
    cbox(sl, h, 0.3 + i*4.2, 5.75, 4.0, 0.38, C_NAVY, size=11, bold=True)
rows = [
    ("Cystic fibrosis",                 "MBL2 / TGFB1",                 "Pulmonary disease severity"),
    ("Sickle cell disease",             "BCL11A, HBG (fetal Hb regulators)", "Severity of crises"),
    ("Familial hypercholesterolaemia",  "APOE genotype",                 "Cardiovascular severity"),
    ("Huntington disease",              "MSH3 (DNA mismatch repair)",    "Age of onset modulation"),
]
for i, (pd, mg, eff) in enumerate(rows):
    yp = 6.18 + i * 0.3
    for j, (val, bgc) in enumerate(zip([pd, mg, eff],
                                       [C_LIGHT, RGBColor(0xD6,0xEA,0xF8), RGBColor(0xD5,0xF5,0xE3)])):
        cbox(sl, val, 0.3 + j*4.2, yp, 4.0, 0.28, bgc, tc=C_DARK, size=10)

foot(sl, "Thompson & Thompson Genetics 9th ed., p.185 | Goldman-Cecil Medicine | Harrison's Principles 22E")

# ── SLIDE 10: DIGENIC INHERITANCE ────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "10. Digenic Inheritance",
    "Simplest multigenic inheritance — disease requires mutations at TWO different loci", col=C_NAVY)

add_text(sl,
    "Definition: Disease manifests ONLY when pathogenic variants at TWO DIFFERENT GENE LOCI are combined. "
    "Heterozygous variants at either locus alone are insufficient — only the co-occurrence of both causes the phenotype.",
    0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)

# Diagram
cbox(sl, "Gene A\n(Heterozygous)\nCarrier — unaffected",
     0.5, 2.15, 2.8, 1.05, C_TEAL, size=12, bold=True)
add_text(sl, "+", 3.4, 2.45, 0.5, 0.55, size=24, bold=True, color=C_DARK, align=PP_ALIGN.CENTER)
cbox(sl, "Gene B\n(Heterozygous)\nCarrier — unaffected",
     4.0, 2.15, 2.8, 1.05, C_ORANGE, size=12, bold=True)
add_text(sl, "=", 6.9, 2.45, 0.5, 0.55, size=24, bold=True, color=C_DARK, align=PP_ALIGN.CENTER)
cbox(sl, "DISEASE\n(Both mutations present together)",
     7.5, 2.15, 2.8, 1.05, C_RED, size=12, bold=True)
# neither alone
cbox(sl, "Gene A alone → NORMAL",  0.5,  3.35, 2.8, 0.38, C_LIGHT, tc=C_TEAL, size=11, bold=True)
cbox(sl, "Gene B alone → NORMAL",  4.0,  3.35, 2.8, 0.38, C_LIGHT, tc=C_ORANGE, size=11, bold=True)
cbox(sl, "Both together → DISEASE", 7.5, 3.35, 2.8, 0.38, C_RED, size=11, bold=True)

# Characteristics
add_text(sl, "Key Characteristics", 0.3, 3.95, 5.5, 0.38, size=14, bold=True, color=C_NAVY)
chars = [
    "Neither mutation alone causes disease",
    "Parents carrying one mutation each are UNAFFECTED",
    "Child inheriting BOTH mutations has 25% risk (if parents carry at different loci)",
    "Appears sporadic/recessive-like in pedigrees",
    "Key distinction: AR = 2 mutations SAME locus; Digenic = 1 mutation at EACH of 2 DIFFERENT loci",
]
for i, c in enumerate(chars):
    cbox(sl, str(i+1), 0.3, 4.38 + i*0.5, 0.42, 0.42, C_TEAL, size=13, bold=True)
    add_text(sl, c, 0.82, 4.4 + i*0.5, 5.0, 0.44, size=11, color=C_DARK)

# Examples
add_text(sl, "Clinical Examples", 6.4, 3.95, 6.6, 0.38, size=14, bold=True, color=C_NAVY)
examples = [
    ("Digenic Retinitis Pigmentosa", C_RED,
     "ROM1 + PRPH2 (peripherin)\nEither gene alone = normal vision; both together = RP"),
    ("Waardenburg Syndrome Type III", C_PURPLE,
     "PAX3 + MITF heterozygosity\nBoth required for the full phenotype"),
    ("Bardet-Biedl Syndrome", C_ORANGE,
     "Mutations at 2+ BBS loci (oligogenic/triallelic)\nIllustrates extension to oligogenic inheritance"),
    ("Hereditary Deafness (GJB2/GJB6)", C_TEAL,
     "Connexin 26 + Connexin 30\nDeletion of one + mutation in other → deafness"),
]
for i, (name, col, desc) in enumerate(examples):
    yp = 4.42 + i * 0.65
    cbox(sl, name, 6.4, yp, 6.4, 0.42, col, size=11, bold=True)
    add_text(sl, desc, 6.5, yp + 0.45, 6.2, 0.4, size=10, color=C_DARK)

cs = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(6.82), Inches(12.7), Inches(0.42))
cs.fill.solid(); cs.fill.fore_color.rgb = C_NAVY
cs.line.fill.background(); cs.shadow.inherit = False
add_text(sl,
    "Clinical Significance: Explains sporadic cases in single-carrier families | "
    "Critical for genomic sequencing interpretation — VUS at two loci may act diigenically",
    0.4, 6.87, 12.4, 0.35, size=11, color=C_WHITE)

foot(sl, "Emery's Elements of Medical Genetics (citing Schäffer, J Med Genet 2013) | Thompson & Thompson Genetics 9th ed.")

# ── REFERENCES ───────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
hdr(sl, "References", "Multifactorial Congenital Malformations", col=C_TEAL)
refs = [
    "1. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
    "2. Turnpenny P, Ellard S. Emery's Elements of Medical Genetics and Genomics. 16th ed. Elsevier; 2022.",
    "3. Goldman L, Schafer AI. Goldman-Cecil Medicine. 27th ed. International ed. Elsevier; 2024.",
    "4. Loscalzo J et al. Harrison's Principles of Internal Medicine. 22nd ed. McGraw-Hill; 2025.",
    "5. Robbins R, Kumar V. Robbins & Kumar Basic Pathology. 11th ed. Elsevier; 2023.",
    "6. Schäffer AA. Digenic inheritance in medical genetics. J Med Genet. 2013;50:641-652.",
    "7. Marchenko ME. Genetic susceptibility to death from coronary heart disease. NEJM. 1994;330:1041-1046.",
]
for i, r in enumerate(refs):
    add_text(sl, r, 0.5, 1.4 + i*0.72, 12.3, 0.65, size=12, color=C_WHITE)

buf = BytesIO(); prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT2_Multifactorial_Malformations.pptx", "wb") as f:
    f.write(buf.getvalue())
print("PPT2 saved OK")
Running Command

rm /tmp/workspace/genetics-cbd/make_ppt2.py /tmp/workspace/genetics-cbd/make_ppt3.py /tmp/workspace/genetics-cbd/make_ppt4.py

Writing File

~/genetics-cbd/make_ppt2.py

"""PPT 2: Multifactorial Congenital Malformations - clean version"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)
C_GREEN  = RGBColor(0x1A,0x7A,0x4A)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide, color=C_LIGHT):
    s = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height)
    s.fill.solid(); s.fill.fore_color.rgb = color
    s.line.fill.background(); s.shadow.inherit = False

def hdr(slide, title, subtitle="", col=C_NAVY):
    b = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(1.25))
    b.fill.solid(); b.fill.fore_color.rgb = col
    b.line.fill.background(); b.shadow.inherit = False
    t = slide.shapes.add_textbox(Inches(0.3), Inches(0.05), Inches(12), Inches(0.7))
    p = t.text_frame.paragraphs[0]; p.text = title
    r = p.runs[0]; r.font.size = Pt(28); r.font.bold = True
    r.font.color.rgb = C_WHITE; r.font.name = "Calibri"
    if subtitle:
        t2 = slide.shapes.add_textbox(Inches(0.35), Inches(0.78), Inches(12), Inches(0.45))
        p2 = t2.text_frame.paragraphs[0]; p2.text = subtitle
        r2 = p2.runs[0]; r2.font.size = Pt(15); r2.font.color.rgb = C_GOLD; r2.font.name = "Calibri"

def add_text(slide, text, x, y, w, h, size=13, bold=False, color=C_DARK,
             align=PP_ALIGN.LEFT, italic=False, wrap=True):
    box = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = box.text_frame; tf.word_wrap = wrap
    p = tf.paragraphs[0]; p.text = text; p.alignment = align
    r = p.runs[0]; r.font.size = Pt(size); r.font.bold = bold
    r.font.color.rgb = color; r.font.name = "Calibri"; r.font.italic = italic

def cbox(slide, text, x, y, w, h, bg_c, tc=C_WHITE, size=12, bold=False):
    s = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                               Inches(x), Inches(y), Inches(w), Inches(h))
    s.fill.solid(); s.fill.fore_color.rgb = bg_c
    s.line.fill.background(); s.shadow.inherit = False
    tf = s.text_frame; tf.word_wrap = True; tf.vertical_anchor = MSO_ANCHOR.MIDDLE
    p = tf.paragraphs[0]; p.text = text; p.alignment = PP_ALIGN.CENTER
    r = p.runs[0]; r.font.size = Pt(size); r.font.color.rgb = tc
    r.font.bold = bold; r.font.name = "Calibri"

def foot(slide, ref):
    ln = slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                                    Inches(0.3), Inches(7.15), Inches(13), Inches(7.15))
    ln.line.color.rgb = C_TEAL; ln.line.width = Pt(1)
    add_text(slide, ref, 0.3, 7.18, 12.7, 0.3, size=9, italic=True,
             color=RGBColor(0x55, 0x55, 0x55))

# ── TITLE ────────────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
dec = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.8), prs.slide_width, Inches(0.1))
dec.fill.solid(); dec.fill.fore_color.rgb = C_TEAL
dec.line.fill.background(); dec.shadow.inherit = False
dec2 = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.9), prs.slide_width, Inches(0.04))
dec2.fill.solid(); dec2.fill.fore_color.rgb = C_GOLD
dec2.line.fill.background(); dec2.shadow.inherit = False
add_text(sl, "GENETICS CBD", 1, 1.2, 11, 0.6, size=22, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "MULTIFACTORIAL CONGENITAL\nMALFORMATIONS",
         0.5, 1.85, 12.3, 1.5, size=40, bold=True, color=C_WHITE, align=PP_ALIGN.CENTER)
add_text(sl, "Definition  |  Neuropsychiatric & Bipolar Disease  |  Coronary Artery Disease  |  Modifier Genes  |  Digenic Inheritance",
         1, 3.6, 11.3, 0.6, size=15, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "Sources: Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics | Goldman-Cecil Medicine",
         1, 6.8, 11.3, 0.5, size=10, italic=True,
         color=RGBColor(0xAA, 0xBB, 0xCC), align=PP_ALIGN.CENTER)

# ── SLIDE 6: DEFINITION ──────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "6. Multifactorial Congenital Malformations",
    "Polygenic + environmental threshold model", col=C_TEAL)
add_text(sl,
    "Definition: Conditions caused by interaction of MULTIPLE GENES (polygenic) with ENVIRONMENTAL FACTORS. "
    "No single gene or environmental exposure alone is sufficient. Disease appears only when combined liability exceeds a THRESHOLD.",
    0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)
add_text(sl, "Threshold Model of Liability", 0.3, 2.1, 5.5, 0.38, size=14, bold=True, color=C_NAVY)
for i, (yw, xo, col) in enumerate([
    (0.22, 1.3, RGBColor(0xD6,0xEA,0xF8)),
    (0.30, 1.0, RGBColor(0xA9,0xCC,0xE3)),
    (0.36, 0.7, RGBColor(0x5D,0xAD,0xE8)),
    (0.30, 1.0, RGBColor(0xA9,0xCC,0xE3)),
    (0.22, 1.3, RGBColor(0xD6,0xEA,0xF8)),
]):
    s = sl.shapes.add_shape(MSO_SHAPE.OVAL, Inches(0.4 + xo), Inches(2.55 + i*0.28),
                            Inches(3.8 - xo*0.5), Inches(yw))
    s.fill.solid(); s.fill.fore_color.rgb = col
    s.line.fill.background(); s.shadow.inherit = False
ln = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                              Inches(3.4), Inches(2.5), Inches(3.4), Inches(4.05))
ln.line.color.rgb = C_RED; ln.line.width = Pt(3)
add_text(sl, "THRESHOLD", 3.45, 2.52, 1.8, 0.35, size=11, bold=True, color=C_RED)
add_text(sl, "Normal population", 0.4, 4.1, 2.2, 0.35, size=11, italic=True, color=C_TEAL)
add_text(sl, "Affected", 3.5, 4.1, 1.5, 0.35, size=11, italic=True, color=C_RED)
add_text(sl, "Liability (genes + environment) ->", 0.4, 4.5, 5.0, 0.35, size=11, color=C_DARK)
add_text(sl, "Key Characteristics", 6.1, 1.35, 6.9, 0.38, size=14, bold=True, color=C_NAVY)
chars = [
    "Risk is HIGHER in 1st-degree relatives than the general population",
    "Risk DROPS RAPIDLY with decreasing degree of relationship",
    "Risk INCREASES if multiple family members are affected",
    "Carter Effect: higher risk if proband is the less-commonly affected sex",
    "More severe the malformation, higher the recurrence risk",
    "No single Mendelian pattern -- polygenic + multifactorial",
]
for i, c in enumerate(chars):
    cbox(sl, str(i+1), 6.1, 1.82 + i*0.72, 0.45, 0.55, C_TEAL, size=13, bold=True)
    add_text(sl, c, 6.65, 1.86 + i*0.72, 6.4, 0.52, size=12, color=C_DARK)
add_text(sl, "Common Malformations with Multifactorial Inheritance",
         0.3, 5.02, 5.5, 0.38, size=13, bold=True, color=C_TEAL)
items = [
    ("Congenital heart defects", "4-8 per 1000"),
    ("Neural tube defects", "2-10 per 1000"),
    ("Cleft lip +/- palate", "0.4-1.7 per 1000"),
    ("Pyloric stenosis (males)", "5 per 1000"),
    ("Hip dislocation (females)", "2 per 1000"),
    ("Ventricular septal defect", "1.7 per 1000"),
]
for i, (name, inc) in enumerate(items):
    ci = i % 3; ri = i // 3
    xp = 0.3 + ci * 1.75; yp = 5.48 + ri * 0.72
    cbox(sl, name, xp, yp, 1.6, 0.45, C_NAVY, size=9, bold=True)
    add_text(sl, inc, xp, yp + 0.48, 1.6, 0.28, size=9, color=C_ORANGE, bold=True)
foot(sl, "Thompson & Thompson Genetics 9th ed., p.181-182 | Emery's Elements of Medical Genetics | Robbins & Kumar Basic Pathology")

# ── SLIDE 7: NEUROPSYCHIATRIC / BIPOLAR ──────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "7. Neuropsychiatric Disorders & Bipolar Disease",
    "Schizophrenia and Bipolar Disorder -- complex multifactorial traits", col=C_PURPLE)
cbox(sl, "SCHIZOPHRENIA", 0.3, 1.35, 6.0, 0.52, C_NAVY, size=16, bold=True)
add_text(sl, "Prevalence: 1% worldwide | Onset: late adolescence/young adulthood",
         0.3, 1.92, 6.0, 0.38, size=12, color=C_DARK)
add_text(sl, "Features: disordered thought, emotion, social relationships; delusions; hallucinations",
         0.3, 2.3, 6.0, 0.4, size=12, color=C_DARK)
add_text(sl, "Recurrence Risks in Schizophrenia", 0.3, 2.82, 6.0, 0.35, size=13, bold=True, color=C_TEAL)
risks = [
    ("Child of 2 affected parents", "46%",  C_RED),
    ("Child of 1 affected parent",  "9-16%", C_ORANGE),
    ("Sibling",                     "8-14%", C_ORANGE),
    ("Nephew / niece",              "1-4%",  C_TEAL),
    ("First cousin",                "2-6%",  C_LIME),
]
for i, (rel, risk, col) in enumerate(risks):
    yp = 3.22 + i * 0.5
    cbox(sl, rel,  0.3, yp, 4.2, 0.42, C_LIGHT, tc=C_DARK, size=11)
    cbox(sl, risk, 4.6, yp, 1.6, 0.42, col, size=13, bold=True)
cbox(sl, "MZ twins: 40-60%", 0.3, 5.75, 2.8, 0.48, C_TEAL, size=13, bold=True)
cbox(sl, "DZ twins: 10-16%", 3.2, 5.75, 2.8, 0.48, C_ORANGE, size=13, bold=True)
add_text(sl, "22q11 deletion: 25% lifetime risk of schizophrenia",
         0.3, 6.3, 6.0, 0.38, size=11, italic=True, color=C_DARK)
cbox(sl, "BIPOLAR DISORDER (Manic-Depressive Illness)", 6.5, 1.35, 6.5, 0.52, C_ORANGE, size=14, bold=True, tc=C_DARK)
add_text(sl, "Prevalence: 1-2% worldwide | Heritability: ~70-80% | Cycles of mania and depression",
         6.5, 1.92, 6.5, 0.45, size=12, color=C_DARK)
add_text(sl, "Genetic Evidence", 6.5, 2.5, 6.5, 0.35, size=13, bold=True, color=C_NAVY)
bp = [
    ("MZ concordance",           "40-70%",           C_ORANGE),
    ("DZ concordance",           "15-25%",           C_LIME),
    ("1st-degree relative risk", "~10x general pop", C_RED),
    ("Heritability",             "~70-80%",          C_TEAL),
]
for i, (label, val, col) in enumerate(bp):
    xp = 6.5 + (i % 2) * 3.2; yp = 2.92 + (i // 2) * 0.72
    cbox(sl, label, xp, yp, 2.9, 0.45, col, size=11, bold=True)
    add_text(sl, val, xp + 0.1, yp + 0.48, 2.8, 0.28, size=12, bold=True, color=col)
add_text(sl, "GWAS Loci (Bipolar Disorder)", 6.5, 4.55, 6.5, 0.35, size=13, bold=True, color=C_NAVY)
loci = [
    "CACNA1C -- voltage-gated calcium channel",
    "ANK3 -- ankyrin G, axon initial segment",
    "NCAN -- neurocan ECM glycoprotein",
    "TRANK1 | SYNE1 -- additional risk loci",
    "Overlapping genetic architecture with schizophrenia (cross-disorder genetics)",
]
for i, l in enumerate(loci):
    add_text(sl, "* " + l, 6.5, 4.95 + i * 0.38, 6.5, 0.36, size=11, color=C_DARK)
ge = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(6.78), Inches(12.7), Inches(0.42))
ge.fill.solid(); ge.fill.fore_color.rgb = RGBColor(0xE8, 0xF4, 0xF8)
ge.line.color.rgb = C_TEAL; ge.line.width = Pt(1); ge.shadow.inherit = False
add_text(sl, "Gene x Environment Triggers: childhood trauma | sleep disruption | cannabis | obstetric complications | urban birth",
         0.4, 6.82, 12.4, 0.35, size=11, color=C_NAVY)
foot(sl, "Thompson & Thompson Genetics 9th ed., p.182-183 | Goldman-Cecil Medicine, International Edition")

# ── SLIDE 8: CORONARY ARTERY DISEASE ─────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "8. Coronary Artery Disease (CAD)",
    "Most common cause of death globally -- complex multifactorial disease", col=C_RED)
add_text(sl, "Genetic Evidence from Twin Studies", 0.3, 1.35, 6.2, 0.38, size=14, bold=True, color=C_NAVY)
for i, h in enumerate(["Twin pair", "Concordance", "Relative risk vs. pop."]):
    cbox(sl, h, 0.3 + i*2.0, 1.82, 1.85, 0.42, C_NAVY, size=11, bold=True)
twin_data = [
    ("Male MZ twins",   "39%", "6-8x"),
    ("Male DZ twins",   "26%", "3x"),
    ("Female MZ twins", "44%", "15x"),
    ("Female DZ twins", "14%", "2.6x"),
]
for i, (pair, conc, rr) in enumerate(twin_data):
    yp = 2.3 + i * 0.5
    for j, (val, bgc, tc) in enumerate([(pair, C_LIGHT, C_DARK),
                                         (conc, C_ORANGE, C_WHITE),
                                         (rr, C_RED, C_WHITE)]):
        cbox(sl, val, 0.3 + j*2.0, yp, 1.85, 0.42, bgc, tc=tc, size=11, bold=(j > 0))
add_text(sl, "Stepwise Pathway -- Genetic Factors", 0.3, 4.62, 6.2, 0.38, size=13, bold=True, color=C_TEAL)
stages = [
    ("Lipid metabolism",     "APOE, LDLR, APOC3, LPA (lipoprotein(a))",     C_TEAL),
    ("Vasoactivity",         "ACE (angiotensin-converting enzyme), AGTR1",   C_ORANGE),
    ("Coagulation",          "Factor V Leiden (R506Q), Prothrombin G20210A", C_RED),
    ("Inflammation",         "IL-6, CRP, TNF-alpha loci",                    C_PURPLE),
    ("Endothelial function", "NOS3 (endothelial nitric oxide synthase)",     C_GREEN),
]
for i, (stage, genes, col) in enumerate(stages):
    yp = 5.05 + i * 0.38
    cbox(sl, stage, 0.3, yp, 2.0, 0.32, col, size=10, bold=True)
    add_text(sl, genes, 2.4, yp + 0.02, 4.1, 0.3, size=10, color=C_DARK)
add_text(sl, "Environmental Risk Factors", 6.6, 1.35, 6.4, 0.38, size=14, bold=True, color=C_NAVY)
for i, e in enumerate(["Diet: saturated fats, trans fats", "Physical inactivity", "Smoking",
                        "Obesity & type 2 diabetes mellitus", "Systemic inflammation"]):
    cbox(sl, e, 6.6, 1.82 + i*0.55, 6.2, 0.45, C_LIGHT, tc=C_DARK, size=12)
add_text(sl, "Key GWAS Findings", 6.6, 4.65, 6.4, 0.38, size=14, bold=True, color=C_TEAL)
for i, g in enumerate([
    "9p21.3 locus -- strongest replicated CAD locus (CDKN2A/CDKN2B region)",
    ">300 independent loci identified genome-wide",
    "Polygenic Risk Scores (PRS) show growing clinical utility",
    "Familial Hypercholesterolaemia: LDLR mutations (AD) markedly raise LDL",
    "Intermediate traits (HTN, DM, obesity) each have additional genetic architecture",
]):
    add_text(sl, "* " + g, 6.6, 5.1 + i*0.42, 6.4, 0.4, size=11, color=C_DARK)
foot(sl, "Thompson & Thompson Genetics 9th ed., p.183-184 | Goldman-Cecil Medicine")

# ── SLIDE 9: MODIFIER GENES ──────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "9. Modifier Genes",
    "Secondary gene loci that modulate disease severity without causing the disease", col=C_TEAL)
add_text(sl,
    "Definition: Modifier genes are genes whose allelic variants affect the EXPRESSION, SEVERITY, or PHENOTYPE "
    "of a disease caused by mutations in a DIFFERENT primary gene. They do not cause the disease themselves.",
    0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)
cbox(sl, "CLASSIC EXAMPLE: CYSTIC FIBROSIS (CF)",
     0.3, 2.1, 12.7, 0.52, C_NAVY, size=15, bold=True)
add_text(sl, "Primary gene: CFTR  |  Variable phenotype NOT fully explained by CFTR genotype alone",
         0.3, 2.68, 12.7, 0.38, size=13, color=C_DARK)
for i, (name, desc, effect, col) in enumerate([
    ("MBL2\n(Mannose-Binding Lectin 2)",
     "Innate immunity plasma protein -- binds pathogens\n"
     "Low MBL2 alleles -> reduced innate immunity -> worse Pseudomonas containment in CF",
     "Low MBL2 alleles -> WORSE pulmonary outcome in CF", C_TEAL),
    ("TGFB1\n(Transforming Growth Factor-b)",
     "High TGFb-producing alleles -> increased lung fibrosis/scarring\n"
     "after chronic neutrophilic inflammation in CF airways",
     "High TGFB1 alleles -> WORSE FEV1 decline in CF", C_ORANGE),
]):
    xp = 0.3 + i * 6.4
    cbox(sl, name, xp, 3.18, 2.3, 0.85, col, size=12, bold=True)
    add_text(sl, desc, xp + 2.4, 3.22, 3.8, 0.8, size=11, color=C_DARK)
    cbox(sl, effect, xp, 4.1, 6.2, 0.48, C_LIGHT, tc=col, size=11, bold=True)
note = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(0.3), Inches(4.68), Inches(12.7), Inches(0.52))
note.fill.solid(); note.fill.fore_color.rgb = RGBColor(0xE8, 0xF4, 0xF8)
note.line.color.rgb = C_TEAL; note.line.width = Pt(1); note.shadow.inherit = False
add_text(sl,
    "CF Lung Disease Heritability: ~50% (from MZ vs DZ twins in CF patients) -- "
    "INDEPENDENT of CFTR allele; confirms 50% of lung disease severity is due to genes OTHER than CFTR",
    0.4, 4.73, 12.4, 0.42, size=11, bold=True, color=C_NAVY)
add_text(sl, "Further Examples of Modifier Genes", 0.3, 5.32, 12.7, 0.38, size=14, bold=True, color=C_NAVY)
for i, h in enumerate(["Primary Disease", "Modifier Gene", "Effect on Phenotype"]):
    cbox(sl, h, 0.3 + i*4.2, 5.75, 4.0, 0.38, C_NAVY, size=11, bold=True)
for i, (pd, mg, eff) in enumerate([
    ("Cystic fibrosis",                "MBL2 / TGFB1",                  "Pulmonary disease severity"),
    ("Sickle cell disease",            "BCL11A, HBG (fetal Hb regs)",   "Severity of vaso-occlusive crises"),
    ("Familial hypercholesterolaemia", "APOE genotype",                  "Cardiovascular disease severity"),
    ("Huntington disease",             "MSH3 (DNA mismatch repair)",     "Age of onset modulation"),
]):
    yp = 6.18 + i * 0.3
    for j, (val, bgc) in enumerate(zip([pd, mg, eff],
                                        [C_LIGHT, RGBColor(0xD6,0xEA,0xF8), RGBColor(0xD5,0xF5,0xE3)])):
        cbox(sl, val, 0.3 + j*4.2, yp, 4.0, 0.28, bgc, tc=C_DARK, size=10)
foot(sl, "Thompson & Thompson Genetics 9th ed., p.185 | Goldman-Cecil Medicine | Harrison's Principles 22E")

# ── SLIDE 10: DIGENIC INHERITANCE ────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "10. Digenic Inheritance",
    "Simplest multigenic inheritance -- disease requires mutations at TWO different loci", col=C_NAVY)
add_text(sl,
    "Definition: Disease manifests ONLY when pathogenic variants at TWO DIFFERENT GENE LOCI are combined. "
    "Heterozygous variants at either locus alone are insufficient -- only the co-occurrence of both causes the phenotype.",
    0.3, 1.35, 12.7, 0.65, size=13, color=C_DARK)
cbox(sl, "Gene A\n(Heterozygous)\nCarrier -- unaffected",
     0.5, 2.15, 2.8, 1.05, C_TEAL, size=12, bold=True)
add_text(sl, "+", 3.4, 2.45, 0.5, 0.55, size=24, bold=True, color=C_DARK, align=PP_ALIGN.CENTER)
cbox(sl, "Gene B\n(Heterozygous)\nCarrier -- unaffected",
     4.0, 2.15, 2.8, 1.05, C_ORANGE, size=12, bold=True)
add_text(sl, "=", 6.9, 2.45, 0.5, 0.55, size=24, bold=True, color=C_DARK, align=PP_ALIGN.CENTER)
cbox(sl, "DISEASE\n(Both mutations present together)",
     7.5, 2.15, 2.8, 1.05, C_RED, size=12, bold=True)
cbox(sl, "Gene A alone -> NORMAL",   0.5, 3.35, 2.8, 0.38, C_LIGHT, tc=C_TEAL, size=11, bold=True)
cbox(sl, "Gene B alone -> NORMAL",   4.0, 3.35, 2.8, 0.38, C_LIGHT, tc=C_ORANGE, size=11, bold=True)
cbox(sl, "Both together -> DISEASE", 7.5, 3.35, 2.8, 0.38, C_RED, size=11, bold=True)
add_text(sl, "Key Characteristics", 0.3, 3.95, 5.5, 0.38, size=14, bold=True, color=C_NAVY)
for i, c in enumerate([
    "Neither mutation alone causes disease",
    "Parents carrying one mutation each are UNAFFECTED",
    "Child inheriting BOTH mutations has 25% risk (if parents carry at different loci)",
    "Appears sporadic/recessive-like in pedigrees",
    "AR = 2 mutations SAME locus; Digenic = 1 mutation at EACH of 2 DIFFERENT loci",
]):
    cbox(sl, str(i+1), 0.3, 4.38 + i*0.5, 0.42, 0.42, C_TEAL, size=13, bold=True)
    add_text(sl, c, 0.82, 4.4 + i*0.5, 5.0, 0.44, size=11, color=C_DARK)
add_text(sl, "Clinical Examples", 6.4, 3.95, 6.6, 0.38, size=14, bold=True, color=C_NAVY)
for i, (name, col, desc) in enumerate([
    ("Digenic Retinitis Pigmentosa", C_RED,
     "ROM1 + PRPH2 (peripherin)\nEither alone = normal; both together = RP"),
    ("Waardenburg Syndrome Type III", C_PURPLE,
     "PAX3 + MITF heterozygosity"),
    ("Bardet-Biedl Syndrome", C_ORANGE,
     "Mutations at 2+ BBS loci (oligogenic/triallelic)"),
    ("Hereditary Deafness (GJB2/GJB6)", C_TEAL,
     "Connexin 26 + Connexin 30 -- combined deletion/mutation -> deafness"),
]):
    yp = 4.42 + i * 0.65
    cbox(sl, name, 6.4, yp, 6.4, 0.42, col, size=11, bold=True)
    add_text(sl, desc, 6.5, yp + 0.45, 6.2, 0.4, size=10, color=C_DARK)
cs = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(6.82), Inches(12.7), Inches(0.42))
cs.fill.solid(); cs.fill.fore_color.rgb = C_NAVY
cs.line.fill.background(); cs.shadow.inherit = False
add_text(sl,
    "Clinical Significance: Explains sporadic cases in single-carrier families | "
    "Critical for genomic sequencing interpretation -- VUS at two loci may act diigenically",
    0.4, 6.87, 12.4, 0.35, size=11, color=C_WHITE)
foot(sl, "Emery's Elements of Medical Genetics (citing Schaffer, J Med Genet 2013) | Thompson & Thompson Genetics 9th ed.")

# ── REFERENCES ───────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
hdr(sl, "References", "Multifactorial Congenital Malformations", col=C_TEAL)
for i, r in enumerate([
    "1. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
    "2. Turnpenny P, Ellard S. Emery's Elements of Medical Genetics and Genomics. 16th ed. Elsevier; 2022.",
    "3. Goldman L, Schafer AI. Goldman-Cecil Medicine. 27th ed. International ed. Elsevier; 2024.",
    "4. Loscalzo J et al. Harrison's Principles of Internal Medicine. 22nd ed. McGraw-Hill; 2025.",
    "5. Robbins R, Kumar V. Robbins & Kumar Basic Pathology. 11th ed. Elsevier; 2023.",
    "6. Schaffer AA. Digenic inheritance in medical genetics. J Med Genet. 2013;50:641-652.",
    "7. Marchenko ME. Genetic susceptibility to death from coronary heart disease. NEJM. 1994;330:1041.",
]):
    add_text(sl, r, 0.5, 1.4 + i*0.72, 12.3, 0.65, size=12, color=C_WHITE)

buf = BytesIO(); prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT2_Multifactorial_Malformations.pptx", "wb") as f:
    f.write(buf.getvalue())
print("PPT2 saved OK")
Writing File

~/genetics-cbd/make_ppt3.py

"""PPT 3: Autosomal Recessive Inheritance"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)
C_GREEN  = RGBColor(0x1A,0x7A,0x4A)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide, color=C_LIGHT):
    s = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height)
    s.fill.solid(); s.fill.fore_color.rgb = color
    s.line.fill.background(); s.shadow.inherit = False

def hdr(slide, title, subtitle="", col=C_NAVY):
    b = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(1.25))
    b.fill.solid(); b.fill.fore_color.rgb = col
    b.line.fill.background(); b.shadow.inherit = False
    t = slide.shapes.add_textbox(Inches(0.3), Inches(0.05), Inches(12), Inches(0.7))
    p = t.text_frame.paragraphs[0]; p.text = title
    r = p.runs[0]; r.font.size = Pt(28); r.font.bold = True
    r.font.color.rgb = C_WHITE; r.font.name = "Calibri"
    if subtitle:
        t2 = slide.shapes.add_textbox(Inches(0.35), Inches(0.78), Inches(12), Inches(0.45))
        p2 = t2.text_frame.paragraphs[0]; p2.text = subtitle
        r2 = p2.runs[0]; r2.font.size = Pt(15); r2.font.color.rgb = C_GOLD; r2.font.name = "Calibri"

def add_text(slide, text, x, y, w, h, size=13, bold=False, color=C_DARK,
             align=PP_ALIGN.LEFT, italic=False, wrap=True):
    box = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = box.text_frame; tf.word_wrap = wrap
    p = tf.paragraphs[0]; p.text = text; p.alignment = align
    r = p.runs[0]; r.font.size = Pt(size); r.font.bold = bold
    r.font.color.rgb = color; r.font.name = "Calibri"; r.font.italic = italic

def cbox(slide, text, x, y, w, h, bg_c, tc=C_WHITE, size=12, bold=False):
    s = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                               Inches(x), Inches(y), Inches(w), Inches(h))
    s.fill.solid(); s.fill.fore_color.rgb = bg_c
    s.line.fill.background(); s.shadow.inherit = False
    tf = s.text_frame; tf.word_wrap = True; tf.vertical_anchor = MSO_ANCHOR.MIDDLE
    p = tf.paragraphs[0]; p.text = text; p.alignment = PP_ALIGN.CENTER
    r = p.runs[0]; r.font.size = Pt(size); r.font.color.rgb = tc
    r.font.bold = bold; r.font.name = "Calibri"

def foot(slide, ref):
    ln = slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                                    Inches(0.3), Inches(7.15), Inches(13), Inches(7.15))
    ln.line.color.rgb = C_TEAL; ln.line.width = Pt(1)
    add_text(slide, ref, 0.3, 7.18, 12.7, 0.3, size=9, italic=True,
             color=RGBColor(0x55, 0x55, 0x55))

# ── TITLE ─────────────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
dec = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.8), prs.slide_width, Inches(0.1))
dec.fill.solid(); dec.fill.fore_color.rgb = C_TEAL
dec.line.fill.background(); dec.shadow.inherit = False
dec2 = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.9), prs.slide_width, Inches(0.04))
dec2.fill.solid(); dec2.fill.fore_color.rgb = C_GOLD
dec2.line.fill.background(); dec2.shadow.inherit = False
add_text(sl, "GENETICS CBD", 1, 1.2, 11, 0.6, size=22, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "AUTOSOMAL RECESSIVE\nINHERITANCE",
         0.5, 1.9, 12.3, 1.5, size=44, bold=True, color=C_WHITE, align=PP_ALIGN.CENTER)
add_text(sl, "Definition  |  Cystic Fibrosis  |  Marfan Syndrome  |  Phenylketonuria  |  CF Phenotypic Features",
         1, 3.65, 11.3, 0.6, size=15, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "Sources: Goldman-Cecil Medicine | Harrison's 22E | Thompson & Thompson Genetics 9th ed.",
         1, 6.8, 11.3, 0.5, size=10, italic=True,
         color=RGBColor(0xAA, 0xBB, 0xCC), align=PP_ALIGN.CENTER)

# ── SLIDE 11: AR DEFINITION ───────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "11. Autosomal Recessive Inheritance",
    "Two pathogenic alleles required; heterozygotes (carriers) are unaffected", col=C_NAVY)

# Pedigree cross diagram
add_text(sl, "Carrier x Carrier Cross  (Aa x Aa)", 0.3, 1.38, 5.5, 0.38, size=14, bold=True, color=C_NAVY)
cbox(sl, "Father\n(Carrier Aa)", 0.4, 1.85, 1.8, 0.8, C_TEAL, size=12, bold=True)
add_text(sl, "x", 2.25, 2.1, 0.4, 0.4, size=20, bold=True, color=C_DARK, align=PP_ALIGN.CENTER)
cbox(sl, "Mother\n(Carrier Aa)", 2.65, 1.85, 1.8, 0.8, C_TEAL, size=12, bold=True)
ln2 = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                               Inches(2.55), Inches(2.65), Inches(2.55), Inches(3.1))
ln2.line.color.rgb = C_DARK; ln2.line.width = Pt(2)
offspring = [("AA 25%\nNormal", C_LIME, C_DARK), ("Aa 50%\nCarrier", C_TEAL, C_WHITE),
             ("Aa 50%\nCarrier", C_TEAL, C_WHITE), ("aa 25%\nAFFECTED", C_RED, C_WHITE)]
for i, (lbl, col, tc) in enumerate(offspring):
    cbox(sl, lbl, 0.3 + i*1.28, 3.15, 1.18, 0.85, col, tc=tc, size=10, bold=True)

add_text(sl, "Rules of AR Inheritance", 0.3, 4.18, 5.5, 0.38, size=14, bold=True, color=C_TEAL)
for i, r in enumerate([
    "1. Both sexes equally affected (autosomal gene)",
    "2. Parents are typically unaffected carriers (Aa x Aa)",
    "3. Horizontal pattern: affected siblings in one generation",
    "4. Consanguinity increases risk (alleles identical by descent)",
    "5. No male-to-male (or male-to-female) vertical pattern",
    "6. Compound heterozygosity: two different pathogenic alleles at same locus",
]):
    add_text(sl, r, 0.3, 4.6 + i*0.38, 5.3, 0.36, size=11, color=C_DARK)
hw = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(6.9), Inches(5.5), Inches(0.45))
hw.fill.solid(); hw.fill.fore_color.rgb = RGBColor(0xD5,0xF5,0xE3)
hw.line.color.rgb = C_GREEN; hw.line.width = Pt(1.5); hw.shadow.inherit = False
add_text(sl, "Hardy-Weinberg: If disease freq = q^2 (CF: 1/2500), q = 1/50, carrier freq 2pq ~= 1/25 (4%)",
         0.4, 6.95, 5.3, 0.37, size=11, color=C_DARK)

# Right panel: comparison table
add_text(sl, "Comparison: AR vs AD vs X-linked Recessive", 5.9, 1.38, 7.1, 0.38, size=14, bold=True, color=C_NAVY)
hcols = ["Feature", "AR", "AD", "XLR"]
col_widths = [2.8, 1.4, 1.4, 1.4]
x_starts = [5.9, 8.75, 10.2, 11.65]
for i, (h, xp, cw) in enumerate(zip(hcols, x_starts, col_widths)):
    cbox(sl, h, xp, 1.82, cw, 0.42, C_NAVY, size=11, bold=True)
for i, (feat, ar, ad, xlr) in enumerate([
    ("Both sexes",      "Equal",           "Equal",       "Males mainly"),
    ("Carrier parents", "Unaffected",      "--",          "Unaffected females"),
    ("Skip generations","Yes",             "No",          "Yes"),
    ("Consanguinity",   "Increases risk",  "No effect",   "No effect"),
    ("M->son transmit.","Possible",        "Possible",    "NEVER"),
]):
    yp = 2.3 + i * 0.58
    for j, (val, xp, cw) in enumerate(zip([feat, ar, ad, xlr], x_starts, col_widths)):
        bgc = [C_LIGHT, RGBColor(0xD6,0xEA,0xF8), RGBColor(0xFD,0xED,0xEC), RGBColor(0xD5,0xF5,0xE3)][j]
        cbox(sl, val, xp, yp, cw, 0.5, bgc, tc=C_DARK, size=11)

add_text(sl, "Common AR Diseases", 5.9, 5.35, 7.1, 0.38, size=13, bold=True, color=C_TEAL)
for i, d in enumerate(["Cystic Fibrosis (CFTR, chr 7q31)", "Phenylketonuria (PAH, chr 12q23)",
                        "Sickle Cell Disease (HBB, chr 11p15)", "Thalassaemia (HBA/HBB)",
                        "Wilson's Disease (ATP7B)", "Haemochromatosis (HFE, C282Y)",
                        "Spinal Muscular Atrophy (SMN1)"]):
    add_text(sl, "* " + d, 5.9, 5.75 + i*0.32, 7.1, 0.3, size=11, color=C_DARK)

foot(sl, "Goldman-Cecil Medicine | Basic Medical Biochemistry 6th ed. | Dermatology 2-Volume Set 5th ed.")

# ── SLIDE 12: CYSTIC FIBROSIS ─────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "12. Cystic Fibrosis",
    "AR | CFTR gene, Chr 7q31.2 | Most common life-shortening AR disease in White populations", col=C_TEAL)

add_text(sl, "CFTR Mutation Classes", 0.3, 1.35, 5.0, 0.4, size=14, bold=True, color=C_NAVY)
for i, (cls, defect, muts, col) in enumerate([
    ("I",  "No synthesis (stop codon)",       "W1282X, G542X",        C_RED),
    ("II", "Protein misfolding/degradation",  "F508del (70%!), N1303K", C_ORANGE),
    ("III","Defective channel gating",        "G551D, G551S",          C_PURPLE),
    ("IV", "Reduced Cl- conductance",         "R117H, R334W",          C_TEAL),
    ("V",  "Reduced transcription/splicing",  "3849+10kbC->T",         C_GREEN),
    ("VI", "Unstable protein",                "4326delTC",             RGBColor(0x2E,0x86,0xAB)),
]):
    cbox(sl, "Class " + cls, 0.3, 1.82 + i*0.62, 1.0, 0.52, col, size=12, bold=True)
    add_text(sl, defect, 1.4, 1.86 + i*0.62, 1.9, 0.5, size=11, color=C_DARK)
    add_text(sl, muts, 3.35, 1.86 + i*0.62, 1.9, 0.5, size=10, color=col, bold=True)

ep = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(5.72), Inches(4.85), Inches(0.7))
ep.fill.solid(); ep.fill.fore_color.rgb = RGBColor(0xE8,0xF4,0xF8)
ep.line.color.rgb = C_TEAL; ep.line.width = Pt(1); ep.shadow.inherit = False
add_text(sl, "Epidemiology: Northern Europe/Americas 1:2500-3000 | USA 1:10,000 | Hispanic 1:7,000 | African American 1:12,000",
         0.4, 5.78, 4.65, 0.58, size=10, color=C_DARK)

add_text(sl, "Pathophysiology by Organ System", 5.4, 1.35, 7.6, 0.4, size=14, bold=True, color=C_NAVY)
for i, (organ, desc, col) in enumerate([
    ("LUNGS (~90% mortality)",
     "Reduced Cl-/HCO3- secretion -> airway dehydration -> mucus plugging -> chronic Pseudomonas -> bronchiectasis", C_RED),
    ("SWEAT GLANDS",
     "Sweat Cl- >=60 mEq/L (DIAGNOSTIC) | Salt wasting | Hyponatremic alkalosis | 'Salty tasting skin'", C_TEAL),
    ("PANCREAS",
     "Exocrine insufficiency -> steatorrhea, fat-soluble vitamin deficiency | CF-related diabetes (CFRD)", C_ORANGE),
    ("LIVER & BILIARY",
     "Biliary canalicular obstruction -> cirrhosis (5%) | Portal hypertension | Gallstones (30%)", RGBColor(0x5D,0x6D,0x7E)),
    ("GI TRACT",
     "Meconium ileus (15-20% neonates) | DIOS in older patients | Rectal prolapse | GERD", C_PURPLE),
    ("REPRODUCTIVE",
     "Males: CBAVD -> obstructive azoospermia -> infertility >95% | Females: thick cervical mucus -> reduced fertility", C_GREEN),
]):
    yp = 1.82 + i*0.82
    cbox(sl, organ, 5.4, yp, 2.0, 0.65, col, size=10, bold=True)
    add_text(sl, desc, 7.5, yp + 0.06, 5.5, 0.62, size=10, color=C_DARK)

foot(sl, "Goldman-Cecil Medicine p.3231-3290 | Harrison's Principles of Internal Medicine 22E | Medical Physiology")

# ── SLIDE 13: MARFAN SYNDROME ─────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "13. Marfan Syndrome",
    "Autosomal DOMINANT | FBN1 gene, Chr 15q21.1 | Connective tissue disorder (included for comparison)",
    col=C_ORANGE)

note = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(0.3), Inches(1.35), Inches(12.7), Inches(0.45))
note.fill.solid(); note.fill.fore_color.rgb = RGBColor(0xFE,0xF9,0xE7)
note.line.color.rgb = C_ORANGE; note.line.width = Pt(2); note.shadow.inherit = False
add_text(sl, "NOTE: Marfan syndrome is AUTOSOMAL DOMINANT -- included here for differential comparison with AR connective tissue disorders",
         0.4, 1.4, 12.4, 0.37, size=11, bold=True, color=RGBColor(0x78,0x3F,0x04))

cbox(sl, "Gene: FBN1 (Fibrillin-1)  |  Chromosome 15q21.1\nAutosomal Dominant  |  ~75% inherited, ~25% de novo",
     0.3, 1.88, 4.5, 0.85, C_NAVY, size=12, bold=True)

add_text(sl, "Pathophysiology", 0.3, 2.88, 4.5, 0.38, size=14, bold=True, color=C_TEAL)
for i, p in enumerate([
    "Fibrillin-1: major structural component of extracellular microfibrils",
    "Microfibrils provide integrity to: aortic wall, lens zonules, ligaments, lung airways, spinal dura",
    "Mutant FBN1 -> weakened microfibrils + excess TGF-b signaling",
    "Excess TGF-b -> progressive aortic wall degradation and dilatation",
]):
    add_text(sl, "* " + p, 0.3, 3.3 + i*0.45, 4.5, 0.43, size=11, color=C_DARK)

dbox = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(0.3), Inches(5.28), Inches(4.5), Inches(1.38))
dbox.fill.solid(); dbox.fill.fore_color.rgb = RGBColor(0xD5,0xF5,0xE3)
dbox.line.color.rgb = C_GREEN; dbox.line.width = Pt(1.5); dbox.shadow.inherit = False
add_text(sl, "Ghent Criteria 2010 (any one):", 0.4, 5.33, 4.3, 0.35, size=12, bold=True, color=C_GREEN)
for i, cr in enumerate([
    "Aortic root dilatation (Z>=2.0) + ectopia lentis",
    "Aortic root dilatation + FBN1 pathogenic variant",
    "Ectopia lentis + FBN1 variant + aortic disease",
    "Systemic score >=7 + aortic disease",
]):
    add_text(sl, "* " + cr, 0.4, 5.72 + i*0.23, 4.3, 0.22, size=10, color=C_DARK)

add_text(sl, "Cardinal Clinical Features", 5.0, 1.38, 8.0, 0.38, size=14, bold=True, color=C_NAVY)
for i, (sys_name, col, items) in enumerate([
    ("CARDIOVASCULAR (Most Dangerous)", C_RED,
     ["Aortic root dilatation/aneurysm (Z>=2.0)",
      "Aortic dissection (Type A -- emergency)",
      "Mitral valve prolapse +/- regurgitation",
      "Pulmonary artery dilatation"]),
    ("OCULAR", C_TEAL,
     ["Ectopia lentis (upward subluxation -- 50-80%)",
      "High myopia",
      "Retinal detachment risk",
      "Glaucoma, cataracts"]),
    ("SKELETAL", C_ORANGE,
     ["Tall stature; dolichostenomelia (long limbs)",
      "Arachnodactyly (wrist & thumb signs +ve)",
      "Pectus excavatum/carinatum",
      "Scoliosis | Dural ectasia | Flat feet"]),
]):
    xp = 5.0 + i * 2.75
    cbox(sl, sys_name, xp, 1.85, 2.5, 0.62, col, size=10, bold=True)
    for j, item in enumerate(items):
        add_text(sl, "* " + item, xp, 2.52 + j*0.46, 2.5, 0.42, size=10, color=C_DARK)

mbox = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(5.0), Inches(5.55), Inches(8.0), Inches(1.1))
mbox.fill.solid(); mbox.fill.fore_color.rgb = C_NAVY
mbox.line.fill.background(); mbox.shadow.inherit = False
add_text(sl, "Management", 5.1, 5.6, 2.0, 0.35, size=12, bold=True, color=C_GOLD)
add_text(sl, "* Beta-blockers (atenolol) or losartan (anti-TGF-b) to slow aortic dilatation\n"
             "* Elective aortic root repair when diameter reaches 4.5-5.0 cm\n"
             "* Annual echocardiography  |  Restrict contact sports & high-intensity exercise",
         5.1, 5.95, 7.8, 0.65, size=11, color=C_WHITE)

foot(sl, "GeneReviews NBK1335 | Medscape | Emery's Elements of Medical Genetics | Thompson & Thompson Genetics 9th ed.")

# ── SLIDE 14: PHENYLKETONURIA ─────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "14. Phenylketonuria (PKU)",
    "AR | PAH gene, Chr 12q23.2 | Inborn error of phenylalanine metabolism", col=C_PURPLE)

cbox(sl, "Gene: PAH (Phenylalanine Hydroxylase)\nChr 12q23.2  |  90 kb  |  13 exons\nAR -- homozygous or compound heterozygous",
     0.3, 1.38, 4.5, 0.95, C_PURPLE, size=12, bold=True)

add_text(sl, "Biochemical Pathway", 0.3, 2.45, 4.5, 0.38, size=13, bold=True, color=C_NAVY)
cbox(sl, "Phenylalanine\n(dietary)", 0.3, 2.9, 2.0, 0.65, C_TEAL, size=12, bold=True)
ln3 = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                               Inches(2.3), Inches(3.22), Inches(2.7), Inches(3.22))
ln3.line.color.rgb = C_GREEN; ln3.line.width = Pt(3)
cbox(sl, "PAH + BH4\n(cofactor)", 2.7, 2.9, 1.6, 0.65, C_GREEN, size=11, bold=True)
ln4 = sl.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                               Inches(4.3), Inches(3.22), Inches(4.65), Inches(3.22))
ln4.line.color.rgb = C_GREEN; ln4.line.width = Pt(3)
cbox(sl, "Tyrosine", 4.65, 2.9, 1.4, 0.65, C_LIME, size=12, bold=True, tc=C_DARK)
x2 = sl.shapes.add_shape(MSO_SHAPE.OVAL, Inches(2.72), Inches(2.62), Inches(0.38), Inches(0.38))
x2.fill.solid(); x2.fill.fore_color.rgb = C_RED; x2.line.fill.background(); x2.shadow.inherit = False
tf2 = x2.text_frame; tf2.vertical_anchor = MSO_ANCHOR.MIDDLE
p2 = tf2.paragraphs[0]; p2.text = "X"; p2.alignment = PP_ALIGN.CENTER
r2 = p2.runs[0]; r2.font.size = Pt(12); r2.font.color.rgb = C_WHITE; r2.font.bold = True
cbox(sl, "PAH absent/deficient -> Phe accumulates -> toxic metabolites\n(phenylpyruvate, phenylacetate, phenyllactate)",
     0.3, 3.65, 4.5, 0.65, C_RED, size=11, bold=True)

add_text(sl, "Clinical Phenotypes (untreated)", 0.3, 4.42, 4.5, 0.38, size=13, bold=True, color=C_TEAL)
for i, (ptype, phe, iq, col) in enumerate([
    ("Classic PKU",  ">1200 umol/L",  "Severe ID (IQ<50)",    C_RED),
    ("Moderate PKU", "600-1200",       "Moderate ID",          C_ORANGE),
    ("Mild PKU",     "360-600",        "Mild cognitive effect", C_ORANGE),
    ("Benign hyperphe.", "<360",       "Minimal/none",         C_LIME),
]):
    cbox(sl, ptype, 0.3, 4.85 + i*0.44, 1.8, 0.38, col, size=10, bold=True)
    add_text(sl, "Phe: " + phe, 2.15, 4.87 + i*0.44, 1.4, 0.35, size=10, color=C_DARK)
    add_text(sl, iq, 3.6, 4.87 + i*0.44, 1.1, 0.35, size=10, color=col, bold=True)

ep2 = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                          Inches(0.3), Inches(6.72), Inches(4.5), Inches(0.5))
ep2.fill.solid(); ep2.fill.fore_color.rgb = RGBColor(0xE8,0xF4,0xF8)
ep2.line.color.rgb = C_TEAL; ep2.line.width = Pt(1); ep2.shadow.inherit = False
add_text(sl, "Prevalence: ~1:24,000 globally | Turkey highest (~38:100,000) | US ~1:10,000-15,000",
         0.4, 6.77, 4.3, 0.4, size=11, color=C_DARK)

add_text(sl, "Clinical Features (untreated)", 5.1, 1.38, 8.0, 0.38, size=14, bold=True, color=C_NAVY)
for i, f in enumerate([
    "Profound intellectual disability (IQ <50)",
    "Epilepsy / seizures",
    "Acquired microcephaly",
    "Behavioral disorders (hyperactivity, autism-like)",
    "Generalized hypopigmentation: blue eyes, fair hair, fair skin (reduced tyrosine -> reduced melanin)",
    "Eczema",
    "Mousy/musty odor (phenylacetate in urine and sweat)",
]):
    cbox(sl, str(i+1), 5.1, 1.82 + i*0.48, 0.4, 0.4, C_PURPLE, size=12, bold=True)
    add_text(sl, f, 5.6, 1.84 + i*0.48, 7.3, 0.42, size=11, color=C_DARK)

add_text(sl, "Treatment", 5.1, 5.42, 8.0, 0.38, size=14, bold=True, color=C_TEAL)
for i, (name, desc, col) in enumerate([
    ("Low-Phe diet (lifelong)", "Restrict proteins; phenylalanine-free amino acid formula", C_TEAL),
    ("Sapropterin (Kuvan)",     "BH4 analog -- effective in ~30-50% (BH4-responsive phenotypes)", C_ORANGE),
    ("Pegvaliase",              "PEGylated PAL enzyme -- for adults with classic PKU poorly controlled", C_PURPLE),
    ("Newborn screening",       "MS/MS on heel-prick blood spot day 2-5 | Early treatment = normal IQ", C_GREEN),
]):
    cbox(sl, name, 5.1, 5.85 + i*0.38, 2.4, 0.32, col, size=10, bold=True)
    add_text(sl, desc, 7.6, 5.87 + i*0.38, 5.4, 0.32, size=10, color=C_DARK)

foot(sl, "Goldman-Cecil Medicine | Basic Medical Biochemistry 6th ed. | PMC9295449 (PKU genetics review)")

# ── SLIDE 15: MAJOR PHENOTYPIC FEATURES OF CF ────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "15. Major Phenotypic Features: Cystic Fibrosis",
    "Multisystem disease -- CFTR dysfunction affects every exocrine gland", col=C_TEAL)

for i, (name, desc, col) in enumerate([
    ("PULMONARY\n~90% mortality",
     "Chronic cough | Bronchiectasis | Chronic Pseudomonas/Staph infection\nHemoptysis | Respiratory failure | Cor pulmonale | Pneumothorax",
     C_RED),
    ("SWEAT\nGLANDS",
     "Cl- >=60 mEq/L (DIAGNOSTIC) | Salt wasting\nHyponatremic alkalosis | 'Salty tasting skin'",
     C_TEAL),
    ("PANCREAS",
     "Exocrine insufficiency -> steatorrhea\nFat-soluble vitamin deficiency (A,D,E,K)\nCFRD (CF-related diabetes) in ~50% by age 50",
     C_ORANGE),
    ("LIVER &\nBILIARY",
     "Biliary obstruction -> focal cirrhosis (5-10%)\nPortal hypertension | Gallstones (30%)",
     RGBColor(0x5D,0x6D,0x7E)),
    ("GI TRACT",
     "Meconium ileus (15-20% neonates)\nDIOS in older patients\nRectal prolapse | GERD",
     C_PURPLE),
    ("REPRODUCTIVE",
     "Males: CBAVD -> obstructive azoospermia -> infertility >95%\nFemales: thick cervical mucus -> reduced fertility",
     C_GREEN),
    ("SINUSES",
     "Chronic sinusitis (virtually all patients)\nNasal polyps (10-40%)",
     C_NAVY),
    ("BONE",
     "Osteoporosis/osteopenia | Short stature\nDelayed puberty | CF arthropathy",
     RGBColor(0x2E,0x86,0xAB)),
    ("CLUBBING &\nSKIN",
     "Digit clubbing (chronic hypoxia/bronchiectasis)\nWrinkling of hands/feet\nHypochloremic alkalosis",
     RGBColor(0x7B,0x68,0xEE)),
]):
    ci = i % 3; ri = i // 3
    xp = 0.3 + ci * 4.3; yp = 1.35 + ri * 1.82
    cbox(sl, name, xp, yp, 1.9, 0.65, col, size=10, bold=True)
    add_text(sl, desc, xp + 1.98, yp + 0.05, 2.25, 0.62, size=9, color=C_DARK)

dcs = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                          Inches(0.3), Inches(6.82), Inches(12.7), Inches(0.52))
dcs.fill.solid(); dcs.fill.fore_color.rgb = C_NAVY
dcs.line.fill.background(); dcs.shadow.inherit = False
add_text(sl, "Diagnostic Criteria (any ONE): ", 0.4, 6.87, 2.8, 0.38, size=12, bold=True, color=C_GOLD)
add_text(sl, "Sweat Cl- >=60 mEq/L (x2)  OR  Two pathogenic CFTR mutations  OR  Abnormal nasal potential difference"
             "  PLUS >=1 clinical feature / family history / positive newborn screen",
         3.25, 6.87, 9.8, 0.42, size=11, color=C_WHITE)

foot(sl, "Goldman-Cecil Medicine p.3231-3290 | Harrison's Principles of Internal Medicine 22E")

# ── REFERENCES ────────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
hdr(sl, "References", "Autosomal Recessive Inheritance", col=C_TEAL)
for i, r in enumerate([
    "1. Goldman L, Schafer AI. Goldman-Cecil Medicine. 27th ed. (International). Elsevier; 2024.",
    "2. Loscalzo J et al. Harrison's Principles of Internal Medicine. 22nd ed. McGraw-Hill; 2025.",
    "3. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
    "4. Lieberman M, Peet A. Basic Medical Biochemistry: A Clinical Approach. 6th ed. Wolters Kluwer; 2024.",
    "5. GeneReviews: FBN1-Related Marfan Syndrome. NBK1335. NCBI Bookshelf.",
    "6. Stenson PD et al. The Human Gene Mutation Database (HGMD). Nucleic Acids Res. 2020;48(D1):D895-D900.",
    "7. Vockley J et al. Phenylalanine hydroxylase deficiency. Genet Med. 2014;16(2):188-200.",
]):
    add_text(sl, r, 0.5, 1.4 + i*0.72, 12.3, 0.65, size=12, color=C_WHITE)

buf = BytesIO(); prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT3_Autosomal_Recessive.pptx", "wb") as f:
    f.write(buf.getvalue())
print("PPT3 saved OK")
Writing File

~/genetics-cbd/make_ppt4.py

"""PPT 4: Chromosomal Anomalies"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from io import BytesIO

C_NAVY   = RGBColor(0x0D,0x2B,0x6E)
C_TEAL   = RGBColor(0x00,0x7B,0x8A)
C_LIME   = RGBColor(0x6A,0xB1,0x87)
C_ORANGE = RGBColor(0xE8,0x8B,0x2E)
C_WHITE  = RGBColor(0xFF,0xFF,0xFF)
C_LIGHT  = RGBColor(0xF0,0xF6,0xFB)
C_DARK   = RGBColor(0x1A,0x1A,0x2E)
C_RED    = RGBColor(0xC0,0x39,0x2B)
C_GOLD   = RGBColor(0xF5,0xCB,0x5C)
C_PURPLE = RGBColor(0x7B,0x35,0x7B)
C_GREEN  = RGBColor(0x1A,0x7A,0x4A)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
BLANK = prs.slide_layouts[6]

def bg(slide, color=C_LIGHT):
    s = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height)
    s.fill.solid(); s.fill.fore_color.rgb = color
    s.line.fill.background(); s.shadow.inherit = False

def hdr(slide, title, subtitle="", col=C_NAVY):
    b = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(1.25))
    b.fill.solid(); b.fill.fore_color.rgb = col
    b.line.fill.background(); b.shadow.inherit = False
    t = slide.shapes.add_textbox(Inches(0.3), Inches(0.05), Inches(12), Inches(0.7))
    p = t.text_frame.paragraphs[0]; p.text = title
    r = p.runs[0]; r.font.size = Pt(28); r.font.bold = True
    r.font.color.rgb = C_WHITE; r.font.name = "Calibri"
    if subtitle:
        t2 = slide.shapes.add_textbox(Inches(0.35), Inches(0.78), Inches(12), Inches(0.45))
        p2 = t2.text_frame.paragraphs[0]; p2.text = subtitle
        r2 = p2.runs[0]; r2.font.size = Pt(14); r2.font.color.rgb = C_GOLD; r2.font.name = "Calibri"

def add_text(slide, text, x, y, w, h, size=13, bold=False, color=C_DARK,
             align=PP_ALIGN.LEFT, italic=False, wrap=True):
    box = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = box.text_frame; tf.word_wrap = wrap
    p = tf.paragraphs[0]; p.text = text; p.alignment = align
    r = p.runs[0]; r.font.size = Pt(size); r.font.bold = bold
    r.font.color.rgb = color; r.font.name = "Calibri"; r.font.italic = italic

def cbox(slide, text, x, y, w, h, bg_c, tc=C_WHITE, size=12, bold=False):
    s = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                               Inches(x), Inches(y), Inches(w), Inches(h))
    s.fill.solid(); s.fill.fore_color.rgb = bg_c
    s.line.fill.background(); s.shadow.inherit = False
    tf = s.text_frame; tf.word_wrap = True; tf.vertical_anchor = MSO_ANCHOR.MIDDLE
    p = tf.paragraphs[0]; p.text = text; p.alignment = PP_ALIGN.CENTER
    r = p.runs[0]; r.font.size = Pt(size); r.font.color.rgb = tc
    r.font.bold = bold; r.font.name = "Calibri"

def foot(slide, ref):
    ln = slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT,
                                    Inches(0.3), Inches(7.15), Inches(13), Inches(7.15))
    ln.line.color.rgb = C_TEAL; ln.line.width = Pt(1)
    add_text(slide, ref, 0.3, 7.18, 12.7, 0.3, size=9, italic=True,
             color=RGBColor(0x55, 0x55, 0x55))

# ── TITLE ─────────────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
dec = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.8), prs.slide_width, Inches(0.1))
dec.fill.solid(); dec.fill.fore_color.rgb = C_TEAL
dec.line.fill.background(); dec.shadow.inherit = False
dec2 = sl.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(3.9), prs.slide_width, Inches(0.04))
dec2.fill.solid(); dec2.fill.fore_color.rgb = C_GOLD
dec2.line.fill.background(); dec2.shadow.inherit = False
add_text(sl, "GENETICS CBD", 1, 1.2, 11, 0.6, size=22, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "CHROMOSOMAL ANOMALIES", 0.5, 2.0, 12.3, 1.1, size=46, bold=True, color=C_WHITE, align=PP_ALIGN.CENTER)
add_text(sl, "Definition  |  Down Syndrome  |  Jacob's Syndrome  |  Y-Linked Diseases  |  X-Linked Diseases",
         1, 3.25, 11.3, 0.6, size=15, color=C_GOLD, align=PP_ALIGN.CENTER)
add_text(sl, "Sources: Robbins & Kumar Basic Pathology | Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics",
         1, 6.8, 11.3, 0.5, size=10, italic=True,
         color=RGBColor(0xAA, 0xBB, 0xCC), align=PP_ALIGN.CENTER)

# ── SLIDE 16: DEFINITION ──────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "16. Chromosomal Anomalies: Definition",
    "Abnormalities of chromosome number, structure, or both", col=C_NAVY)

add_text(sl, "A. Numerical Abnormalities (Aneuploidy)", 0.3, 1.35, 6.2, 0.38, size=14, bold=True, color=C_NAVY)
for i, (name, def_, ex, col) in enumerate([
    ("Monosomy (2n-1)", "Loss of 1 chromosome",           "45,X -- Turner syndrome",     C_RED),
    ("Trisomy (2n+1)",  "Extra chromosome",               "47,+21 -- Down syndrome",     C_ORANGE),
    ("Tetrasomy",       "Two extra of same type",         "48,XXXX",                     C_PURPLE),
    ("Polyploidy",      "Complete extra set (lethal)",    "Triploidy (69,XXX)",           RGBColor(0x5D,0x6D,0x7E)),
]):
    yp = 1.82 + i*0.68
    cbox(sl, name, 0.3, yp, 2.2, 0.55, col, size=11, bold=True)
    add_text(sl, def_, 2.6, yp + 0.06, 2.0, 0.45, size=11, color=C_DARK)
    add_text(sl, ex, 4.65, yp + 0.06, 1.65, 0.45, size=10, color=col, bold=True)

add_text(sl, "B. Structural Abnormalities", 0.3, 4.65, 6.2, 0.38, size=14, bold=True, color=C_TEAL)
for i, (name, def_, ex, col) in enumerate([
    ("Deletion",              "Loss of chromosomal segment",      "5p- (Cri-du-chat)",          C_RED),
    ("Duplication",           "Extra copy of segment",            "Dup 17p11.2 (CMT1A)",        C_ORANGE),
    ("Robertsonian transl.",  "Fusion of 2 acrocentric chrs",     "rob(14;21) in Down syndrome", C_TEAL),
    ("Reciprocal transl.",    "Exchange between non-homologs",    "t(9;22) -- Philadelphia chr", C_NAVY),
    ("Inversion",             "Reversed chromosomal segment",     "inv(9)",                     C_PURPLE),
]):
    yp = 5.1 + i*0.38
    cbox(sl, name, 0.3, yp, 2.2, 0.32, col, size=10, bold=True)
    add_text(sl, def_, 2.6, yp + 0.02, 2.0, 0.32, size=10, color=C_DARK)
    add_text(sl, ex, 4.65, yp + 0.02, 1.65, 0.32, size=9, color=col)

# Right panel
add_text(sl, "C. Special Categories", 6.8, 1.35, 6.2, 0.38, size=14, bold=True, color=C_NAVY)
for i, (name, mech, ex, col) in enumerate([
    ("Uniparental Disomy", "Both homologs from same parent",      "PWS/Angelman",    C_ORANGE),
    ("Mosaicism",          "Two or more different cell lines",    "Mosaic Down syn.", C_TEAL),
    ("Imprinting disorder","Epigenetic regulation disrupted",     "PWS/AS",          C_PURPLE),
]):
    yp = 1.82 + i*0.78
    cbox(sl, name, 6.8, yp, 2.2, 0.62, col, size=11, bold=True)
    add_text(sl, mech, 9.1, yp + 0.06, 2.5, 0.52, size=11, color=C_DARK)
    add_text(sl, ex, 11.65, yp + 0.06, 1.5, 0.52, size=10, color=col, bold=True)

add_text(sl, "Causes of Chromosomal Anomalies", 6.8, 4.22, 6.2, 0.38, size=14, bold=True, color=C_TEAL)
for i, c in enumerate([
    "Nondisjunction (most common): failure of chromosome separation in meiosis I or II",
    "Advanced maternal age: strongly associated with nondisjunction for most trisomies",
    "Chromosome breakage: radiation, chemical mutagens, repair errors",
    "Unequal recombination at segmental duplications (e.g., 15q11-q13)",
]):
    add_text(sl, "* " + c, 6.8, 4.65 + i*0.45, 6.2, 0.42, size=11, color=C_DARK)

freq = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(6.8), Inches(6.55), Inches(6.2), Inches(0.62))
freq.fill.solid(); freq.fill.fore_color.rgb = C_NAVY
freq.line.fill.background(); freq.shadow.inherit = False
add_text(sl, "Frequency: ~1 in 160 live births | ~50% of spontaneous abortions are chromosomally abnormal",
         6.9, 6.6, 6.0, 0.52, size=11, color=C_WHITE)

foot(sl, "Thompson & Thompson Genetics 9th ed. | Emery's Elements of Medical Genetics | Robbins & Kumar Pathologic Basis of Disease")

# ── SLIDE 17: DOWN SYNDROME ───────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "17. Down Syndrome (Trisomy 21 / Mongolism)",
    "Most common chromosomal disorder | 1 in 700 live births", col=C_TEAL)

add_text(sl, "Karyotype Types", 0.3, 1.35, 5.5, 0.38, size=14, bold=True, color=C_NAVY)
for i, (ktype, pct, mech, col) in enumerate([
    ("47,XX or XY,+21\n(Free Trisomy)", "~95%",
     "Meiotic nondisjunction\n95% extra chr 21 is maternal origin", C_RED),
    ("46 with Robertsonian\ntranslocation rob(14;21)", "~4%",
     "Familial in some cases\nMaternal carrier: 45,XX,rob(14;21)", C_ORANGE),
    ("Mosaic (46/47\nmixed cell lines)", "~1%",
     "Mitotic nondisjunction in early embryo\nMilder phenotype possible", C_TEAL),
]):
    yp = 1.82 + i*1.0
    cbox(sl, ktype, 0.3, yp, 2.5, 0.72, col, size=11, bold=True)
    cbox(sl, pct,   2.88, yp + 0.1, 0.7, 0.52, col, size=14, bold=True)
    add_text(sl, mech, 3.65, yp + 0.1, 2.0, 0.52, size=10, color=C_DARK)

add_text(sl, "Maternal Age Risk", 0.3, 4.95, 5.5, 0.38, size=13, bold=True, color=C_TEAL)
for i, (age, risk, col) in enumerate([
    ("<20 yrs", "1:1,550", C_GREEN),
    ("30 yrs",  "1:900",   C_ORANGE),
    ("35 yrs",  "1:385",   C_ORANGE),
    ("40 yrs",  "1:100",   C_RED),
    (">=45 yrs","1:25",    C_RED),
]):
    cbox(sl, age,  0.3 + i*1.08, 5.38, 0.9, 0.42, C_NAVY, size=10, bold=True)
    cbox(sl, risk, 0.3 + i*1.08, 5.85, 0.9, 0.42, col,    size=10, bold=True)

# Clinical features grid
add_text(sl, "Clinical Features", 5.9, 1.35, 7.1, 0.38, size=14, bold=True, color=C_NAVY)
for i, (sys_name, desc, col) in enumerate([
    ("FACIAL",           "Flat face, epicanthal folds, upslanting palpebral fissures\nBrushfield spots, macroglossia, small ears", C_TEAL),
    ("CNS",              "Moderate-mild intellectual disability (IQ 40-70)\nHypotonia (universal at birth)", C_NAVY),
    ("CARDIAC\n(40%)",   "AVSD 43% | VSD 32% | ASD 19% | ToF 6%\nLeading cause of death in infancy", C_RED),
    ("GI",               "Duodenal atresia ('double bubble')\nHirschsprung disease", C_ORANGE),
    ("HAEMATOLOGY",      "20x ALL risk | 500x AML risk\nTransient myeloproliferative disorder (GATA1)", C_PURPLE),
    ("NEURODEGENERATION","Alzheimer in virtually ALL >40 yrs\n(APP gene x 3 -> excess amyloid-beta)", RGBColor(0x5D,0x6D,0x7E)),
    ("IMMUNOLOGY",       "Defective T-cell function -> infections\nThyroid autoimmunity 15-20%", RGBColor(0x2E,0x86,0xAB)),
    ("LIFE EXPECTANCY",  "Median 47 years (was 25 yrs in 1983)\nImproved with cardiac surgery", C_GREEN),
]):
    ci = i % 2; ri = i // 2
    xp = 5.9 + ci*3.55; yp = 1.82 + ri*1.22
    cbox(sl, sys_name, xp, yp, 1.8, 0.58, col, size=10, bold=True)
    add_text(sl, desc, xp + 1.88, yp + 0.04, 1.58, 0.55, size=9, color=C_DARK)

ps = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(6.5), Inches(5.5), Inches(0.7))
ps.fill.solid(); ps.fill.fore_color.rgb = C_NAVY
ps.line.fill.background(); ps.shadow.inherit = False
add_text(sl, "Prenatal Screening:", 0.4, 6.55, 1.8, 0.3, size=12, bold=True, color=C_GOLD)
add_text(sl, "cfDNA/NIPT (>99% sensitivity) | 1st trim: NT + PAPP-A + b-hCG | 2nd trim: Quad screen | Confirm: amniocentesis/CVS + karyotype",
         0.4, 6.85, 5.3, 0.3, size=10, color=C_WHITE)

foot(sl, "Robbins & Kumar Pathologic Basis of Disease p.163-165 | Thompson & Thompson Genetics 9th ed. | Emery's Elements")

# ── SLIDE 18: JACOB'S SYNDROME ────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "18. Jacob's Syndrome (47,XYY)",
    "Sex chromosome aneuploidy | Extra Y chromosome | 1 in 1000 male births", col=C_ORANGE)

cbox(sl,
     "Karyotype: 47,XYY\nIncidence: 1 in 1,000 males\n"
     "Cause: Nondisjunction in PATERNAL meiosis II\n(Y chromatids fail to separate -- 100% paternal origin)",
     0.3, 1.35, 4.5, 1.35, C_NAVY, size=12, bold=True)

ms = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(2.78), Inches(4.5), Inches(0.5))
ms.fill.solid(); ms.fill.fore_color.rgb = RGBColor(0xFE,0xF9,0xE7)
ms.line.color.rgb = C_ORANGE; ms.line.width = Pt(1.5); ms.shadow.inherit = False
add_text(sl, "Mosaicism (46,XY/47,XYY): post-zygotic mitotic error -- milder phenotype; ~10% of cases",
         0.4, 2.83, 4.3, 0.4, size=11, color=C_DARK)

add_text(sl, "Clinical Features", 0.3, 3.38, 4.5, 0.38, size=14, bold=True, color=C_NAVY)
for i, (dom, col, items) in enumerate([
    ("Physical", C_TEAL, [
        "Tall stature (>1.88m at final height)",
        "Macrocephaly | Hypertelorism",
        "Clinodactyly (5th finger) | Macrodontia",
        "Macroorchidism | Flat feet | Scoliosis",
    ]),
    ("Neurodevelopmental", C_ORANGE, [
        "Normal IQ range (slightly lower vs siblings)",
        "Language/reading delays (dyslexia)",
        "ADHD | Anxiety | Depression",
        "Autism spectrum disorder -- increased risk",
    ]),
    ("Medical", C_RED, [
        "Asthma (increased incidence)",
        "Seizures / tremors",
        "Genitourinary anomalies (some cases)",
        "Infertility: oligospermia in some",
    ]),
    ("Behavioral", C_PURPLE, [
        "Impulse control difficulties",
        "Emotional dysregulation",
        "NOT necessarily criminal/violent",
        "Many individuals fully normal",
    ]),
]):
    ci = i % 2; ri = i // 2
    xp = 0.3 + ci*2.25; yp = 3.82 + ri*1.62
    cbox(sl, dom, xp, yp, 2.0, 0.42, col, size=11, bold=True)
    for j, item in enumerate(items):
        add_text(sl, "* " + item, xp, yp + 0.48 + j*0.28, 2.1, 0.26, size=9, color=C_DARK)

add_text(sl, "Diagnosis & Management", 5.0, 1.35, 8.0, 0.38, size=14, bold=True, color=C_NAVY)
for i, (cat, desc) in enumerate([
    ("Prenatal",         "NIPT, amniocentesis, CVS -- karyotype 47,XYY confirmed"),
    ("Postnatal",        "Karyotype from blood lymphocytes | Median Dx age: ~17 yrs"),
    ("Speech therapy",   "Early language/speech intervention for language delays"),
    ("Educational",      "Individualized educational support for learning difficulties"),
    ("Behavioral",       "CBT, behavioral therapy for impulse control difficulties"),
    ("Occupational",     "Therapy for motor development delays"),
    ("Monitoring",       "Annual check for scoliosis | Endocrine evaluation if needed"),
    ("Genetic counseling","Most offspring have normal karyotype; ART available if infertile"),
]):
    cbox(sl, cat, 5.0, 1.82 + i*0.62, 1.8, 0.48, C_TEAL, size=10, bold=True)
    add_text(sl, desc, 6.9, 1.86 + i*0.62, 6.2, 0.46, size=10, color=C_DARK)

foot(sl, "NCBI Bookshelf NBK557699 | Cleveland Clinic | MedlinePlus Genetics | Emery's Elements of Medical Genetics")

# ── SLIDE 19: Y-LINKED DISEASES ───────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "19. Y-Linked (Holandric) Diseases",
    "Genes on Y chromosome -- father to ALL sons | NO daughters ever affected", col=C_GREEN)

cbox(sl,
     "Y-Linked Inheritance Rules:\n"
     "* Transmitted exclusively father to son (holandric)\n"
     "* ALL sons of affected father are affected\n"
     "* NO daughters affected -- ever\n"
     "* No female carriers possible",
     0.3, 1.35, 5.5, 1.22, C_NAVY, size=12, bold=True)

add_text(sl, "Y Chromosome Structure", 0.3, 2.68, 5.5, 0.38, size=13, bold=True, color=C_TEAL)
for x, lbl, col in [(0.3, "PAR1\n(Pseudoauto-\nsomal Region 1)\nPairs with X", C_TEAL),
                    (2.2, "MSY\nMale-Specific Y\n(Non-recombining)\nTruly Y-specific genes", C_NAVY),
                    (4.1, "PAR2\n(Pseudoauto-\nsomal Region 2)", C_TEAL)]:
    cbox(sl, lbl, x, 3.12, 1.8, 0.95, col, size=10, bold=True)
add_text(sl, "PAR1/2 pair with X during meiosis -- genes here are NOT exclusively Y-linked",
         0.3, 4.15, 5.5, 0.35, size=10, italic=True, color=C_DARK)

add_text(sl, "Key Y-Linked Genes & Diseases", 0.3, 4.62, 5.5, 0.38, size=13, bold=True, color=C_NAVY)
for i, (gene, loc, func, dis, col) in enumerate([
    ("SRY", "Yp11.3",
     "Sex determination -- initiates male sex development",
     "Mutations -> 46,XY sex reversal (female phenotype)", C_RED),
    ("AZFa/b/c loci\n(Azoospermia Factor)", "Yq11.2",
     "Spermatogenesis -- DAZ, RBMY, USP9Y",
     "Microdeletions -> azoospermia/oligospermia -> male infertility", C_ORANGE),
    ("Hypertrichosis\npinnae", "Y (debated)",
     "Hairy ear pinna -- classical holandric teaching example",
     "Father-to-all-sons transmission (now debated vs autosomal)", C_TEAL),
]):
    cbox(sl, gene, 0.3, 5.08 + i*0.58, 1.1, 0.48, col, size=10, bold=True)
    add_text(sl, "Loc: " + loc, 1.48, 5.1 + i*0.58, 0.9, 0.22, size=9, color=C_DARK)
    add_text(sl, func, 1.48, 5.3 + i*0.58, 2.2, 0.28, size=9, color=C_DARK)
    add_text(sl, dis, 3.75, 5.12 + i*0.58, 2.0, 0.42, size=9, color=col, bold=True)

# AZF deletions
add_text(sl, "Y Chromosome Microdeletions & Male Infertility", 6.0, 1.35, 7.0, 0.38, size=14, bold=True, color=C_NAVY)
for i, (del_name, desc, col) in enumerate([
    ("AZFa deletion",
     "Sertoli-cell-only syndrome -- NO germ cells present\nTESE: sperm retrieval UNLIKELY", C_RED),
    ("AZFb deletion",
     "Spermatogenic arrest -- sperm production halted\nTESE: sperm retrieval UNLIKELY", C_ORANGE),
    ("AZFc deletion",
     "Most common (50-60% of AZF deletions)\nVariable severity -- TESE often SUCCESSFUL", C_TEAL),
]):
    yp = 1.82 + i*1.0
    cbox(sl, del_name, 6.0, yp, 2.3, 0.55, col, size=11, bold=True)
    add_text(sl, desc, 8.4, yp + 0.05, 4.7, 0.5, size=11, color=C_DARK)

prev = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                           Inches(6.0), Inches(5.05), Inches(7.0), Inches(0.5))
prev.fill.solid(); prev.fill.fore_color.rgb = RGBColor(0xD5,0xF5,0xE3)
prev.line.color.rgb = C_GREEN; prev.line.width = Pt(1.5); prev.shadow.inherit = False
add_text(sl, "AZF deletion prevalence: ~7-10% of azoospermic men | ~5% of severely oligospermic men",
         6.1, 5.1, 6.8, 0.38, size=11, bold=True, color=C_DARK)

add_text(sl, "Klinefelter Syndrome (47,XXY) -- for comparison", 6.0, 5.65, 7.0, 0.38, size=13, bold=True, color=C_NAVY)
for i, k in enumerate([
    "Karyotype: 47,XXY (most common); XXYY, XXXY (increasingly severe)",
    "Incidence: 1 in 500-1,000 male births",
    "Features: tall | small testes | azoospermia | gynaecomastia | reduced testosterone | learning difficulties",
    "NOT holandric -- involves extra sex chromosome; often de novo nondisjunction",
]):
    add_text(sl, "* " + k, 6.0, 6.08 + i*0.29, 7.0, 0.27, size=10, color=C_DARK)

foot(sl, "Emery's Elements of Medical Genetics | Thompson & Thompson Genetics 9th ed. | NCBI/GeneReviews")

# ── SLIDE 20: X-LINKED DISEASES ───────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl)
hdr(sl, "20. X-Linked Diseases",
    "Hemizygous expression in males -- X-linked recessive and dominant patterns", col=C_RED)

lh = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                         Inches(0.3), Inches(1.35), Inches(12.7), Inches(0.52))
lh.fill.solid(); lh.fill.fore_color.rgb = RGBColor(0xFD,0xED,0xEC)
lh.line.color.rgb = C_RED; lh.line.width = Pt(2); lh.shadow.inherit = False
add_text(sl,
    "Lyon Hypothesis (X-Inactivation): One X chromosome randomly inactivated per somatic cell at ~16 days post-fertilization"
    " -- Barr body. Skewed X-inactivation (>90:10) can cause MANIFESTING CARRIERS of XLR diseases.",
    0.4, 1.4, 12.4, 0.42, size=11, color=C_DARK)

add_text(sl, "X-Linked RECESSIVE (XLR) Rules", 0.3, 1.97, 5.5, 0.38, size=13, bold=True, color=C_NAVY)
for i, r in enumerate([
    "Predominantly affects MALES (hemizygous -- only one allele)",
    "Females usually asymptomatic CARRIERS (heterozygous)",
    "Carrier mother: 50% sons affected | 50% daughters carriers",
    "Affected father: ALL daughters carriers | NO sons affected",
    "NO male-to-male transmission (KEY distinguishing feature from AD)",
    "Rare affected females: Turner syndrome / homozygous XLR / skewed X-inactivation",
]):
    cbox(sl, str(i+1), 0.3, 2.42 + i*0.44, 0.4, 0.37, C_RED, size=12, bold=True)
    add_text(sl, r, 0.82, 2.44 + i*0.44, 4.8, 0.36, size=10, color=C_DARK)

xld = sl.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
                          Inches(0.3), Inches(5.12), Inches(5.5), Inches(1.55))
xld.fill.solid(); xld.fill.fore_color.rgb = RGBColor(0xD5,0xF5,0xE3)
xld.line.color.rgb = C_GREEN; xld.line.width = Pt(1.5); xld.shadow.inherit = False
add_text(sl, "X-Linked DOMINANT (XLD):", 0.4, 5.17, 3.0, 0.35, size=12, bold=True, color=C_GREEN)
for i, (name, desc) in enumerate([
    ("Rett Syndrome (MECP2)",          "Progressive neurological disorder; almost exclusively females (males lethal)"),
    ("Incontinentia Pigmenti (IKBKG)", "Skin/dental/CNS/eye; males die in utero"),
    ("Hypophosphatemic Rickets (PHEX)","Phosphate-wasting; affects both sexes; females less severe"),
]):
    add_text(sl, "* " + name + ":", 0.4, 5.56 + i*0.36, 2.1, 0.33, size=10, bold=True, color=C_GREEN)
    add_text(sl, desc, 2.5, 5.56 + i*0.36, 3.2, 0.33, size=10, color=C_DARK)

# Major XLR diseases table
add_text(sl, "Major X-Linked Recessive Diseases", 5.9, 1.97, 7.1, 0.38, size=13, bold=True, color=C_NAVY)
for i, (disease, gene, features, col) in enumerate([
    ("Duchenne MD",            "DMD (dystrophin) Xp21.2",
     "Progressive muscle wasting; Gowers' sign; wheelchair teens; dilated CM",      C_RED),
    ("Haemophilia A",          "F8 (Factor VIII) Xq28",
     "Severe bleeding; haemarthroses; absent/reduced FVIII",                         C_RED),
    ("Haemophilia B",          "F9 (Factor IX) Xq27.1",
     "Christmas disease; similar to Haemophilia A; reduced FIX",                     C_ORANGE),
    ("Fragile X Syndrome",     "FMR1 (CGG repeat) Xq27.3",
     "Most common inherited ID; macroorchidism; autism; large ears",                 C_PURPLE),
    ("Colour blindness",       "OPN1LW/MW Xq28",
     "Most common XL condition; ~8% males; red-green deficiency",                    C_TEAL),
    ("G6PD Deficiency",        "G6PD Xq28",
     "Haemolytic anaemia triggered by drugs/infections/fava beans",                  C_ORANGE),
    ("Fabry Disease",          "GLA (alpha-galactosidase A) Xq22",
     "Lysosomal storage; angiokeratomas; renal failure; cardiac disease",             C_NAVY),
    ("Lesch-Nyhan Syndrome",   "HPRT1 Xq26",
     "Gout + intellectual disability + self-mutilation; HGPRT deficiency",           C_RED),
    ("X-linked Agammaglob.",   "BTK (Bruton's TK) Xq21.33",
     "Absent B cells; recurrent bacterial infections (XLA)",                         C_GREEN),
    ("Wiskott-Aldrich",        "WAS Xp11.23",
     "Triad: eczema + thrombocytopenia + immunodeficiency",                          C_PURPLE),
]):
    ci = i % 2; ri = i // 2
    xp = 5.9 + ci*3.55; yp = 2.42 + ri*0.93
    cbox(sl, disease, xp, yp, 2.0, 0.5, col, size=10, bold=True)
    add_text(sl, gene, xp + 2.08, yp + 0.01, 1.35, 0.28, size=8, color=col, bold=True)
    add_text(sl, features, xp + 2.08, yp + 0.26, 1.38, 0.32, size=8, color=C_DARK)

foot(sl, "Emery's Elements of Medical Genetics | Thompson & Thompson Genetics 9th ed. | Robbins & Kumar Pathologic Basis of Disease")

# ── REFERENCES ────────────────────────────────────────────────────────────────
sl = prs.slides.add_slide(BLANK); bg(sl, C_NAVY)
hdr(sl, "References", "Chromosomal Anomalies", col=C_TEAL)
for i, r in enumerate([
    "1. Robbins R, Kumar V. Robbins & Kumar Basic Pathology. 11th ed. Elsevier; 2023. p.163-165.",
    "2. Thompson MW et al. Thompson & Thompson Genetics and Genomics in Medicine. 9th ed. Elsevier; 2023.",
    "3. Turnpenny P, Ellard S. Emery's Elements of Medical Genetics and Genomics. 16th ed. Elsevier; 2022.",
    "4. Bull MJ. Down syndrome. N Engl J Med. 2020;382:2344-2352.",
    "5. Tartaglia NR et al. 47,XYY syndrome. StatPearls/NCBI Bookshelf NBK557699. 2023.",
    "6. Cleveland Clinic. 47,XYY Syndrome (Jacobs Syndrome). my.clevelandclinic.org. 2024.",
    "7. Vogt PH et al. Human Y chromosome azoospermia factors (AZF). Hum Reprod. 1996;11:1459-1466.",
    "8. Goldman L, Schafer AI. Goldman-Cecil Medicine. 27th ed. International ed. Elsevier; 2024.",
]):
    add_text(sl, r, 0.5, 1.4 + i*0.65, 12.3, 0.58, size=12, color=C_WHITE)

buf = BytesIO(); prs.save(buf)
with open("/tmp/workspace/genetics-cbd/PPT4_Chromosomal_Anomalies.pptx", "wb") as f:
    f.write(buf.getvalue())
print("PPT4 saved OK")
Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.
This is a shared conversation. Sign in to Orris to start your own chat.