Exemple #1
0
	def test_probit(self):
		logging.info("Leap test_probit")		
		related_file = os.path.abspath(os.path.join(self.gold_dir, 'dataset1.related'))
		bed, _ = leapUtils.loadData(self.bedbase, None, self.phen_fn, loadSNPs=False)
		keepArr = leapUtils.loadRelatedFile(bed, related_file)
		
		for i in xrange(1,11):
			h2_file = os.path.abspath(os.path.join(self.gold_dir, 'dataset1_nochr{0}.h2'.format(i)))
			h2 = np.loadtxt(h2_file, usecols=[0])
			eigen_file = os.path.abspath(os.path.join(self.tempout_dir, 'dataset1_nochr{}.npz'.format(i)))
			eigen = np.load(eigen_file)
			ref_file = os.path.abspath(os.path.join(self.gold_dir, 'dataset1_nochr{}.liabs'.format(i)))
			extractSim = 'dataset1/extracts/nochr{0}_extract.txt'.format(i)
			bed, _ = leapUtils.loadData(self.bedbase, extractSim, self.phen_fn, loadSNPs=True)
			output_file = os.path.abspath(os.path.join(self.tempout_dir, 'dataset1_nochr{}'.format(i)))
			leapMain.probit(bed, self.phen_fn, h2=h2, prev=0.001, eigen=eigen, outFile=output_file, keepArr=keepArr, hess=False)
			self.compare_pheno(ref_file, output_file+'.liabs')
Exemple #2
0
    #Compute eigendecomposition for the data
    eigenFile = 'temp_eigen.npz'
    eigen = leapMain.eigenDecompose(bedExclude, outFile=eigenFile)

    #compute heritability explained by this data
    h2 = leapMain.calcH2(phenoFile,
                         prevalence,
                         eigen,
                         keepArr=indsToKeep,
                         h2coeff=1.0)

    #Compute liabilities explained by this data
    liabs = leapMain.probit(bedExclude,
                            phenoFile,
                            h2,
                            prevalence,
                            eigen,
                            keepArr=indsToKeep)

    #perform GWAS, using the liabilities as the observed phenotypes
    results_df = leapMain.leapGwas(bedExclude, bedTest, liabs, h2)
    frame_list.append(results_df)

#Join together the results of all chromosomes, and print the top ranking SNPs
frame = pd.concat(frame_list)
frame.sort("PValue", inplace=True)
frame.index = np.arange(len(frame))
print('Top 10 most associated SNPs:')
print(frame.head(n=10))
Exemple #3
0
	#Create a bed object excluding SNPs from the current chromosome
	bedExclude = leapUtils.getExcludedChromosome(bfile, chrom)
	
	#Create a bed object including only SNPs from the current chromosome
	bedTest = leapUtils.getChromosome(bfile, chrom)	
	
	#Compute eigendecomposition for the data
	eigenFile = 'temp_eigen.npz'
	eigen = leapMain.eigenDecompose(bedExclude, outFile=eigenFile)
	
	#compute heritability explained by this data
	h2 = leapMain.calcH2(phenoFile, prevalence, eigen, keepArr=indsToKeep)
	
	#Compute liabilities explained by this data
	liabs = leapMain.probit(bedExclude, phenoFile, h2, prevalence, eigen, keepArr=indsToKeep)
	
	#perform GWAS, using the liabilities as the observed phenotypes
	results_df = leapMain.leapGwas(bedExclude, bedTest, liabs, h2)
	frame_list.append(results_df)

#Join together the results of all chromosomes, and print the top ranking SNPs
frame = pd.concat(frame_list)
frame.sort("PValue", inplace=True)
frame.index = np.arange(len(frame))
print 'Top 10 most associated SNPs:'
print frame.head(n=10)