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
0f0814d4
Commit
0f0814d4
authored
Feb 13, 2020
by
Yoann Dufresne
Browse files
simplification with multiple components
parent
448f02f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/main/d2_reduction.py
View file @
0f0814d4
...
...
@@ -13,6 +13,7 @@ def parse_arguments():
parser
.
add_argument
(
'barcode_graph'
,
help
=
'The barcode graph file. Must be a gefx formated file.'
)
parser
.
add_argument
(
'd2_graph'
,
help
=
'd2 graph to reduce. Must be a gefx formated file.'
)
parser
.
add_argument
(
'--output_d2_name'
,
'-o'
,
default
=
"transitively_reduced_d2.gexf"
,
help
=
"Output file prefix."
)
parser
.
add_argument
(
'--component_min_size'
,
'-c'
,
type
=
int
,
default
=
10
,
help
=
"Minimum size of a component to keep it in the d2-graph, after the edge simplifications."
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -37,11 +38,14 @@ def main():
d2a
.
transitive_reduction
(
d2g
)
# Take the principal component
largest_component_nodes
=
max
(
nx
.
connected_components
(
d2g
),
key
=
len
)
largest_component
=
d2g
.
subgraph
(
largest_component_nodes
)
# Write the simplificated graph
nx
.
write_gexf
(
largest_component
,
args
.
output_d2_name
)
components
=
[
c
for
c
in
nx
.
connected_components
(
d2g
)
if
len
(
c
)
>
args
.
component_min_size
]
nodes
=
set
()
for
comp
in
components
:
nodes
.
update
(
comp
)
subgraph
=
d2g
.
subgraph
(
nodes
)
# Write the simplified graph
nx
.
write_gexf
(
subgraph
,
args
.
output_d2_name
)
if
__name__
==
"__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