コード例 #1
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_favites_phyloscanner_sharptni_tnet_new_tnet_bias_directed(bootstrap_th, sample_th):
	F1_file = open('results/sharptni_min_coinfection_directed_comparison/favites.phyloscanner.sharptni.min.coinf.tnet.new.tnet.bias.sample_th.' + str(sample_th) + '.bootstrap_th.' + str(bootstrap_th) + '.csv', 'w+')
	F1_file.write('dataset,phylo_prec,phylo_rec,phylo_f1,sharp_prec,sharp_rec,sharp_f1,tnet_prec,tnet_rec,tnet_f1,tnet_bias_prec,tnet_bias_rec,tnet_bias_f1\n')

	folders = next(os.walk('outputs/'))[1]
	old_output_dir = '/home/saurav/research/FAVITES_compare_TNet_v2/outputs/'

	for folder in folders:
		print('inside folder:', folder)
		F1 = []
		boot_th = len(next(os.walk('dataset/' + folder + '/rooted_bootstrap_trees'))[2])
		boot_th = math.ceil(boot_th * (bootstrap_th / 100))

		real = set(ge.get_real_edges('dataset/' + folder + '/transmission_network.txt'))
		phylo = set(ge.get_phyloscanner_summary_trans_edges(old_output_dir + folder + '/phyloscanner_output_100_bootstrap/favites_hostRelationshipSummary.csv', boot_th))
		sharptni = set(ge.get_tnet_summary_edges('outputs/' + folder + '/sharptni_bootstrap_min_coinfection_summary_directed/sankoff_sample_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))
		tnet = set(ge.get_tnet_summary_edges(old_output_dir + folder + '/tnet_new_bootstrap_summary_directed/tnet_new_100_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))
		tnet_bias = set(ge.get_tnet_summary_edges('outputs/' + folder + '/tnet_new_with_bias_bootstrap_summary_directed/tnet_new_100_bootstrap_with_bias_th_' + str(sample_th) + '_summary.csv', boot_th))

		F1.extend(get_prec_rec_f1(real, phylo))
		F1.extend(get_prec_rec_f1(real, sharptni))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_bias))
		F1_file.write('{},{},{},{},{},{},{},{},{},{},{},{},{}\n'.format(folder,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8],F1[9],F1[10],F1[11]))

	F1_file.close()
コード例 #2
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_cdc_directed(threshold):
	F1_file = open('results/cdc_directed_comparison/cdc.phyloscanner.tnet.new.tnet.bias.th.' + str(threshold) + '.csv', 'w+')
	F1_file.write('dataset,phylo_prec,phylo_rec,phylo_f1,tnet_prec,tnet_rec,tnet_f1,tnet_bias_prec,tnet_bias_rec,tnet_bias_f1\n')
	out_dir = '/home/saurav/research/FAVITES_compare_TNet_v2/'

	for outbreak in cdc.known_outbreaks:
		F1 = []
		bootstrap = len(next(os.walk('CDC/' + outbreak + '/tnet_input'))[2])

		real = set(cdc.get_true_transmission_edges(outbreak))
		phylo = set(ge.get_phyloscanner_summary_trans_edges('CDC/' + outbreak + '/phyloscanner_output/cdc_hostRelationshipSummary.csv', bootstrap//2))
		tnet = set(ge.get_tnet_summary_edges(out_dir + 'CDC/' + outbreak + '/tnet_new_bootstrap_summary_directed/tnet_new_bootstrap_th_' + str(threshold) + '_summary.csv', bootstrap//2))
		tnet_bias = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/tnet_new_bootstrap_with_bias_summary_directed/tnet_new_bootstrap_th_' + str(threshold) + '_summary.csv', bootstrap//2))

		F1.extend(get_prec_rec_f1(real, phylo))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_bias))
		F1_file.write('{},{},{},{},{},{},{},{},{},{}\n'.format(outbreak,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8]))

	F1_file.close()
コード例 #3
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_favites_sharptni_tnet_bias_tnet_min_coinf_directed(bootstrap_th, sample_th):
	F1_file = open('results/tnet_min_coinfection/favites.sharptni.min.coinf.tnet.bias.tnet.min.coinf.sample_th.' + str(sample_th) + '.bootstrap_th.' + str(bootstrap_th) + '.csv', 'w+')
	F1_file.write('dataset,sharp_prec,sharp_rec,sharp_f1,tnet_prec,tnet_rec,tnet_f1,tnet_min_prec,tnet_min_rec,tnet_min_f1\n')

	folders = next(os.walk('outputs/'))[1]

	for folder in folders:
		print('inside folder:', folder)
		F1 = []

		real = set(ge.get_real_edges('dataset/' + folder + '/transmission_network.txt'))
		sharptni = set(ge.get_tnet_summary_edges('outputs/' + folder + '/sharptni_bootstrap_min_coinfection_summary_directed/sankoff_sample_bootstrap_th_' + str(sample_th) + '_summary.csv', bootstrap_th))
		tnet = set(ge.get_tnet_summary_edges('outputs/' + folder + '/tnet_new_with_bias_bootstrap_summary_directed/tnet_new_100_bootstrap_with_bias_th_' + str(sample_th) + '_summary.csv', bootstrap_th))
		tnet_min_coinf = set(ge.get_tnet_summary_edges('outputs/' + folder + '/tnet_new_100_bootstrap_with_bias_min_coinfection_summary_directed/tnet_bootstrap_th_' + str(sample_th) + '_summary.csv', bootstrap_th))

		F1.extend(get_prec_rec_f1(real, sharptni))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_min_coinf))
		F1_file.write('{},{},{},{},{},{},{},{},{},{}\n'.format(folder,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8]))

	F1_file.close()
