Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yoann DUFRESNE
linked reads molecule ordering
Commits
4782df1e
Commit
4782df1e
authored
May 15, 2020
by
Rayan Chikhi
Browse files
sensitivity random path fix
parent
c653160c
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/main/d2_random_path_evaluation.py
View file @
4782df1e
...
...
@@ -139,18 +139,38 @@ def evaluate_accuracy_paths(path_len,max_paths_per_node=5):
# ---- sensitivity evaluation
""" given an ordered list of molecules, determine if the graph contains a path of central nodse which have these molecules.
it does that by testing all possible combinations of d-graphs having those molecules in their central nodes """
it does that creating a multipartite graph with a source and a sink
"""
def
is_there_path
(
graph
,
molecules_to_nodes
,
sought_path
):
possible_central_nodes
=
[]
for
mol
in
sought_path
:
MPG
=
nx
.
Graph
()
# a multipartite graph
# construct all levels of the multipartite graph
possible_central_nodes
=
[]
for
i
,
mol
in
enumerate
(
sought_path
):
possible_central_nodes
+=
[
molecules_to_nodes
[
mol
]]
#print(possible_central_nodes)
for
mols
in
itertools
.
product
(
*
possible_central_nodes
):
if
nx
.
is_connected
(
graph
.
subgraph
(
mols
)):
#print("found connected path",mols)
return
True
#print("found no connected paths",sought_path)
return
False
for
node
in
possible_central_nodes
:
MPG
.
add_node
(
"%d-%s"
%
(
i
,
node
))
# construct edges between levels
for
i
in
range
(
len
(
sought_path
)
-
1
):
pcn_i
=
molecules_to_nodes
[
sought_path
[
i
]]
pcn_ip1
=
molecules_to_nodes
[
sought_path
[
i
+
1
]]
for
node_i
,
node_j
in
itertools
.
product
(
pcn_i
,
pcn_ip1
):
#print(node_i,node_j)
if
graph
.
has_edge
(
node_i
,
node_j
):
MPG
.
add_edge
(
"%d-%s"
%
(
i
,
node_i
),
"%d-%s"
%
(
i
+
1
,
node_j
))
# add source/sink
MPG
.
add_node
(
"source"
)
MPG
.
add_node
(
"sink"
)
pcn_0
=
molecules_to_nodes
[
sought_path
[
0
]]
for
node
in
pcn_0
:
MPG
.
add_edge
(
"source"
,
"0-%s"
%
node
)
pcn_end
=
molecules_to_nodes
[
sought_path
[
-
1
]]
for
node
in
pcn_end
:
MPG
.
add_edge
(
"%d-%s"
%
(
len
(
sought_path
)
-
1
,
node
),
"sink"
)
return
nx
.
has_path
(
MPG
,
"source"
,
"sink"
)
def
evaluate_sensitivity_paths
(
path_len
,
overlap_length
=
7000
):
all_molecules
=
set
()
...
...
@@ -183,9 +203,14 @@ def main():
p
=
Pool
(
12
)
#p.map(evaluate_accuracy_paths, [1,2,4,6,8,10,15,20,50,100,200,500])
p
.
map
(
evaluate_accuracy_paths
,
[
2
,
4
,
10
,
100
])
p
.
join
()
#p.map(evaluate_sensitivity_paths, [1,2,3,4])
p
.
map
(
evaluate_sensitivity_paths
,
[
2
,
4
,
10
,
100
])
#evaluate_accuracy_paths(100)
#evaluate_sensitivity_paths(1)
#evaluate_sensitivity_paths(3)
#evaluate_sensitivity_paths(10)
p
.
close
()
p
.
join
()
if
__name__
==
"__main__"
:
main
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment