Пример #1
0
	def setUpClass(self):
		from fastlmm.util.util import create_directory_if_necessary
		create_directory_if_necessary(self.tempout_dir, isfile=False)
		self.pythonpath = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__))))
		self.bedbase = os.path.join(self.pythonpath, 'dataset1/dataset1')		
		self.phen_fn = os.path.join(self.pythonpath, 'dataset1/dataset1.phe')
		
		#Create eigendecompositions
		logging.info("Creating eigendecomposition files")		
		for i in xrange(1,11):
			output_file = os.path.abspath(os.path.join(self.tempout_dir, 'dataset1_nochr{}.npz'.format(i)))
			extractSim = 'dataset1/extracts/nochr{0}_extract.txt'.format(i)
			bed, _ = leapUtils.loadData(self.bedbase, extractSim, self.phen_fn, loadSNPs=True)
			leapMain.eigenDecompose(bed, output_file)
Пример #2
0
#Iterate over each chromosome
frame_list = []
for chrom in chromosomes:
    print()
    print('Analyzing chromosome', chrom, '...')

    #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,
                         h2coeff=1.0)

    #Compute liabilities explained by this data
    liabs = leapMain.probit(bedExclude,
                            phenoFile,
                            h2,
                            prevalence,
                            eigen,
                            keepArr=indsToKeep)
Пример #3
0
#Iterate over each chromosome
frame_list = []
for chrom in chromosomes:
	print
	print 'Analyzing chromosome', chrom, '...'

	#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))