- 4. 両親のジェノタイプから子のジェノタイプを作る
father<-MakeHaplotype(NaS,PaS,2)
mother<-MakeHaplotype(NaS,PaS,2)
father
mother
father.gamates<-Rec.Haplotype(father[1,],father[2,],Dg)
mother.gamates<-Rec.Haplotype(mother[1,],mother[2,],Dg)
from.father<-father.gamates[sample(1:2,1),]
from.mother<-mother.gamates[sample(1:2,1),]
offspring<-matrix(c(from.father,from.mother),byrow=TRUE,nrow=2)
offspring
father
mother
offspring
-
- 両親のジェノタイプから子のジェノタイプを作る処理を関数にする
MakeOffspring<-function(father,mother,d){
father.gamates<-Rec.Haplotype(father[1,],father[2,],d)
mother.gamates<-Rec.Haplotype(mother[1,],mother[2,],d)
from.father<-father.gamates[sample(1:2,1),]
from.mother<-mother.gamates[sample(1:2,1),]
offspring<-matrix(c(from.father,from.mother),byrow=TRUE,nrow=2)
offspring
}
offspring<-MakeOffspring(father,mother,Dg)
father
mother
offspring