From e0b280762485374f2f070fa45fb4224fa1c0612d Mon Sep 17 00:00:00 2001 From: Yassin <aliyassin4@hotmail.com> Date: Sun, 2 Jul 2023 19:02:46 +0200 Subject: [PATCH] Adding new methods and the consensual backbone extraction --- netbone/__init__.py | 1 + netbone/compare.py | 2 +- netbone/structural/global_threshold.py | 10 +++------- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/netbone/__init__.py b/netbone/__init__.py index 2bd9d8a..512ff1f 100644 --- a/netbone/__init__.py +++ b/netbone/__init__.py @@ -26,6 +26,7 @@ from netbone.structural.mlam import mlam from netbone.structural.gspar import gspar from netbone.structural.degree import degree from netbone.structural.betweenness import betweenness +from netbone.structural.mad import mad # from netbone.statistical.correlation_and_statistic import correlation_and_statistic from netbone.filters import threshold_filter, fraction_filter diff --git a/netbone/compare.py b/netbone/compare.py index bf04168..bd631f6 100644 --- a/netbone/compare.py +++ b/netbone/compare.py @@ -97,7 +97,7 @@ class Compare: raise Exception('Please enter the filter values.') cons = [] if consent == False: - for backbon in self.backbones: + for backbone in self.backbones: cons.append(False) consent = cons diff --git a/netbone/structural/global_threshold.py b/netbone/structural/global_threshold.py index bf3da7e..2a4d151 100644 --- a/netbone/structural/global_threshold.py +++ b/netbone/structural/global_threshold.py @@ -7,15 +7,11 @@ from netbone.filters import fraction_filter, threshold_filter def global_threshold(data): if isinstance(data, DataFrame): - table = data.copy() + g = nx.from_pandas_edgelist(data, edge_attr=edge_properties(data)) elif isinstance(data, Graph): - table = nx.to_pandas_edgelist(data) + g = data.copy() else: print("data should be a panads dataframe or nx graph") return - table['score'] = table['weight'] - - g = nx.from_pandas_edgelist(table, edge_attr=edge_properties(table)) - - return Backbone(g, method_name="Global Threshold Filter", property_name="score", ascending=False, compatible_filters=[fraction_filter, threshold_filter], filter_on='Edges') \ No newline at end of file + return Backbone(g, method_name="Global Threshold Filter", property_name="weight", ascending=False, compatible_filters=[fraction_filter, threshold_filter], filter_on='Edges') \ No newline at end of file -- GitLab