Commit 2ca17eb4 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

Merge branch 'master' of gitlab.pasteur.fr:ydufresne/10x-deconvolve

parents 455f6e88 a5259676
......@@ -85,6 +85,12 @@ def is_coherent_path(central_nodes,path_len):
assert(len(mols_in_central_nodes) == path_len+1)
return is_there_path_acc(mols_in_central_nodes)
def get_barcode(x):
if 'udg' in graph.nodes[x]:
return graph.nodes[x]['udg'].split()[0]
else:
return graph.nodes[x]['label']
""" the main function that tests for accuracy of random paths """
graph = None
def evaluate_accuracy_paths(path_len,max_paths_per_node=100):
......@@ -101,7 +107,7 @@ def evaluate_accuracy_paths(path_len,max_paths_per_node=100):
seen_paths.add(tuple(sorted(path)))
assert(len(path) == path_len+1)
#print("path",path)
central_nodes = [graph.nodes[x]['udg'].split()[0] for x in path]
central_nodes = [get_barcode(x) for x in path]
assert(len(central_nodes) == path_len+1)
#print(path,central_nodes)
if is_coherent_path(central_nodes,path_len):
......@@ -131,7 +137,7 @@ def evaluate_sensitivity_paths(path_len,overlap_length=7000):
from collections import defaultdict
molecules_to_nodes = defaultdict(list)
for node in graph.nodes():
central_node = graph.nodes[node]['udg'].split()[0]
central_node = get_barcode(node)
mols = central_node_to_molecules(central_node)
all_molecules |= set(mols)
for mol in mols:
......
......@@ -2,6 +2,7 @@
import sys
sys.setrecursionlimit(10000)
import argparse
from termcolor import colored
import networkx as nx
......@@ -184,7 +185,10 @@ def str_to_udg_lists(s):
def parse_dg_name(gr, name):
udg = nx.get_node_attributes(gr, 'udg')[name]
central, h1, h2 = str_to_udg_lists(udg)
res = str_to_udg_lists(udg)
if len(res) != 3:
print("parsing problem:",res)
central, h1, h2 = res
idx = name
score = nx.get_node_attributes(gr, 'score')[name]
......@@ -315,7 +319,7 @@ def recursive_longest_path(current_node, current_molecule, next_nodes, longest_p
longest = 0
longest_next = None
min_mol_idx = current_molecule + 10000
min_mol_idx = float('inf')
# Recursively compute the longest path
for mol_idx, node in next_nodes[current_node][current_molecule]:
size, _, _ = recursive_longest_path(node, mol_idx, next_nodes, longest_paths)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment