bioneuralnet.metrics.plot

Functions

cluster_correlation(cluster_df, pheno)

Compute the Pearson correlation coefficient between PC1 of a cluster and phenotype.

compare_clusters(louvain_clusters, ...[, ...])

Compare clusters from two methods by computing the correlation for each induced subnetwork.

get_logger(name)

Retrieves a global logger configured to write to 'bioneuralnet.log' at the project root.

plot_embeddings(embeddings[, node_labels])

Plot the embeddings in 2D space using t-SNE.

plot_network(adjacency_matrix[, ...])

Plots a network graph from an adjacency matrix with improved visualization.

plot_performance(embedding_result, raw_rf_acc)

Clean and minimal bar plot comparing raw vs embeddings-based performance.

plot_performance_three(raw_score, gnn_score, ...)

Bar plot comparing performance for raw omics, GNN-enriched omics, and one other method.

plot_variance_by_feature(df)

Plot the variance for each feature against its index or name.

plot_variance_distribution(df[, bins])

Compute the variance for each feature (column) in the DataFrame and plot a histogram of these variances.

bioneuralnet.metrics.plot.compare_clusters(louvain_clusters: list, smccnet_clusters: list, pheno: DataFrame, omics_merged: DataFrame, label1: str = 'Louvain', label2: str = 'SmCCNet')[source]

Compare clusters from two methods by computing the correlation for each induced subnetwork. Both inputs are expected to be lists of pandas DataFrames. If the lists have different lengths, only the first min(n, m) clusters are compared.

Parameters:
  • louvain_clusters – list of pd.DataFrame Each DataFrame represents an induced subnetwork (from Louvain).

  • smccnet_clusters – list of pd.DataFrame Each DataFrame represents an induced subnetwork (from SMCCNET).

  • pheno – pd.DataFrame Phenotype data (the first column is used).

  • omics_merged – pd.DataFrame Full omics data

  • label1 – str Label for the first method.

  • label2 – str Label for the second method.

Returns:

Results table with cluster indices, sizes, and correlations

Return type:

pd.DataFrame

bioneuralnet.metrics.plot.plot_embeddings(embeddings, node_labels=None)[source]

Plot the embeddings in 2D space using t-SNE.

Parameters:
  • embeddings (array-like) – High-dimensional embedding data.

  • node_labels (array-like or DataFrame, optional) – Labels for the nodes to color the points.

bioneuralnet.metrics.plot.plot_network(adjacency_matrix, weight_threshold=0.0, show_labels=False, show_edge_weights=False)[source]

Plots a network graph from an adjacency matrix with improved visualization. Also adds a summary table mapping node indexes to actual gene names.

Parameters:
  • adjacency_matrix (pd.DataFrame) – The adjacency matrix of the network.

  • weight_threshold (float) – Minimum weight to keep an edge (default: 0.0).

  • show_labels (bool) – Whether to show node labels.

  • show_edge_weights (bool) – Whether to show edge weights.

Returns:

Mapping of node indexes to actual gene names.

Return type:

pd.DataFrame

bioneuralnet.metrics.plot.plot_performance(embedding_result, raw_rf_acc, title='Performance Comparison', filename=None)[source]

Clean and minimal bar plot comparing raw vs embeddings-based performance.

bioneuralnet.metrics.plot.plot_performance_three(raw_score, gnn_score, other_score, labels=['Raw', 'GNN', 'Other'], title='Performance Comparison', filename=None)[source]

Bar plot comparing performance for raw omics, GNN-enriched omics, and one other method.

bioneuralnet.metrics.plot.plot_variance_by_feature(df: DataFrame)[source]

Plot the variance for each feature against its index or name.

Parameters:

df (pd.DataFrame) – Input data.

Returns:

Generated figure.

Return type:

matplotlib.figure.Figure

bioneuralnet.metrics.plot.plot_variance_distribution(df: DataFrame, bins: int = 50)[source]

Compute the variance for each feature (column) in the DataFrame and plot a histogram of these variances.

Parameters:
  • df (pd.DataFrame) – Input data.

  • bins (int) – Number of bins for the histogram.

Returns:

Generated figure.

Return type:

matplotlib.figure.Figure