MendelCreature Genetics
Neutral Gender Breeding Example

This notebook is an annotated walkthrough of the MendelCreature genetics package, using the MendelPeas package to explore methods for determining dominance, trait linkage and allele frequency. Note that in regards to chromosomal details, MendelPeas are fictional examples, although they do share the traits studied by Mendel.

Getting started
	To begin, we set the appropriate package directory and import the MendelPeas.m package

SetDirectory["C:\Documents and Settings\grl\My \
Documents\Mathematica"];
<< MendelPeas.m

Type explains a bit about the genome we have just loaded

TYPE

Instead of making an original and new population, we can load one from memory, so it will be the same for the walkthrough (PeaPatch = MakePop[5000] generates a new, random population).

<< MendelPeasEg.mx
Length[PeaPatch]
Sample  =  Take[PeaPatch, 10];
ShowPop[Sample]

Determining Dominance
	Select all individuals from the large population with what appear to be all dominant traits, and choose one of them.

\(\(DomGuess\  = \ 
        FindTraitMatches[
          PeaPatch, {"Smooth Seeds", "Yellow Seeds", "Tall Stems", "Inflated Pods", \ "Yellow Pods", "White Flowers", "Axial Flowers"}, And];\)\)
OneDom  =  DomGuess[[1]];
ShowOne[OneDom]

Do the same for recessive traits, although we don't know what is opposite 'axial'.  Might need to do only some of the traits if this individual doen't exist!

RecGuess  =  
        FindTraitMatches[
          PeaPatch, {"Wrinkled Seeds", "Green Seeds", "Dwarf \
Stems", "Constricted Pods",  "Green Pods", "Purple Flowers"}, 
          And];
OneRec  =  RecGuess[[1]];
ShowOne[OneRec]

Cross suspected dominant with itself.  100 % means OneDom is homozygous (but not necessarily dominant!), near 75% means OneDom is heterozygous dominant.

DomG1  =  Breed[OneDom, OneDom, 100];
CountTrait[DomG1, "Smooth Seeds"]
CountTrait[DomG1, "Yellow Seeds"]
CountTrait[DomG1, "Tall Stems"]
CountTrait[DomG1, "Inflated Pods"]
CountTrait[DomG1, "Yellow Pods"]
CountTrait[DomG1, "White Flowers"]
CountTrait[DomG1, "Axial Flowers"]

Confirmed Dominant: Smooth Seeds, Yellow Seeds, Tall Stems, Inflated Pods	
	Unknown Homozygous: Green Pods, White Flowers, Axial Flowers
	Same test for suspected recessive.  100 % means OneRec is homozygous, near 75% means OneRec is actually heterozygous dominant!

RecG1  =  Breed[OneRec, OneRec, 100];
CountTrait[RecG1, "Wrinkled Seeds"]
CountTrait[RecG1, "Green Seeds"]
CountTrait[RecG1, "Dwarf Stems"]
CountTrait[RecG1, "Constricted Pods"]
CountTrait[RecG1, "Green Pods"]
CountTrait[RecG1, "Purple Flowers"]

Looks like Green Pods are actually dominant to Yellow Pods! 
	Now breed OneDom to OneRec and compare double homozygous traits (in this case Purple Flowers to White Flowers

DoReG1 = Breed[OneDom, OneRec, 100];
CountTrait[DoReG1, "Purple Flowers"]
CountTrait[DoReG1, "White Flowers"]

Purple Flowers  are apparently dominant!
Allele frequency 
	Look at number of recessive individuals in general population. Note that recessive Yellow Pods and White Flowers are each actually in the majority.

wscount = CountTrait[PeaPatch, "Wrinkled Seeds"]

gscount  = CountTrait[PeaPatch, "Green Seeds"]

dscount  = CountTrait[PeaPatch, "Dwarf Stems"]

cpcount  = CountTrait[PeaPatch, "Constricted Pods"]

ypcount = CountTrait[PeaPatch, "Yellow Pods"]

wfcount = CountTrait[PeaPatch, "White Flowers"]

Hardy-Weinberg says 'frequency of recessive allele' * 'frequency of recessive allele' = fraction of homozygous recessives. For Wrinkled Seeds

q  = N[ (Sqrt[wscount])[[3]]]

So 49.9% (~ 50%) of "Seed texture" alleles in population are Wrinkled recessive.
	For Yellow Pods

q  = N[ (Sqrt[ypcount])[[3]]]

About 90% of "Pod color" alleles are Yellow recessive, which means that nature likely selects for Yellow Pods, despite the gene being recessive to Green Pods.
Finding an infrequent trait
	Breed samples with themselves, looking for an Axial Flowers homozygote.

Test1 = Breed[Sample[[1]], Sample[[1]], 100]; 
    CountTrait[Test1, "Axial Flowers"]

Test2 = Breed[Sample[[2]], Sample[[2]], 100]; 
    CountTrait[Test2, "Axial Flowers"]

Take a sample. Approx.1 out 4 should be the 'other' phenotype.

FlowerSample  =  Take[Test2, 10];
ShowPop[FlowerSample]

Missing trait is Terminal Flowers, which are apparently very rare.

CountTrait[PeaPatch, {"Terminal Flowers"}]

Determining linkages
	OneDom is known heterozygous for Smooth Seeds, Yellow Seeds, Tall Stems and Inflated Pods. OneRec is known homozygous recessive for the matching traits. DoRegG1 should be 50% recessive, 50% heterozygous.

CountTrait[DoReG1, "Smooth Seeds"]
CountTrait[DoReG1, "Yellow Seeds"]
CountTrait[DoReG1, "Tall Stems"]
CountTrait[DoReG1, "Inflated Pods"]

If traits are independent, then (fraction of population with first trait) * (fraction of population with second trait) = (fraction of population with both traits), so we should expect approximately .50*.50 = .25 match for independent trait pairs.

CountTraitMatch[DoReG1, {"Smooth Seeds", "Yellow Seeds"}, 
      And]
CountTraitMatch[DoReG1, {"Smooth Seeds", "Tall Stems"}, 
      And]
CountTraitMatch[DoReG1, {"Smooth Seeds", "Inflated Pods"}, 
      And]
CountTraitMatch[DoReG1, {"Yellow Seeds", "Tall Stems"}, 
      And]
CountTraitMatch[DoReG1, {"Yellow Seeds", "Inflated Pods"}, 
      And]
CountTraitMatch[DoReG1, {"Tall Stems", "Inflated Pods"}, 
      And]

For all combinations but one there appears to be a distribution near 25%, which is very likely independent.  However, there is not an independent distribution of Smooth Seeds and Inflated Pods, as none of the offspring have both traits!  About half are Smooth Seed/Constricted Pod, and the other half Wrinkled Seed/Inflated Pod, meaning they received a linked Wrinkled/Constricted from the recessive parent (the only possibility) and either a linked Wrinkled/Inflated or linked Smooth/Constricted from the heterozygous parent!	 So seed texture and pod condition are linked!

CountTraitMatch[DoReG1, {"Smooth Seeds", "Constricted Pods"}, 
      And]

CountTraitMatch[DoReG1, {"Wrinkled Seeds", "Inflated Pods"}, 
      And]

The End
	The statement below was used to save the original patch in the file you initially loaded.

DumpSave["MendelPeasEg.mx", {PeaPatch}];

This notebook created by Dr. Garrett R. Love for the Shodor Education Foundation. Copyright 2002