コード例 #4
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_cdc_sharptni_tnet_directed(bootstrap_th, sample_th):
	F1_file = open('results/sharptni_directed_comparison/cdc.sharptni.tnet.new.tnet.bias.sample_th.' + str(sample_th) + '.bootstrap_th.' + str(bootstrap_th) + '.csv', 'w+')
	F1_file.write('dataset,sharp_prec,sharp_rec,sharp_f1,tnet_prec,tnet_rec,tnet_f1,tnet_bias_prec,tnet_bias_rec,tnet_bias_f1\n')

	for outbreak in cdc.known_outbreaks:
		print('inside outbreak:',outbreak)
		F1 = []
		boot_th = len(next(os.walk('CDC/' + outbreak + '/tnet_input'))[2])
		boot_th = math.ceil(boot_th * (bootstrap_th / 100))

		real = set(cdc.get_true_transmission_edges(outbreak))
		sharptni = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/sharptni_sankoff_sample_bootstrap_summary_directed/sankoff_sample_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))
		tnet = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/tnet_new_bootstrap_summary_directed/tnet_new_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))
		tnet_bias = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/tnet_new_bootstrap_with_bias_summary_directed/tnet_new_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))

		F1.extend(get_prec_rec_f1(real, sharptni))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_bias))
		F1_file.write('{},{},{},{},{},{},{},{},{},{}\n'.format(outbreak,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8]))

	F1_file.close()
