def test_central_node(self): """ Checks if, given a graph that has been tested for centrality, no nodes are identified as hubs (actually the p-value is too low). """ results = cluster_graph(deepcopy(g), limit, max_clusters, min_clusters, min_cluster_size, iterations, subset, ratio, edgescale, permutations, verbose) graph = results[0] central_edge(graph, percentile, permutations, error, verbose) central_node(graph) self.assertEqual(len(nx.get_node_attributes(graph, 'hub')), 0)
def test_default_manta(self): """ Checks whether the main function carries out both clustering and centrality estimates. """ clustered_graph = cluster_graph(deepcopy(g), limit, max_clusters, min_clusters, min_cluster_size, iterations, subset, ratio, edgescale, permutations, verbose) graph = clustered_graph[0] central_edge(graph, percentile, rel, error, verbose) central_node(graph) clusters = nx.get_node_attributes(graph, 'cluster') hubs = nx.get_edge_attributes(graph, 'hub') self.assertGreater(len(hubs), 0)
def test_center_manta(self): """ Checks if the edge between 1 and 2 is identified as a positive hub. WARNING: at the moment the test indicates that centrality measures are not stable. """ results = cluster_graph(deepcopy(g), limit, max_clusters, min_clusters, min_cluster_size, iterations, subset, ratio, edgescale, permutations, verbose) graph = results[0] central_edge(graph, percentile, permutations, error, verbose) hubs = nx.get_edge_attributes(graph, 'hub') if ('OTU_4', 'OTU_3') in hubs: hubs['OTU_3', 'OTU_4'] = hubs['OTU_4', 'OTU_3'] # 3.5 test sometimes swaps keys around apparently self.assertEqual(hubs[('OTU_3', 'OTU_4')], 'negative hub')