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
a652cd40
Commit
a652cd40
authored
Aug 21, 2019
by
Yoann Dufresne
Browse files
Merge branch 'master' of gitlab.pasteur.fr:ydufresne/10x-deconvolve
parents
1bc64e01
391412f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/evaluate.py
View file @
a652cd40
...
...
@@ -167,17 +167,13 @@ def print_path_summary(frequencies, neighborhood, light_print=False, file_pointe
# ------------- D2 Graph -------------
def
parse_dg_name
(
name
):
name
=
name
.
replace
(
"]"
,
""
).
replace
(
' ['
,
'['
)
header
,
h1
,
h2
=
name
.
split
(
'['
)
def
parse_dg_name
(
gr
,
name
):
udg
=
nx
.
get_node_attributes
(
gr
,
'udg'
)[
name
]
udg
=
udg
.
replace
(
"]"
,
""
).
replace
(
' ['
,
'['
)
central
,
h1
,
h2
=
udg
.
split
(
'['
)
# Parse header
header
=
header
.
split
(
" "
)
idx
=
central
=
score
=
-
1
if
len
(
header
)
==
3
:
idx
,
central
,
score
=
header
else
:
central
,
score
=
header
idx
=
name
score
=
nx
.
get_node_attributes
(
gr
,
'score'
)[
name
]
# Parse hands
h1
=
h1
.
split
(
', '
)
...
...
@@ -267,7 +263,7 @@ def compute_next_nodes(d2_component):
for
node
in
d2_component
.
nodes
():
# Parse the current node name
head
,
h1
,
h2
=
parse_dg_name
(
node
)
head
,
h1
,
h2
=
parse_dg_name
(
d2_component
,
node
)
next_nodes
[
node
]
=
{}
neighbors
=
list
(
d2_component
.
neighbors
(
node
))
...
...
@@ -276,7 +272,7 @@ def compute_next_nodes(d2_component):
for
mol_idx
in
molecule_idxs
:
nexts
=
[]
for
neighbor
in
neighbors
:
nei_head
,
_
,
_
=
parse_dg_name
(
neighbor
)
nei_head
,
_
,
_
=
parse_dg_name
(
d2_component
,
neighbor
)
nei_mols
=
mols_from_node
(
nei_head
[
1
])
nei_mols
=
[
x
for
x
in
nei_mols
if
x
>
mol_idx
]
...
...
@@ -401,7 +397,7 @@ def verify_graph_edges(d2_component):
udg_molecules_dict
=
dict
()
for
node
in
d2_component
.
nodes
():
# Parse the current node name
head
,
c1
,
c2
=
parse_dg_name
(
node
)
head
,
c1
,
c2
=
parse_dg_name
(
d2_component
,
node
)
# Construct the molecule(s) that this udg really 'reflects'
# i.e. the udg has a central node and two cliques
...
...
@@ -440,10 +436,10 @@ def verify_graph_edges(d2_component):
# Then: annotate edges as to whether they're real (their udg_molecule(s) are nearby) or fake
for
n1
,
n2
,
data
in
d2_component
.
edges
(
data
=
True
):
# Parse the current node name
head
,
c1
,
c2
=
parse_dg_name
(
n1
)
head
,
c1
,
c2
=
parse_dg_name
(
d2_component
,
n1
)
node_udg_molecules
=
udg_molecules_dict
[
head
[
0
]]
n_head
,
n_c1
,
n_c2
=
parse_dg_name
(
n2
)
n_head
,
n_c1
,
n_c2
=
parse_dg_name
(
d2_component
,
n2
)
neighbor_udg_molecules
=
udg_molecules_dict
[
n_head
[
0
]]
if
nearby_udg_molecules
(
node_udg_molecules
,
neighbor_udg_molecules
):
...
...
@@ -456,7 +452,7 @@ def verify_graph_edges(d2_component):
# also, annotate nodes by their putative molecule found
for
n
,
data
in
d2_component
.
nodes
(
data
=
True
):
# Parse the current node name
head
,
c1
,
c2
=
parse_dg_name
(
n
)
head
,
c1
,
c2
=
parse_dg_name
(
d2_component
,
n
)
node_udg_molecules
=
udg_molecules_dict
[
head
[
0
]]
data
[
'udg_molecule'
]
=
'_'
.
join
(
list
(
map
(
str
,
node_udg_molecules
)))
...
...
@@ -468,7 +464,7 @@ def verify_graph_edges(d2_component):
nodes_to_remove
=
[]
for
n
,
data
in
d2_component
.
nodes
(
data
=
True
):
# Parse the current node name
head
,
c1
,
c2
=
parse_dg_name
(
n
)
head
,
c1
,
c2
=
parse_dg_name
(
d2_component
,
n
)
if
"_"
in
data
[
'udg_molecule'
]
or
data
[
'udg_molecule'
]
==
''
:
if
"_"
in
data
[
'udg_molecule'
]:
m1
,
m2
=
list
(
map
(
int
,
data
[
'udg_molecule'
].
split
(
"_"
)))
...
...
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