コード例 #5
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_cdc_phyloscanner_sharptni_tnet_new_tnet_bias_directed(bootstrap_th, sample_th):
	F1_file = open('results/sharptni_min_coinfection_directed_comparison/cdc.phyloscanner.sharptni.min.coinf.tnet.new.tnet.bias.sample_th.' + str(sample_th) + '.bootstrap_th.' + str(bootstrap_th) + '.csv', 'w+')
	F1_file.write('dataset,phylo_prec,phylo_rec,phylo_f1,sharp_prec,sharp_rec,sharp_f1,tnet_prec,tnet_rec,tnet_f1,tnet_bias_prec,tnet_bias_rec,tnet_bias_f1\n')

	for outbreak in cdc.known_outbreaks:
		print('inside folder:', outbreak)
		F1 = []
		boot_th = len(next(os.walk('CDC/' + outbreak + '/rooted_bootstrap_trees_100'))[2])
		boot_th = math.ceil(boot_th * (bootstrap_th / 100))

		real = set(cdc.get_true_transmission_edges(outbreak))
		phylo = set(ge.get_phyloscanner_summary_trans_edges('CDC/' + outbreak + '/phyloscanner_output_100/CDC_hostRelationshipSummary.csv', boot_th))
		sharptni = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/sharptni_sankoff_sample_100_bootstrap_min_coinfection_summary_directed/sankoff_sample_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))
		tnet = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/tnet_new_bootstrap_100_summary_directed/tnet_new_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))
		tnet_bias = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/tnet_new_bootstrap_with_bias_100_summary_directed/tnet_new_bootstrap_th_' + str(sample_th) + '_summary.csv', boot_th))

		F1.extend(get_prec_rec_f1(real, phylo))
		F1.extend(get_prec_rec_f1(real, sharptni))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_bias))
		F1_file.write('{},{},{},{},{},{},{},{},{},{},{},{},{}\n'.format(outbreak,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8],F1[9],F1[10],F1[11]))

	F1_file.close()
コード例 #6
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_sharptni_tnet_directed(bootstrap_th, sample_th):
	data_dir = 'outputs/'
	out_dir = '/home/saurav/research/FAVITES_compare_TNet_v2/outputs/'
	folders = next(os.walk(data_dir))[1]
	folders.sort()

	F1_file = open('results/sharptni_directed_comparison/favites.sharptni.tnet.new.tnet.bias.sample_th.' + str(sample_th) + '.bootstrap_th.' + str(bootstrap_th) + '.csv', 'w+')
	F1_file.write('dataset,sharp_prec,sharp_rec,sharp_f1,tnet_prec,tnet_rec,tnet_f1,tnet_bias_prec,tnet_bias_rec,tnet_bias_f1\n')

	for folder in folders:
		print('inside folder: ',folder)
		F1 = []

		real = set(ge.get_real_edges('dataset/' + folder + '/transmission_network.txt'))
		sharptni = set(ge.get_tnet_summary_edges(data_dir + folder + '/sharptni_sankoff_sample_bootstrap_summary_directed/sankoff_sample_bootstrap_th_' + str(sample_th) + '_summary.csv', bootstrap_th))
		tnet = set(ge.get_tnet_summary_edges(out_dir + folder + '/tnet_new_bootstrap_summary_directed/tnet_new_100_bootstrap_th_'+str(sample_th)+'_summary.csv', bootstrap_th))
		tnet_bias = set(ge.get_tnet_summary_edges(data_dir + folder + '/tnet_new_with_bias_bootstrap_summary_directed/tnet_new_100_bootstrap_with_bias_th_'+str(sample_th)+'_summary.csv', bootstrap_th))

		F1.extend(get_prec_rec_f1(real, sharptni))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_bias))
		F1_file.write('{},{},{},{},{},{},{},{},{},{}\n'.format(folder,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8]))

	F1_file.close()
