Skip to content
Snippets Groups Projects
Commit 28e6a699 authored by Le, Mia's avatar Le, Mia
Browse files

edited seed variation plots

parent 0c89a26d
Branches
No related tags found
No related merge requests found
......@@ -143,6 +143,7 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
if nvenn or save_image:
print('Sending results to nVenn')
url = cami.use_nvenn()
if url:
if nvenn:
webbrowser.open(url)
if save_image:
......@@ -164,7 +165,7 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
# SEED VARIATION
if seed_variation:
def make_consensus(vis=False):
def predict_and_make_consensus(vis=False):
result_sets = cami.make_predictions()
cami.create_consensus(result_sets)
if nvenn and vis:
......@@ -182,12 +183,12 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
print(f'Initializing CAMI and the seed variation by running CAMI with all given seeds:{original_seeds}')
with open('/Users/Mia/cami_local/cami/data/output/explorativeness.tsv', 'a') as f:
make_consensus(vis=True)
predict_and_make_consensus(vis=True)
seedname = seeds
for tool in cami.result_gene_sets:
f.write(f'\n{seedname}\t{len(cami.seed_lst)}\t{tool}\t{len(cami.result_gene_sets[tool])}')
#make_consensus(vis=True)
#predict_and_make_consensus(vis=True)
random.seed(50)
removal_frac = 0.2
......@@ -235,9 +236,9 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
# repeat consensus
if ident%5==0:
make_consensus(vis=True)
predict_and_make_consensus(vis=True)
else:
make_consensus()
predict_and_make_consensus()
used_seeds = [cami.ppi_vertex2gene[seed] for seed in cami.seed_lst]
......@@ -278,20 +279,23 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
rediscovery_rates_results = [results[0] for results in variation_results]
# print(rediscovery_rates_results)
tools = [tool for tool in rediscovery_rates_results[0].keys()]
for idx,tool in enumerate(tools):
if '_' in tool:
tmp_lst = tool.split('_')
linebreak_pos = len(tmp_lst)//2
added_linebreak_lst = tmp_lst[:linebreak_pos] + ['\n'] + tmp_lst[linebreak_pos]
tools[idx] = ''.join(added_linebreak_lst)
tool_labels = tools.copy()
redisc_rates = [[res[tool] for res in rediscovery_rates_results] for tool in tools]
for idx,tool in enumerate(tool_labels):
if '_' in tool:
# find the index of the second occurrence of the character
second_occurrence_index = tool.find('_', tool.find('_') + 1)
if second_occurrence_index > -1:
# replace the character at that index with the replacement character
tool_name = tool[:second_occurrence_index] + '\n' + tool[second_occurrence_index + 1:]
tool_labels[idx] = tool_name
#PLOT
# Create a figure instance
plt.figure(figsize=(50,8))
plt.figure(figsize=(48,12))
# Extract Figure and Axes instance
ax1 = plt.subplot(1,2,1, label='ax1')
......@@ -303,10 +307,11 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
for violin in violins1['bodies']:
violin.set_facecolor('red')
# Add title
ax1.set_title(f'Rediscovery rate after randomly removing {nof_removals} seeds\n{nof_iterations} times from {identifier} seeds.', wrap=True)
ax1.set_title(f'Rediscovery rate after randomly removing {nof_removals} seeds {nof_iterations} times from {identifier} seeds.', wrap=True, fontsize=14)
ax1.set_xticks(list(range(1,len(tools)+1)))
ax1.set_xticklabels(tools)
ax1.set_xticklabels(tool_labels)
ax1.tick_params(axis='x', labelsize=11)
ax1.set_ylabel('Rediscovery rate (<rediscovered seeds>/<removed seeds>)', wrap=True)
......@@ -332,12 +337,13 @@ def main(ppi_network, seeds, tools, tool_weights, consensus, evaluate,
for violin in violins3['bodies']:
violin.set_facecolor('blue')
ax5.set_title(f'Ratio of number of rediscovered seeds and predicted module size\nafter removing {nof_removals} seeds {nof_iterations} times from {identifier} seeds.', wrap=True)
ax5.set_title(f'Ratio of number of rediscovered seeds and predicted module size after removing {nof_removals} seeds {nof_iterations} times from {identifier} seeds.', wrap=True, fontsize=14)
ax5.set_xticks(list(range(1,len(tools)+1)))
ax5.set_xticklabels(tools)
ax5.set_xticklabels(tool_labels)
ax5.set_ylabel('(<rediscovered seeds>/<module size>)')
ax5.tick_params(axis='x', labelsize=11)
plt.tight_layout
plt.savefig(f'{output_dir}/00_{identifier}_seed_variation_result.png')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment