ある家系に1人以上の被捜索者がいるときにすべての捜索パターンをテストする

  • 予定パッケージ名
    • HigashiNopponLikelihood
  • 関数名
    • TestAllPatterns
  • タイトル
TestAllPatterns
  • 説明
ある家系に属する1人以上のメンバーが被捜索者となっていて、そのうちの0人以上、全員以下が候補者プールに含まれうる。被捜索者は候補者プールのうちの一部でもありえるし、全員でもあり得る。そのうえで、被捜索者は、1人から全員の全通りについて、また、候補者については、すべての場合について、尤度を計算する
  • 使用例
TestAllPatterns(p=p,G=G2,Gpool=Gpool2,candidates=candidates,Alleles=Alleles,Probs=Probs)
  • ソース
TestAllPatterns<-function(p,G,Gpool,candidates,Alleles,Probs){
	ptemp<-MakePedigreeFromFamilyInfo(p)

	tobeSearched<-which(p[,5]==2)
	SearchPattern<-MakeSearchPattern(tobeSearched)
	ret<-NULL
	ret2<-NULL
	ret3<-NULL
	counter<-1
	for(i in 1:length(SearchPattern$X)){
		spx<-as.matrix(SearchPattern$X[[i]])
		
		for(j in 1:length(spx[,1])){
			
			ToTestCurrent<-spx[j,]
			tmpG2<-G
			#print(tmpG2[,,1])
			tobeEvaluated<-rep(0,length(p[,1]))
			tobeEvaluated[which(p[,5]==1)]<-1
			tobeEvaluated[which(p[,5]==3)]<-1
			tobeEvaluated[ToTestCurrent]<-1
			tmpp<-p[which(tobeEvaluated==1),]
			tmptmpG2<-tmpG2[which(tobeEvaluated==1),,]
			if(length(tmpG2[1,1,])==1){
				tmptmpG2<-array(0,c(length(which(tobeEvaluated==1)),2,1))
				tmptmpG2[,,1]<-tmpG2[which(tobeEvaluated==1),,]
			}

			#print(tmptmpG2)

			#print("---")
			#print(tmpG2)
			#print(tobeEvaluated)
			#print(tmpp)
			#print(tmptmpG2)
			ret[[counter]]<-CalcLogLikelihoodFamily(tmpp,tmptmpG2,Alleles,Probs)
			ret2[[counter]]<-list(ToTestCurrent)
			ret3[[counter]]<-list()
			#print(ret[[counter]])
		
			counter<-counter+1
			
			numtested<-length(spx[j,])
			tmpcandidates<-NULL

			for(k in 1:numtested){
				selectedToBeTested<-which(tobeSearched==spx[j,k])
				
				tmpcandidates[[k]]<-candidates[[selectedToBeTested]]
			}
			tmpTestPattern<-MakeTestPattern(tmpcandidates)
			for(k in 1:length(tmpTestPattern[,1])){
				#print("to be tested IDs in pedigree")
				#print(ToTestCurrent)
				#print("to be tested sampleIDs in pool")
				#print(tmpTestPattern[k,])

				tmpG2<-G
				tmpG2[ToTestCurrent,,]<-Gpool[tmpTestPattern[k,],,]

				tobeEvaluated<-rep(0,length(p[,1]))
				tobeEvaluated[which(p[,5]==1)]<-1
				tobeEvaluated[which(p[,5]==3)]<-1
				tobeEvaluated[ToTestCurrent]<-1
				tmpp<-p[which(tobeEvaluated==1),]
				tmptmpG2<-tmpG2[which(tobeEvaluated==1),,]
				if(length(tmpG2[1,1,])==1){
					tmptmpG2<-array(0,c(length(which(tobeEvaluated==1)),2,1))
					tmptmpG2[,,1]<-tmpG2[which(tobeEvaluated==1),,]
				}

				#print("---")
				#print(tobeEvaluated)
				#print(tmpp)
				#print(tmptmpG2)
				ret[[counter]]<-CalcLogLikelihoodFamily(tmpp,tmptmpG2,Alleles,Probs)
				
				#ret[[counter]]<-CalcLogLikelihoodFamily(p,tmpG2,Alleles,Probs)
				ret2[[counter]]<-list(ToTestCurrent)
				ret3[[counter]]<-list(tmpTestPattern[k,])

				#print(ret[[counter]])
				counter<-counter+1
			}
		}
	}
	
	list(LogLike=ret,SearchedID=ret2,CandidateID=ret3,familyinfo=p,pedigree=ptemp,tobeSearched=tobeSearched,candidates=candidates,offeredGenotype=G,poolGenotype=Gpool,Alleles=Alleles,Probs=Probs)
}
  • Rdファイル
\name{TestAllPatterns}
\alias{TestAllPatterns}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
TestAllPatterns
}
\description{
ある家系に属する1人以上のメンバーが被捜索者となっていて、そのうちの0人以上、全員以下が候補者プールに含まれうる。被捜索者は候補者プールのうちの一部でもありえるし、全員でもあり得る。そのうえで、被捜索者は、1人から全員の全通りについて、また、候補者については、すべての場合について、尤度を計算する
}
\usage{
TestAllPatterns(p=p,G=G,Gpool=Gpool,candidates=candidates,Alleles=Alleles,Probs=Probs)
}
\arguments{
\item{p}{家系関係行列}
\item{G}{ジェノタイプ}
\item{Gpool}{候補者を含むプールサンプルのジェノタイプ}
\item{candidates}{被捜索者ごとのプール内候補ベクトルを要素とするリスト}
\item{Alleles}{アレル名ベクトルのリスト}
\item{Probs}{アレル頻度ベクトルのリスト}
}
%- maybe also 'usage' for other objects documented here.
\details{
%%  ~~ If necessary, more details than the description above ~~
}
\value{
\item{LogLike}{全捜索パターンの対数尤度}
\item{SearchedID}{全捜索パターンの被捜索対象者をベクトルとするリスト}
\item{CandidateID}{全捜索パターンの被捜索対象者ごとの候補者ID}
\item{familyinfo}{家系情報行列}
\item{pedigree}{家系pedigreeオブジェクト}
\item{tobeSearched}{家系内の被捜索者ベクトル}
\item{candidates}{被捜索者ごとの候補者IDベクトルを要素とするリスト}
\item{offeredGenotype}{提供された家族メンバーのジェノタイプの行列}
\item{poolGenotype}{候補者プールのジェノタイプ行列}
\item{Alleles}{アレル名ベクトルのリスト}
\item{Probs}{アレル頻度のベクトルのリスト}
}
\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)
tap<-TestAllPatterns(p=p,G=G,Gpool=Gpool,candidates=candidates,Alleles=Alleles,Probs=Probs)
printTAPout(tap)

}