RandomGenotypeFamily
家系図を与え、指定マーカーについて、アレルとそのアレル頻度情報から、適当にその家系図を満足するジェノタイプデータを作る
G<-RandomGenotypeFamily(p,NL,Alleles,Probs)
G2<-RandomGenotypeFamily(p,NL,Alleles,Probs,missing=TRUE)
RandomGenotypeFamily<-function(d,n,Alleles,Probs,missing=FALSE){
ns<-length(d[,1])
g<-array(0,c(ns,2,n))
noparents<-which(d[,2]==0,d[,3]==0)
for(i in noparents){
for(j in 1:n){
g[i,,j]<-sample(Alleles[[j]],2,replace=TRUE,Probs[[j]])
}
}
given<-rep(0,ns)
given[noparents]<-1
loop<-TRUE
if(sum(given)==ns)loop<-FALSE
while(loop){
yet<-which(given==0)
for(i in yet){
prt1<-d[i,2]
prt2<-d[i,3]
if(given[prt1]+given[prt2]==2){
for(j in 1:n){
g[i,1,j]<-sample(g[prt1,,j],1)
g[i,2,j]<-sample(g[prt2,,j],1)
}
given[i]<-1
}
}
if(sum(given)==ns)loop<-FALSE
}
if(missing){
Type<-p[,5]
G2<-array(0,c(length(p[,1]),2,NL))
G2[which(Type==1),,]<-G[which(Type==1),,]
g<-G2
}
g
}
\name{RandomGenotypeFamily}
\alias{RandomGenotypeFamily}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
RandomGenotypeFamily
}
\description{
家系図を与え、指定マーカーについて、アレルとそのアレル頻度情報から、適当にその家系図を満足するジェノタイプデータを作る。シミュレーションのため。
}
\usage{
G<-RandomGenotypeFamily(p,NL,Alleles,Probs)
G2<-RandomGenotypeFamily(p,NL,Alleles,Probs,missing=TRUE)
}
\arguments{
\item{p}{家系情報の行列}
\item{Np}{人数}
\item{NL}{マーカー数}
\item{Alleles}{アレル名のベクトルのリスト}
\item{Probs}{アレル頻度のベクトルのリスト}
\item{missing}{TRUEまたはFALSE。TRUEの場合には、DNAサンプル提供者のみジェノタイプがある}
}
%- maybe also 'usage' for other objects documented here.
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
ディプロタイプを表す、3次元アレイ(人数x2xマーカー数)
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
}
\examples{
p<-matrix(
c(1:8,
0,0,1,0,3,3,3,3,
0,0,2,0,4,4,4,4,
1,0,1,0,1,1,0,0,
1,1,2,1,1,1,2,1),
ncol=5)
NL<-15
AandP<-MakeAlleleProb(NL=NL)
Alleles<-AandP$Alleles
Probs<-AandP$Probs
G<-RandomGenotypeFamily(p,NL,Alleles,Probs)
G2<-RandomGenotypeFamily(p,NL,Alleles,Probs,missing=TRUE)
}