Example #1
0
def RunGWAS(filename,k=5,eps=2.0):
	sz=450
	[[y1,sFil1],[y2,sFil2]]=loadData(filename=filename,useRand=False,sz=sz);

	MU1=MU_STRAT(sFil1,k);	
	MU2=MU_STRAT(sFil2,k);
	print "EXACT1!"
	MU1.calcMU(k,exact=True)
	print "Exact 2!"
	MU2.calcMU(k,exact=True);

	res=pt(y1,MU1,1,-1,algor="noise");

	resL=pt(y1,MU1,20,-1,algor="noise");
	print resL
	#print wt(y1,MU1,-1,snps=res);
	res2=pt(y2,MU2,1,-1,algor="noise");
	print res;
	resT=res;
	print res2;
	resT=wt(y2,MU2,eps,snps=resL[5:7]);
	res2=wt(y1,MU1,eps,snps=res);
	res3=wt(y1,MU1,-1,snps=[]);

	res4=wt(y2,MU2,-1,snps=[]);
	n=len(y2);

	print len(y1);
	print n;
	val=[resT[0]*(n-k-1),resT[1]*(n-k-1)]

	n2=len(y1);	
	print "In Val:"
	print val;
	print "In Orig"
	print res2[0]*(n2-k-1);

	n2=len(y1);	
	print np.median(res3)*(n2-k-1)

	n2=len(y1);	
	res3=sorted(res3,reverse=True)[:10];
	res3=[(n2-k-1)*i for i in res3];
	print res3

	fil=open("saveRes.txt","w")
	for r in res4:
		fil.write(str(r)+"\n")
	fil.close();
	res4=sorted(res4,reverse=True)[:20];
	res3=[(n-k-1)*i for i in res4];
	print res3
	CIlst=CI(y2,MU2,.95,2.0,resL[5:6]);
	CIlst2=CI(y2,MU2,.95,2.0,resL[6:7]);
	CIlst=[[(n-k-1)*i for i in s] for s in CIlst]
	CIlst22=[[(n-k-1)*i for i in s] for s in CIlst2]
	print CIlst;
	print CIlst2;
Example #2
0
def TestCase(cutoff=23,num=2,filename="../GWAS/NoFam_0.05",k=10,sz=450):
	[[y1,sFil1],[y2,sFil2]]=loadData(filename=filename,useRand=False,sz=sz);
	MU1=MU_STRAT(sFil1,k)
	MU2=MU_STRAT(sFil2,k)

	n=len(y2);
	n2=len(y1);
	print "Exact 1!"
	MU1.calcMU(k,exact=True);
	print "Exact 2!"
	MU2.calcMU(k,exact=True);

	print "Get top in set 1"
	top1=pt(y1,MU1,20,-1,algor="noise");
	print "Get Scores"
	scores=wt(y1,MU1,-1,snps=top1);

	print "Get "+str(num)+" SNPs directly below "+str(cutoff);
	i=min([i for i in range(0,len(top1)) if scores[i]<cutoff/float(n2-k-1)])
	print top1[i];
	print float((n2-k-1)*scores[i])
	#print i;
	#print scores[:10];
	print "";
	print top1[i+1];
	print float((n2-k-1)*scores[i+1])

	CIlst=CI(y2,MU2,.95,2.0,top1[i:i+2]);
	Clst=[[(n-k-1)*i for i in s] for s in CIlst]
	print Clst;
Example #3
0
def plotWald(eps,filename,savename="",k=5):
	if len(savename)==0:
		savename="OutputDir/res_wald_"+str(eps[0])+"_"+str(k)+".txt"
	print "load Data"
	[y,BED]=ld.getData(filename);
	print "calc MU!"
	MU=MU_STRAT(BED,k);
	print "get True!";
	tru=wt(y,MU,-1,snps=[],forFigs=False);
	fil=open(savename,"w");
	n=len(y);
	for i in range(0,10):
		e=eps[i];
		print e;
		res=wt(y,MU,e,snps=[],forFigs=True);
		err=sorted([float(n-k-1)*abs(res[i]-tru[i]) for i in range(0,len(tru))]);
		m=len(err);
		med=err[int(.5*m)]
		up=err[int(.75*m)];
		down=err[int(.25*m)];
		print med;
		fil.write(str(e)+" "+str(down)+" "+str(med)+" "+str(up)+"\n");
	fil.close();