Exemplo n.º 1
0
	def test(self):
		"""Test Benjamini-Hochberg P-value adjustment"""
		adjps = stats.adjustPValues([0.1,0.2,0.3,0.4], method='FDR')
		self.assertTrue(round(adjps[0],1)==0.4)
		self.assertTrue(round(adjps[1],1)==0.4)
		self.assertTrue(round(adjps[2],1)==0.4)
		self.assertTrue(round(adjps[3],1)==0.4)

		adjps = stats.adjustPValues([0.1,0.2,0.003], method='fdr')
		self.assertTrue(round(adjps[0],2)==0.15)
		self.assertTrue(round(adjps[1],1)==0.2)
		self.assertTrue(round(adjps[2],3)==0.009)
Exemplo n.º 2
0
	def test(self):
		"""Test Benjamini-Hochberg P-value adjustment, ordering"""
		sp.random.seed(111)
		n = 3
		#pvals = sp.array(range(n-1,-1,-1))/1.0e5
		#ranks = st.rankdata(sp.random.random(len(pvals)))
		#pvals = [pvals[x-1] for x in ranks]
		pvals = [0.0, 2e-5, 1e-5]
		adjps = stats.adjustPValues(pvals, method='FDR')
		#print ""
		#for i in range(n):
		#	print "{:1.6E}\t{:1.6E}".format(pvals[i],adjps[i])
		for i in range(n):
			self.assertTrue(adjps[i] >= pvals[i])
Exemplo n.º 3
0
			p_value_list.append(pval)
			try:
				length_dict[length].append(key)
			except KeyError:
				length_dict[length] = [key]
		except KeyError:
			print "Erroring...this should not continue"
			p_value_dict[key] = 1.0
			p_value_list.append(1.0)
			continue
	if options.adjust:
		# Each distribution, based on length, gets its own correction
		for length in length_dict.keys():
			len_keys = length_dict[length]
			p_values = [p_value_dict[lk] for lk in len_keys]
			adjusted_p_values = stats.adjustPValues(p_values, method='FDR')
			for (i,k) in enumerate(len_keys):
				adjusted_p_value_dict[k] = adjusted_p_values[i]
		#adjusted_p_value_dict = dict([(k, v) for (k,v) in zip(keys, adjusted_p_values)])
	
	# Write output
	n_written = 0
	# Tack sequence on the end, for better readability
	columns = headers[:]
	columns.remove('sequence')
	data_outs.write('\t'.join(columns) + "\tp.value\tp.value.adj\tsequence\n")
	for key in keys:
		flds = data[key]
		#entropy = flds['entropy']
		#length = flds['length'] # length of the region
		pval = p_value_dict[key]
Exemplo n.º 4
0
	def test(self):
		"""Test Benjamini-Hochberg P-value adjustment, ordering"""
		pvals = sp.array(range(100,-1,-1))/1.0e5
		adjps = stats.adjustPValues(pvals, method='FDR')
		for i in range(1,10):
			self.assertTrue(adjps[i]<adjps[i-1])