Commit a2baf0b0 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

bad greedy path

parent b1a94992
...@@ -2,10 +2,10 @@ include: "Snakefile_data_simu" ...@@ -2,10 +2,10 @@ include: "Snakefile_data_simu"
include: "Snakefile_d2" include: "Snakefile_d2"
WORKDIR = "snake_experiments" if "workdir" not in config else config["workdir"] WORKDIR = "snake_experiments" if "workdir" not in config else config["workdir"]
N = [5000, 10000] N = [1000]
D = [10] D = [10]
M = [2,3] M = [2]
DEV = [0, 1] DEV = [0]
rule generate_compare: rule generate_compare:
input: input:
......
...@@ -69,6 +69,8 @@ class Path(list): ...@@ -69,6 +69,8 @@ class Path(list):
d2p.nodes[udg.idx]["center"] = udg.center d2p.nodes[udg.idx]["center"] = udg.center
d2p.nodes[udg.idx]["udg"] = str(udg) d2p.nodes[udg.idx]["udg"] = str(udg)
d2p.nodes[udg.idx]["score"] = f"{udg.score}/{udg.get_optimal_score()}" d2p.nodes[udg.idx]["score"] = f"{udg.score}/{udg.get_optimal_score()}"
barcode_edges = " ".join([str(self.d2g.barcode_edge_idxs[x]) for x in udg.edges])
d2p.nodes[udg.idx]["barcode_edges"] = barcode_edges
# add the edges # add the edges
for idx in range(len(self)-1): for idx in range(len(self)-1):
......
...@@ -14,6 +14,10 @@ def parse_arguments(): ...@@ -14,6 +14,10 @@ def parse_arguments():
parser.add_argument('--out_prefix', '-o', default="", help="Output file prefix.") parser.add_argument('--out_prefix', '-o', default="", help="Output file prefix.")
args = parser.parse_args() args = parser.parse_args()
if args.out_prefix == "":
args.out_prefix = '.'.join(args.d2_graph.split('.')[:-1])
return args return args
...@@ -45,7 +49,7 @@ def main(): ...@@ -45,7 +49,7 @@ def main():
optimizer.extends_until_end(solution) optimizer.extends_until_end(solution)
print(f"covering score: {solution.covering_score()}") print(f"covering score: {solution.covering_score()}")
solution.save_path_in_graph(f"{args.out_prefix}_d2_path.gexf") # solution.save_path_in_graph(f"{args.out_prefix}_d2_path.gexf")
solution.save_path(f"{args.out_prefix}_path.gexf") solution.save_path(f"{args.out_prefix}_path.gexf")
solution.save_barcode_path(f"{args.out_prefix}_barcode_count.gexf") solution.save_barcode_path(f"{args.out_prefix}_barcode_count.gexf")
print("Solution saved") print("Solution saved")
......
import argparse
import networkx as nx
from itertools import combinations
from multiprocessing import Pool
def parse_arguments():
parser = argparse.ArgumentParser(description='Transform a 10X barcode graph into a d2 graph. The program dig for the d-graphs and then merge them into a d2-graph.')
parser.add_argument('barcode_graph', help='The barcode graph file. Must be a gefx formated file.')
parser.add_argument('--threads', '-t', default=8, type=int, help='Number of thread to use for dgraph computation')
args = parser.parse_args()
return args
def main():
args = parse_arguments()
print(args.barcode_graph)
graph = nx.read_gexf(args.barcode_graph)
for node in graph.nodes():
neighbors = list(graph.neighbors(node))
subgraph = nx.Graph(graph.subgraph(neighbors))
index_cliques(subgraph, node)
def index_cliques(graph, node):
clique_index = {}
nb_cliques = 0
nb_unfiltered_cliques = 0
for clique in nx.find_cliques(graph):
nb_cliques += 1
if len(clique) > 3:
# print(clique)
nb_unfiltered_cliques += 1
print(nb_unfiltered_cliques, '/', nb_cliques)
if __name__ == "__main__":
main()
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