Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
STR
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Anne-Sophie Denommé-Pichon
STR
Commits
1e5b9d7d
Commit
1e5b9d7d
authored
Feb 03, 2020
by
Anne-Sophie Denommé-Pichon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle all tools from the input tsv files when plotting
parent
d17f9a99
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
19 deletions
+34
-19
triplets_plotly.py
plot/triplets_plotly.py
+34
-19
No files found.
plot/triplets_plotly.py
View file @
1e5b9d7d
...
@@ -21,42 +21,57 @@ import sys
...
@@ -21,42 +21,57 @@ import sys
path
=
'/work/gad/shared/analyse/STR/results2020-01-09'
path
=
'/work/gad/shared/analyse/STR/results2020-01-09'
def
display_console_graph
(
title
,
data
):
def
display_console_graph
(
title
,
tools
,
data
):
print
(
title
)
print
(
title
)
for
x
,
y
in
data
:
for
tool
,
tool_data
in
zip
(
tools
,
data
):
print
(
tool
)
for
x
,
y
in
tool_data
:
print
(
f
'{x}
\t
{"*" * y}'
)
print
(
f
'{x}
\t
{"*" * y}'
)
def
display_html_graph
(
title
,
data
):
def
display_html_graph
(
title
,
tools
,
data
):
import
plotly.graph_objects
as
go
import
plotly.graph_objects
as
go
import
plotly.subplots
as
sp
fig
=
go
.
Figure
(
figure
=
sp
.
make_subplots
(
data
=
[
go
.
Bar
(
rows
=
len
(
tools
),
x
=
[
x
for
(
x
,
y
)
in
data
],
cols
=
1
,
y
=
[
y
for
(
x
,
y
)
in
data
]
subplot_titles
=
tools
)],
layout_title_text
=
title
)
)
print
(
fig
.
to_html
())
for
tool_id
in
range
(
len
(
tools
)):
figure
.
add_trace
(
go
.
Bar
(
x
=
[
x
for
(
x
,
y
)
in
data
[
tool_id
]],
y
=
[
y
for
(
x
,
y
)
in
data
[
tool_id
]]
),
row
=
tool_id
+
1
,
col
=
1
)
figure
.
update_layout
(
title_text
=
title
,
showlegend
=
False
)
print
(
figure
.
to_html
())
def
graph_locus
(
locus
):
def
graph_locus
(
locus
):
title
=
f
'Effectif pour chaque nombre de répétitions au locus {locus}'
title
=
f
'Effectif pour chaque nombre de répétitions au locus {locus}'
data
=
[]
with
open
(
f
'{path}{os.sep}{locus}.tsv'
)
as
result_file
:
with
open
(
f
'{path}{os.sep}{locus}.tsv'
)
as
result_file
:
tsvreader
=
csv
.
reader
(
result_file
,
delimiter
=
'
\t
'
)
tsvreader
=
csv
.
reader
(
result_file
,
delimiter
=
'
\t
'
)
try
:
try
:
next
(
tsvreader
)
tools
=
next
(
tsvreader
)[
1
:]
counter
=
collections
.
Counter
()
counters
=
[
collections
.
Counter
({
0
:
0
})
for
tool
in
tools
]
counter
[
0
]
=
0
for
row
in
tsvreader
:
for
row
in
tsvreader
:
if
row
[
1
]
not
in
[
'.'
,
'nofile'
]:
for
tool_id
in
range
(
len
(
tools
)):
for
count
in
row
[
1
]
.
split
(
','
):
if
row
[
tool_id
+
1
]
not
in
[
'.'
,
'nofile'
]:
counter
[
int
(
count
)]
+=
1
for
count
in
row
[
tool_id
+
1
]
.
split
(
','
):
counters
[
tool_id
][
int
(
count
)]
+=
1
except
StopIteration
:
except
StopIteration
:
print
(
'Input file is empty'
,
file
=
sys
.
stderr
)
print
(
'Input file is empty'
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
data
=
sorted
(
counter
.
items
())
for
tool_id
in
range
(
len
(
tools
)):
#display_console_graph(title, data)
data
.
append
(
sorted
(
counters
[
tool_id
]
.
items
()))
display_html_graph
(
title
,
data
)
#display_console_graph(title, tools, data)
display_html_graph
(
title
,
tools
,
data
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
!=
2
:
if
len
(
sys
.
argv
)
!=
2
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment