Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MC_MSA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lihouck Flavien
MC_MSA
Commits
e4c26ffe
Commit
e4c26ffe
authored
3 years ago
by
Lihouck Flavien
Browse files
Options
Downloads
Patches
Plain Diff
Courbes pour les seuils des premiers consensus et second consensus
parent
8591b276
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plot_results.py
+59
-23
59 additions, 23 deletions
src/plot_results.py
src/workflow/Snakefile
+18
-5
18 additions, 5 deletions
src/workflow/Snakefile
with
77 additions
and
28 deletions
src/plot_results.py
100644 → 100755
+
59
−
23
View file @
e4c26ffe
#!/usr/bin/env python3
import
matplotlib
as
mpl
import
matplotlib.pyplot
as
plt
import
numpy
as
np
...
...
@@ -5,14 +8,20 @@ import re
import
sys
import
os
th
=
[
30
,
40
,
50
,
60
,
70
,
80
]
def
parse_file
(
filename
,
x_scale
):
identity
,
similarity
,
equivalence
,
mismatches
=
[
[],
[]
,
[],
[]]
value
=
[]
with
open
(
filename
,
'
r
'
)
as
f
:
cnt
=
0
for
line
in
f
:
try
:
i
,
s
,
e
,
m
=
map
(
float
,
line
.
split
(
'
,
'
)[
1
:])
except
:
i
,
s
,
e
,
m
=
[
0
,
0
,
0
,
0
]
print
(
"
Missing values replaced by 0, 0, 0, 0
"
)
identity
.
append
(
i
)
similarity
.
append
(
s
)
equivalence
.
append
(
e
)
...
...
@@ -21,26 +30,53 @@ def parse_file(filename, x_scale):
return
identity
,
similarity
,
equivalence
,
mismatches
th
=
[
30
,
40
,
50
,
60
,
70
,
80
]
def
plot_from_folder
(
args
,
target
,
labels
,
folder
):
ls
,
li
,
le
,
lm
=
[],
[],
[],
[]
for
tool_file
in
os
.
scandir
(
sys
.
argv
[
1
]):
if
"
.txt
"
in
tool_file
.
name
:
i
,
s
,
e
,
m
=
map
(
np
.
array
,
parse_file
(
tool_file
,
th
))
for
tool_file
in
args
:
if
folder
!=
""
:
cond
=
"
.txt
"
in
tool_file
.
name
filename
=
folder
+
tool_file
.
name
else
:
cond
=
"
.txt
"
in
tool_file
filename
=
tool_file
if
cond
:
i
,
s
,
e
,
m
=
map
(
np
.
array
,
parse_file
(
filename
,
th
))
li
.
append
(
i
)
ls
.
append
(
s
)
le
.
append
(
e
)
lm
.
append
(
m
)
fig
=
plt
.
figure
(
figsize
=
(
20
,
10
))
ll
=
[
ls
,
li
,
le
,
lm
]
cnt
=
0
graph_
cnt
=
0
target_att
=
[
"
identity
"
,
"
similarity
"
,
"
equivalence
"
,
"
mismatches
"
]
for
graph
in
ll
:
plt
.
clf
()
tab_cnt
=
0
for
tab
in
graph
:
if
(
len
(
tab
)
>
1
):
plt
.
plot
(
th
,
tab
,
'
bo
'
,
label
=
cnt
)
plt
.
plot
(
th
,
tab
,
'
o
'
,
label
=
labels
[
tab_cnt
])
# plt.plot(th,tab, label=labels[tab_cnt])
else
:
plt
.
plot
(
th
,[
tab
for
x
in
range
(
len
(
th
))])
plt
.
savefig
(
sys
.
argv
[
2
]
+
"
_
"
+
target_att
[
cnt
]
+
"
.png
"
)
cnt
+=
1
plt
.
plot
(
th
,[
tab
for
x
in
range
(
len
(
th
))],
label
=
labels
[
graph_cnt
])
tab_cnt
+=
1
legend
=
plt
.
legend
(
shadow
=
True
,
fontsize
=
'
x-large
'
)
plt
.
savefig
(
target
+
"
_
"
+
target_att
[
graph_cnt
]
+
"
.png
"
,
format
=
"
png
"
,)
graph_cnt
+=
1
if
__name__
==
"
__main__
"
:
if
(
len
(
sys
.
argv
)
<
3
):
exit
(
-
1
)
if
(
len
(
sys
.
argv
)
==
3
):
print
(
sys
.
argv
)
folder_it
=
os
.
scandir
(
sys
.
argv
[
2
])
name
=
[
x
.
name
for
x
in
folder_it
]
#folder_it= os.scandir(sys.argv[2])
plot_from_folder
(
folder_it
,
sys
.
argv
[
1
],
name
,
folder
=
sys
.
argv
[
2
])
exit
(
0
)
lb
=
[]
for
elem
in
th
:
lb
.
append
(
"
th
"
+
str
(
elem
))
plot_from_folder
(
sys
.
argv
[
2
:]
,
sys
.
argv
[
1
],
sys
.
argv
[
2
:],
folder
=
""
)
This diff is collapsed.
Click to expand it.
src/workflow/Snakefile
+
18
−
5
View file @
e4c26ffe
...
...
@@ -5,6 +5,7 @@ THRESHOLD = ["30", "40", "50", "60", "70", "80"]
REGION = ["100", "200", "500", "1000", "2000"]
DEPTH = ["10", "20", "50", "100", "150"]
ALIGN = ["muscle", "mafft"]
GRAPH_TYPES = ["identity", "similarity", "equivalence", "mismatches"]
STAT_HEADER= "threshold, percent_identity, percent_similarity, total_equivalence, total_mismatches\n "
...
...
@@ -77,8 +78,6 @@ rule exonerate_ref_result:
# "echo {STAT_HEADER} >> {output} \n for FILE in {input.files}; do exonerate --bestn 1 -Q dna -E -m a:g --showalignment false --showsugar false --showvulgar false --showcigar false --ryo {resources.format} --verbose 0 -q {input.ref} -t $FILE >> {output} 2>/dev/null; done" #
rule plottable_exonerate_meta_t2:
input: files=expand(rules.final_consensus.output, align="muscle", value=THRESHOLD, allow_missing=True) , ref=expand("{data}/seq_selectes_region/region_seq_r{region}.fasta", data=DATA, allow_missing=True)
output: "consensus/plot/{region}/{depth}/{threshold}/aln_stats_meta.txt"
...
...
@@ -93,8 +92,22 @@ rule plottable_exonerate_tools_t2:
conda: "envs/exonerate.yaml"
shell: "./exonerate_stats.sh {output} {input.ref} {input.consensus_per_tool}"
rule plot_t2:
input: expand(rules.plottable_exonerate_tools_t2.output, region=REGION, depth=DEPTH, threshold=THRESHOLD, tool=TOOL),
expand(rules.plottable_exonerate_meta_t2.output, region=REGION, depth=DEPTH, threshold=THRESHOLD, tool=TOOL)
rule plot_t1:
input:
expand(rules.plottable_exonerate_meta_t2.output, threshold=THRESHOLD, allow_missing=True),
params: target_folder="consensus/plot/{region}/{depth}"
output: expand("consensus/plot/{region}/{depth}/graph_r{region}_d{depth}_{graph}.png", graph=GRAPH_TYPES, allow_missing=True)
shell: "./plot_results.py {params.target_folder}/graph_r{wildcards.region}_d{wildcards.depth} {input}"
rule plot_t2:
input: expand(rules.plottable_exonerate_tools_t2.output, tool=TOOL, allow_missing=True),
rules.plottable_exonerate_meta_t2.output
params: target_folder="consensus/plot/{region}/{depth}/{threshold}/"
output: expand("consensus/plot/{region}/{depth}/{threshold}/graph_r{region}_d{depth}_t1_{threshold}_{graph}.png", graph=GRAPH_TYPES, allow_missing=True)
shell: "./plot_results.py {params.target_folder}graph_r{wildcards.region}_d{wildcards.depth}_t1_{wildcards.threshold} {input}"
rule make_plots:
input: expand(rules.plot_t2.output, region=REGION, depth=DEPTH, threshold=THRESHOLD),
expand(rules.plot_t1.output, region=REGION, depth=DEPTH)
\ No newline at end of file
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