Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cami
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chow Castro, Marcos
cami
Commits
7fa45ade
Commit
7fa45ade
authored
2 years ago
by
Le, Mia
Browse files
Options
Downloads
Patches
Plain Diff
temporarily removed digest from seed_var evaluation
parent
2048647d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cami_src/evaluation_scripts/seed_variation_script.py
+29
-29
29 additions, 29 deletions
cami_src/evaluation_scripts/seed_variation_script.py
with
29 additions
and
29 deletions
cami_src/evaluation_scripts/seed_variation_script.py
+
29
−
29
View file @
7fa45ade
...
...
@@ -17,7 +17,7 @@ def predict_and_make_consensus(cami, vis=False):
if
vis
:
cami
.
use_nvenn
(
download
=
True
)
def
make_seedvariation
(
cami
,
n_iterations
,
removal_frac
=
0.2
,
vis
=
False
,
plot
=
Tru
e
):
def
make_seedvariation
(
cami
,
n_iterations
,
removal_frac
=
0.2
,
vis
=
False
,
plot
=
Fals
e
):
identifier
=
cami
.
uid
base_seeds
=
cami
.
origin_seed_lst
original_seeds
=
[
cami
.
ppi_vertex2gene
[
seed
]
for
seed
in
base_seeds
]
...
...
@@ -52,11 +52,11 @@ def make_seedvariation(cami, n_iterations, removal_frac=0.2, vis=False, plot=Tru
for
tool
in
prediction_tools
:
res_table
.
write
(
f
'
\t
{
tool
}
_msr_ks_pvalue
'
)
with
open
(
os
.
path
.
join
(
cami
.
tmp_dir
,
f
'
{
used_tools
[
0
]
}
_
{
cami
.
uid
}
_relevance_scores.tsv
'
),
'
r
'
)
as
f
:
for
line
in
f
:
val_name
=
line
.
split
(
'
\t
'
)[
0
]
redisc_table
.
write
(
f
'
\t
{
val_name
}
'
)
res_table
.
write
(
'
\n
'
)
#
with open(os.path.join(cami.tmp_dir, f'{used_tools[0]}_{cami.uid}_relevance_scores.tsv'), 'r') as f:
#
for line in f:
#
val_name = line.split('\t')[0]
#
redisc_table.write(f'\t{val_name}')
#
res_table.write('\n')
# result dictionaries of the form {tool:list(value for each iteration)}
tp_rate_dict
=
{
k
:
list
()
for
k
in
used_tools
}
...
...
@@ -142,10 +142,10 @@ def make_seedvariation(cami, n_iterations, removal_frac=0.2, vis=False, plot=Tru
list
(
module_size_dict
[
pred_tool
]))
res_table
.
write
(
f
'
\t
{
p_val
}
'
)
with
open
(
os
.
path
.
join
(
cami
.
tmp_dir
,
f
'
{
tool
}
_
{
identifier
}
_relevance_scores.tsv)
'
),
'
r
'
)
as
f
:
for
line
in
f
:
rel_score
=
line
.
split
(
'
\t
'
)[
1
].
strip
()
res_table
.
write
(
f
'
\t
{
rel_score
}
'
)
#
with open(os.path.join(cami.tmp_dir, f'{tool}_{identifier}_relevance_scores.tsv)'), 'r') as f:
#
for line in f:
#
rel_score = line.split('\t')[1].strip()
#
res_table.write(f'\t{rel_score}')
res_table
.
write
(
'
\n
'
)
print
(
f
'
Result tables are saved in the following locations:
'
)
...
...
@@ -171,7 +171,7 @@ def make_seedvariation(cami, n_iterations, removal_frac=0.2, vis=False, plot=Tru
#PLOT
# Create a figure instance
#print(sys.getrecursionlimit())
fig1
,
(
ax1
,
ax5
,
ax4
)
=
plt
.
subplots
(
3
,
1
,
figsize
=
(
20
,
20
))
fig1
,
(
ax1
,
ax5
)
=
plt
.
subplots
(
2
,
1
,
figsize
=
(
20
,
20
))
fig1
.
subplots_adjust
(
left
=
0.2
)
# Extract Figure and Axes instance
...
...
@@ -200,26 +200,26 @@ def make_seedvariation(cami, n_iterations, removal_frac=0.2, vis=False, plot=Tru
ax1
.
set_ylabel
(
'
Rediscovery rate (<rediscovered seeds>/<removed seeds>)
'
,
wrap
=
True
,
fontsize
=
14
)
violins2
=
ax4
.
violinplot
([
tp_rate_dict
[
tool
]
for
tool
in
tools
],
showmeans
=
True
,
showextrema
=
True
)
for
violinpart
in
list
(
violins2
.
keys
())[
2
:]:
violins2
[
violinpart
].
set_color
(
'
k
'
)
for
violin
,
tool
in
zip
(
violins2
[
'
bodies
'
],
tools
):
if
tool
in
[
tw
.
name
for
tw
in
cami
.
tool_wrappers
]:
violin
.
set_facecolor
(
'
tan
'
)
elif
tool
==
'
first_neighbors
'
:
violin
.
set_facecolor
(
'
peachpuff
'
)
elif
tool
in
[
'
union
'
,
'
intersection
'
]:
violin
.
set_facecolor
(
'
orange
'
)
else
:
violin
.
set_facecolor
(
'
darkorange
'
)
# Add title
ax4
.
set_title
(
f
'
True positive rates after randomly removing
{
nof_removals
}
seeds
{
nof_iterations
}
times from
{
identifier
}
seeds.
'
,
wrap
=
True
,
fontsize
=
14
)
ax4
.
set_xticks
(
list
(
range
(
1
,
len
(
tools
)
+
1
)))
ax4
.
set_xticklabels
(
tool_labels
)
ax4
.
tick_params
(
axis
=
'
x
'
,
labelsize
=
11
)
ax4
.
set_ylabel
(
'
Sensitivity (TP/TP + FN)
'
,
wrap
=
True
,
fontsize
=
14
)
#
violins2 = ax4.violinplot([tp_rate_dict[tool] for tool in tools], showmeans=True, showextrema=True)
#
for violinpart in list(violins2.keys())[2:]:
#
violins2[violinpart].set_color('k')
#
for violin, tool in zip(violins2['bodies'], tools):
#
if tool in [tw.name for tw in cami.tool_wrappers]:
#
violin.set_facecolor('tan')
#
elif tool == 'first_neighbors':
#
violin.set_facecolor('peachpuff')
#
elif tool in ['union', 'intersection']:
#
violin.set_facecolor('orange')
#
else:
#
violin.set_facecolor('darkorange')
#
#
Add title
#
ax4.set_title(f'True positive rates after randomly removing {nof_removals} seeds {nof_iterations} times from {identifier} seeds.', wrap=True, fontsize=14)
#
ax4.set_xticks(list(range(1,len(tools)+1)))
#
ax4.set_xticklabels(tool_labels)
#
ax4.tick_params(axis='x', labelsize=11)
#
ax4.set_ylabel('Sensitivity (TP/TP + FN)', wrap=True, fontsize=14)
violins3
=
ax5
.
violinplot
([
module_size_dict
[
tool
]
for
tool
in
tools
],
showmeans
=
True
,
showextrema
=
True
)
# Add title
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment