User API — BioNeuralNet 1.0.4 documentation

# User API

The User API lists BioNeuralNet’s key classes, methods, and utilities.

`bioneuralnet.network_embedding` |
`bioneuralnet.clustering` |
`bioneuralnet.downstream_task` |
`bioneuralnet.utils` |
`bioneuralnet.datasets` |
`bioneuralnet.metrics` |
`bioneuralnet.external_tools` |

## Executables

Certain classes expose a high-level `run()` method to perform end-to-end workflows:

- SubjectRepresentation for integrating embeddings into subject-level data

- CorrelatedLouvain or HybridLouvain for clustering

- DPMON for disease prediction

Usage Pattern:

1. Instantiate the class with the relevant data (omics, adjacency, phenotype, etc.).

2. Call the run() method to perform the pipeline.

Example:

    from bioneuralnet.downstream_task import DPMON

    dpmon_obj = DPMON(
        adjacency_matrix=adjacency_matrix,
        omics_list=omics_list,
        phenotype_data=phenotype_data,
        clinical_data=clinical_data,
        model='GAT'
    )
    predictions = dpmon_obj.run()

Methods:

Below are references to the `run()` methods:

SmCCNet.run()

SubjectRepresentation.run() → DataFrame

  Executes the Subject Representation workflow. If tuning is enabled, runs hyperparameter tuning and uses the best config to reduce embeddings. Otherwise, uses the default reduction method. :returns:

  > - Enhanced omics data as a DataFrame.

DPMON.run() → DataFrame

  Execute the DPMON pipeline for disease prediction.

  Steps:

  1. Combining Omics and Phenotype Data: - Merges the provided omics datasets and ensures that the phenotype (phenotype) column is included.

  2. Tuning or Training: - Tuning: If tune=True, performs hyperparameter tuning using Ray Tune and returns an empty DataFrame. - Training: If tune=False, runs standard training to generate predictions.

  3. Predictions: - If training is performed, returns a DataFrame of predictions with ‘Actual’ and ‘Predicted’ columns.

  Returns: pd.DataFrame

  > - If tune=False, a DataFrame containing disease phenotype predictions for each sample.

  > - If tune=True, returns an empty DataFrame since no predictions are generated.

  Raises:

  > - ValueError: If the input data is improperly formatted or missing.

  > - Exception: For any unforeseen errors encountered during preprocessing, tuning, or training.

  Notes:

  > - DPMON relies on internally-generated embeddings (via GNNs), node correlations, and a downstream neural network.

  > - Ensure that the adjacency matrix and omics data are properly aligned and that clinical/phenotype data match the sample indices.

  Example:

      dpmon = DPMON(adjacency_matrix, omics_list, phenotype_data, clinical_data, model='GCN')
      predictions = dpmon.run()
      print(predictions.head())

CorrelatedLouvain.run(as_dfs: bool = False) → dict | list

  Run correlated Louvain clustering.

  If as_dfs is True, returns a list of adjacency matrices (DataFrames), where each adjacency matrix represents a cluster with more than 2 nodes. Otherwise, returns the partition dictionary.

  If tune is True and as_dfs is False, hyperparameter tuning is performed and the best parameters are returned. If tune is True and as_dfs is True, tuning is performed, and then standard detection is run using the tuned parameters.

HybridLouvain.run(as_dfs: bool = False) → dict | list