コード例 #7
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_phyloscanner_tnet_directed(bootstrap, threshold):
	data_dir = 'outputs/'
	out_dir = '/home/saurav/research/FAVITES_compare_TNet_v2/outputs/'
	folders = next(os.walk(data_dir))[1]
	folders.sort()

	F1_file = open('results/favites_directed_comparison/bootstrap.'+str(bootstrap)+'.phyloscanner.tnet.new.tnet.bias.th.'+str(threshold)+'.boot_th.100.csv', 'w+')
	F1_file.write('dataset,phylo_prec,phylo_rec,phylo_f1,tnet_prec,tnet_rec,tnet_f1,tnet_bias_prec,tnet_bias_rec,tnet_bias_f1\n')

	for folder in folders:
		print('inside folder: ',folder)
		F1 = []

		real = set(ge.get_real_edges('dataset/' + folder + '/transmission_network.txt'))
		phylo = set(ge.get_phyloscanner_summary_trans_edges(out_dir + folder + '/phyloscanner_output_'+str(bootstrap)+'_bootstrap/favites_hostRelationshipSummary.csv', bootstrap))
		tnet = set(ge.get_tnet_summary_edges(out_dir + folder + '/tnet_new_bootstrap_summary_directed/tnet_new_'+str(bootstrap)+'_bootstrap_th_'+str(threshold)+'_summary.csv', bootstrap))
		tnet_bias = set(ge.get_tnet_summary_edges(data_dir + folder + '/tnet_new_with_bias_bootstrap_summary_directed/tnet_new_'+str(bootstrap)+'_bootstrap_with_bias_th_'+str(threshold)+'_summary.csv', bootstrap))

		F1.extend(get_prec_rec_f1(real, phylo))
		F1.extend(get_prec_rec_f1(real, tnet))
		F1.extend(get_prec_rec_f1(real, tnet_bias))
		F1_file.write('{},{},{},{},{},{},{},{},{},{}\n'.format(folder,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5],F1[6],F1[7],F1[8]))

	F1_file.close()
コード例 #8
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_cdc_undirected(threshold):
	F1_file = open('results/cdc_undirected_comparison/cdc.phyloscanner.tnet.new.th.' + str(threshold) + '.csv', 'w+')
	F1_file.write('dataset,phylo_prec,phylo_rec,phylo_f1,tnet_prec,tnet_rec,tnet_f1\n')

	for outbreak in cdc.known_outbreaks:
		F1 = []
		bootstrap = len(next(os.walk('CDC/' + outbreak + '/tnet_new_bootstrap'))[2])

		real = set(cdc.get_true_transmission_edges(outbreak))
		phylo = set(ge.get_phyloscanner_summary_trans_and_complex_edges('CDC/' + outbreak + '/phyloscanner_output/cdc_hostRelationshipSummary.csv', bootstrap//2))
		tnet = set(ge.get_tnet_summary_edges('CDC/' + outbreak + '/tnet_new_bootstrap_summary_undirected/tnet_new_bootstrap_th_' + str(threshold) + '_summary.csv', bootstrap//2))

		F1.extend(get_prec_rec_f1_undirected(real, phylo))
		F1.extend(get_prec_rec_f1_undirected(real, tnet))
		F1_file.write('{},{},{},{},{},{},{}\n'.format(outbreak,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5]))

	F1_file.close()
コード例 #9
0
ファイル: compare.py プロジェクト: sauravdhr/tnet_development
def compare_phyloscanner_tnet_undirected(bootstrap, threshold):
	data_dir = 'outputs/'
	folders = next(os.walk(data_dir))[1]
	folders.sort()

	F1_file = open('results/favites_undirected_comparison/bootstrap.'+str(bootstrap)+'.phyloscanner.tnet.new.th.'+str(threshold)+'.csv', 'w+')
	F1_file.write('dataset,phylo_prec,phylo_rec,phylo_f1,tnet_prec,tnet_rec,tnet_f1\n')

	for folder in folders:
		print('inside folder: ',folder)
		F1 = []

		real = set(ge.get_real_edges('dataset/' + folder + '/transmission_network.txt'))
		phylo = set(ge.get_phyloscanner_summary_trans_and_complex_edges(data_dir + folder + '/phyloscanner_output_'+str(bootstrap)+'_bootstrap/favites_hostRelationshipSummary.csv', bootstrap//2))
		tnet = set(ge.get_tnet_summary_edges(data_dir + folder + '/tnet_new_bootstrap_summary_directed/tnet_new_'+str(bootstrap)+'_bootstrap_th_'+str(threshold)+'_summary.csv', bootstrap//2))

		F1.extend(get_prec_rec_f1_undirected(real, phylo))
		F1.extend(get_prec_rec_f1_undirected(real, tnet))
		F1_file.write('{},{},{},{},{},{},{}\n'.format(folder,F1[0],F1[1],F1[2],F1[3],F1[4],F1[5]))

	F1_file.close()