Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dpmon_output
.enviroment
TCGA-BRCA_Dataset_testing*.ipynb
testsOLD
network_construction_run.ipynb
datasets_run.ipynb
# Other example data and tests not needed in the repo.

Output**
Expand Down
10 changes: 8 additions & 2 deletions bioneuralnet/metrics/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def plot_embeddings(embeddings, node_labels=None):
plt.show()


def plot_network(adjacency_matrix, weight_threshold=0.0, show_labels=False, show_edge_weights=False):
def plot_network(adjacency_matrix, weight_threshold=0.0, show_labels=False, show_edge_weights=False, layout="kamada"):
"""
Plots a network graph from an adjacency matrix with improved visualization.
Also adds a summary table mapping node indexes to actual gene names.
Expand Down Expand Up @@ -295,7 +295,13 @@ def plot_network(adjacency_matrix, weight_threshold=0.0, show_labels=False, show
else:
edge_widths = []

pos = nx.kamada_kawai_layout(G, weight="abs_weight")
if layout == "spectral":
pos = nx.spectral_layout(G)
elif layout == "spring":
pos = nx.spring_layout(G, weight="abs_weight", seed=117, iterations=50)
else:
pos = nx.kamada_kawai_layout(G, weight="abs_weight")

fig, ax_graph = plt.subplots(figsize=(14, 8))

nx.draw_networkx_nodes(G, pos, node_size=node_sizes, node_color="gold", edgecolors="black", linewidths=1.5, alpha=0.9, ax=ax_graph)
Expand Down
200 changes: 124 additions & 76 deletions bioneuralnet/utils/graph.py

Large diffs are not rendered by default.

Loading
Loading