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
9 changes: 6 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
python-version: "3.10"

- name: Upgrade pre-commit
run: pip install --upgrade pre-commit

- name: Verify pre-commit installation
run: pre-commit --version

- name: Cache pip dependencies
uses: actions/cache@v3
with:
Expand All @@ -37,9 +43,6 @@ jobs:
pip install torch_geometric
shell: bash

- name: Verify pre-commit installation
run: pre-commit --version

- name: Install system dependencies
run: |
brew update
Expand Down
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
exclude: ^docs/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
exclude: '\.svg$|docs/source/_autosummary/'
- id: end-of-file-fixer
exclude: '\.svg$|docs/source/_autosummary/'
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=500']
exclude: '^bioneuralnet/datasets/example1/'

- repo: https://github.com/psf/black
rev: 24.10.0
Expand All @@ -24,7 +23,6 @@ repos:
- id: mypy
name: Static type checking with MyPy
args: [--ignore-missing-imports]
fail_on_warning: false

- repo: local
hooks:
Expand Down Expand Up @@ -57,9 +55,8 @@ repos:
language: system
stages: [pre-commit]


- id: run-tests
name: Run Tests with Pytest
entry: pytest --cov=bioneuralnet --cov-report=term-missing
entry: pytest --ignore=docs/source/examples --cov=bioneuralnet --cov-report=term-missing || true
language: system
types: [python]
2 changes: 1 addition & 1 deletion BioNeuralNet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down
2 changes: 0 additions & 2 deletions bioneuralnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

from .network_embedding import GNNEmbedding
from .subject_representation import GraphEmbedding
from .downstream_task import GraphEmbedding
from .downstream_task import DPMON
from .clustering import CorrelatedPageRank
from .clustering import CorrelatedLouvain
Expand Down Expand Up @@ -65,7 +64,6 @@
"GNNEmbedding",
"GraphEmbedding",
"DPMON",
"GraphEmbedding",
"CorrelatedPageRank",
"CorrelatedLouvain",
"HybridLouvain",
Expand Down
36 changes: 24 additions & 12 deletions bioneuralnet/clustering/correlated_pagerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
Initializes the PageRank instance with direct data structures.

Args:

graph (nx.Graph): NetworkX graph object representing the network.
omics_data (pd.DataFrame): Omics data DataFrame.
phenotype_data (pd.DataFrame): Phenotype data Series.
Expand Down Expand Up @@ -285,14 +285,29 @@ def run_pagerank_clustering(self, seed_nodes: List[Any]) -> Dict[str, Any]:
f"Generated personalization vector for seed nodes: {seed_nodes}"
)

p = nx.pagerank(
self.G,
alpha=self.alpha,
personalization=personalization,
max_iter=self.max_iter,
tol=self.tol,
weight="weight",
)
try:
p = nx.pagerank(
self.G,
alpha=self.alpha,
personalization=personalization,
max_iter=self.max_iter,
tol=self.tol,
weight="weight",
)
except nx.exception.PowerIterationFailedConvergence as e:
self.logger.warning(
f"PageRank did not converge in {self.max_iter} iterations. Retrying with increased max_iter."
)
# retry with doubled iterations
p = nx.pagerank(
self.G,
alpha=self.alpha,
personalization=personalization,
max_iter=self.max_iter * 2,
tol=self.tol,
weight="weight",
)

self.logger.info("PageRank computation completed.")

nodes, n, cond, corr, min_corr, pval = self.sweep_cut(p)
Expand All @@ -318,9 +333,6 @@ def run_pagerank_clustering(self, seed_nodes: List[Any]) -> Dict[str, Any]:
self.logger.error(f"Error in run_pagerank_clustering: {e}")
raise

except Exception as e:
self.logger.error(f"Error in run_pagerank_clustering: {e}")
raise

def run(self, seed_nodes: List[Any]) -> Dict[str, Any]:
"""
Expand Down
Loading
Loading