Select Git revision
test_index_cliques.py
test_index_cliques.py 1.20 KiB
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()