bioneuralnet.clustering
Classes
|
CorrelatedLouvain Class for Community Detection with Correlated Omics Data. |
|
PageRank Class for Clustering Nodes Based on Personalized PageRank. |
|
HybridLouvain Class that combines Correlated Louvain and Correlated PageRank for community detection. |
Bases:
objectCorrelatedLouvain Class for Community Detection with Correlated Omics Data. .. attribute:: G
NetworkX graph object.
- type:
nx.Graph
Omics data.
- Type:
pd.DataFrame
Phenotype data.
- Type:
pd.DataFrame
Weight for Correlated Louvain.
- Type:
Weight for Correlated Louvain.
- Type:
Edge weight parameter name.
- Type:
Flag to enable tuning of parameters
- Type:
Convert the partition dictionary into a list of adjacency matrices (DataFrames), where each adjacency matrix represents a cluster with more than 2 nodes.
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.
Bases:
objectPageRank Class for Clustering Nodes Based on Personalized PageRank.
This class handles the execution of the Personalized PageRank algorithm and identification of clusters based on sweep cuts.
Damping factor for PageRank.
- Type:
Maximum number of iterations for PageRank convergence.
- Type:
Tolerance for convergence.
- Type:
Weighting factor for composite correlation-conductance score.
- Type:
Directory to save outputs.
- Type:
Generates a weighted personalization vector for PageRank.
- Parameters:
nodes (List[Any]) – List of node identifiers to consider.
- Returns:
Personalization vector with weights for each node.
- Return type:
Dict[Any, float]
Returns the composite score (or correlation) from the latest clustering run.
Calculates the Pearson correlation between the PCA of omics data and phenotype.
Executes the correlated PageRank clustering pipeline.
Steps:
- Initializing Clustering:
Receives a list of seed nodes to personalize the PageRank algorithm.
Prepares the input graph and relevant parameters for clustering.
- PageRank Execution:
Applies the PageRank algorithm with personalization based on the seed nodes.
Computes node scores and determines cluster memberships.
- Result Compilation:
Compiles clustering results, including cluster sizes and node memberships, into a dictionary.
Logs the successful completion of the clustering process.
- Args:
- seed_nodes (List[Any]):
A list of node identifiers used as seed nodes for personalized PageRank.
These nodes influence the clustering process by biasing the algorithm.
Returns: Dict[str, Any]
- A dictionary containing the clustering results. Keys may include:
clusters: Lists of nodes grouped into clusters.
scores: PageRank scores for each node.
metadata: Additional metrics or details about the clustering process.
Raises:
ValueError: If the input graph is empty or seed nodes are invalid.
Exception: For any unexpected errors during clustering execution.
Notes:
Seed nodes strongly influence the clustering outcome; select them carefully based on prior knowledge or experimental goals.
The PageRank algorithm requires a well-defined and connected graph to produce meaningful results.
Results are sensitive to the alpha (damping factor) and other hyperparameters.
Executes the PageRank clustering algorithm.
- Parameters:
seed_nodes (List[Any]) – List of seed node identifiers for personalization.
- Returns:
Dictionary containing clustering results.
- Return type:
Dict[str, Any]
- class bioneuralnet.clustering.HybridLouvain(G: Graph, B: DataFrame, Y: DataFrame, k3: float = 0.2, k4: float = 0.8, max_iter: int = 10, weight: str = 'weight', gpu: bool = False, seed: int | None = None, tune: bool | None = False)[source]
Bases:
objectHybridLouvain Class that combines Correlated Louvain and Correlated PageRank for community detection.
- G
NetworkX graph object.
- Type:
nx.Graph
- B
Omics data.
- Type:
pd.DataFrame
- Y
Phenotype data.
- Type:
pd.DataFrame
Modules