def pv_adj_and_ind(self, nperm, pv_adj, nullfit, lrt, lrtperm, alteqnull, alteqnullperm, qmax, nullfitfile, nlocalperm): if nlocalperm>0: #don't do the fitting ind = pv_adj.argsort() return pv_adj, ind from fastlmm.association.tests import Cv return Cv.pv_adj_and_ind(nperm, pv_adj, nullfit, lrt, lrtperm, alteqnull, alteqnullperm, qmax, nullfitfile, nlocalperm) # call the shared version of this method
def recalibrate(dirin,filepattern='*.txt', lrtpermfile=None, pnames=["P-value(50/50)"], rownames=rownames(), nullfit="qq",qmax=0.1, postfix="RECALIBRATED"): ''' Read in each results file, use the null stats in lrtpermfile to re-calibrate the null distribution, and then add a column to each file ''' assert lrtpermfile is not None, "must provide lrtpermfile (output by FastLmmSet.py with lrt)" myfiles = getfiles(dirin, filepattern) ii=0 for f in myfiles: ii=ii+1 print str(ii) + ") " + f pv,rowids,llnull,llalt = extractpvals(f,pnames,rownames) lrt = -2*(llnull-llalt) alteqnull = (lrt==0) pv_adj = Cv.pv_adj_and_ind(nperm=0, pv_adj=None, nullfit=nullfit, lrt=lrt, lrtperm=None, alteqnull=alteqnull, alteqnullperm=None, qmax=qmax, nullfitfile=lrtpermfile, nlocalperm=0, sort=False)[0] outfile = ut.appendtofilename(f,postfix) np.savetxt(outfile, pv_adj)