gpath2vec 3.0.0__tar.gz → 3.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/PKG-INFO +1 -1
  2. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/__init__.py +6 -1
  3. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/cli.py +16 -9
  4. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec.egg-info/PKG-INFO +1 -1
  5. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec.egg-info/SOURCES.txt +1 -0
  6. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/setup.py +1 -1
  7. gpath2vec-3.0.1/tests/test_cli_cluster_weights.py +41 -0
  8. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/LICENSE +0 -0
  9. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/README.md +0 -0
  10. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/aucell.py +0 -0
  11. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/compare.py +0 -0
  12. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/ea.py +0 -0
  13. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/embedder.py +0 -0
  14. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/net.py +0 -0
  15. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec/utils.py +0 -0
  16. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec.egg-info/dependency_links.txt +0 -0
  17. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec.egg-info/entry_points.txt +0 -0
  18. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec.egg-info/requires.txt +0 -0
  19. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/gpath2vec.egg-info/top_level.txt +0 -0
  20. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/setup.cfg +0 -0
  21. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/tests/test_aucell_topk.py +0 -0
  22. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/tests/test_ea_aggregation.py +0 -0
  23. {gpath2vec-3.0.0 → gpath2vec-3.0.1}/tests/test_metapath_topology.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gpath2vec
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: gene-set to biological pathway embeddings with enrichment analysis
5
5
  Home-page: https://github.com/teslajoy/gpath2vec
6
6
  Author: Nasim Sanati
@@ -7,4 +7,9 @@ from . import ea
7
7
  from . import utils
8
8
  from . import compare
9
9
 
10
- __version__ = "1.0.0"
10
+ from importlib.metadata import version, PackageNotFoundError
11
+
12
+ try:
13
+ __version__ = version("gpath2vec")
14
+ except PackageNotFoundError:
15
+ __version__ = "unknown"
@@ -22,6 +22,21 @@ from gpath2vec.aucell import compute_aucell, topk_per_niche
22
22
  METHODS = ["metapath2vec", "svd", "spectral", "line", "vae"]
23
23
 
24
24
 
25
+ def _cluster_weights(ea_df, weight):
26
+ """cluster -> {stId: edge weight} over significant pathways."""
27
+ # vectorized; avoids materializing ea_df as a python list of dicts
28
+ sig_df = ea_df[ea_df["sig_pathway"].astype(bool)]
29
+ if weight == "fdr":
30
+ sig_df = sig_df.assign(w=1 - sig_df["fdr_bh"])
31
+ else:
32
+ sig_df = sig_df.assign(w=sig_df["oddsratio"])
33
+ # no leading underscore: itertuples renames such fields positionally
34
+ clusters = {}
35
+ for r in sig_df[["cluster", "stId", "w"]].itertuples(index=False):
36
+ clusters.setdefault(str(r.cluster), {})[str(r.stId)] = float(r.w)
37
+ return clusters
38
+
39
+
25
40
  def _run_embedder(method, graph, ea_mat, study_id, dimensions, epochs, lr,
26
41
  window, seed=1234):
27
42
  """run the selected embedding method, return embeddings dict."""
@@ -294,15 +309,7 @@ def run_pipeline(genes, gene_sets, output_dir, study_id, level, gene_filter,
294
309
 
295
310
  # network
296
311
  click.echo("step 2: network")
297
- # vectorized; avoids materializing ea_df as a python list of dicts
298
- sig_df = ea_df[ea_df["sig_pathway"].astype(bool)]
299
- if weight == "fdr":
300
- sig_df = sig_df.assign(_w=1 - sig_df["fdr_bh"])
301
- else:
302
- sig_df = sig_df.assign(_w=sig_df["oddsratio"])
303
- clusters = {}
304
- for r in sig_df[["cluster", "stId", "_w"]].itertuples(index=False):
305
- clusters.setdefault(str(r.cluster), {})[str(r.stId)] = float(r._w)
312
+ clusters = _cluster_weights(ea_df, weight)
306
313
 
307
314
  # same contract as aggregate_min_fdr: one entry per pathway with min FDR
308
315
  pw_min = ea_df.groupby("stId", as_index=False)["fdr_bh"].min()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gpath2vec
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: gene-set to biological pathway embeddings with enrichment analysis
5
5
  Home-page: https://github.com/teslajoy/gpath2vec
6
6
  Author: Nasim Sanati
@@ -16,5 +16,6 @@ gpath2vec.egg-info/entry_points.txt
16
16
  gpath2vec.egg-info/requires.txt
17
17
  gpath2vec.egg-info/top_level.txt
18
18
  tests/test_aucell_topk.py
19
+ tests/test_cli_cluster_weights.py
19
20
  tests/test_ea_aggregation.py
20
21
  tests/test_metapath_topology.py
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- __version__ = "3.0.0"
3
+ __version__ = "3.0.1"
4
4
 
5
5
  setup(
6
6
  name="gpath2vec",
@@ -0,0 +1,41 @@
1
+ """unit tests for end2end step 2 cluster weights."""
2
+
3
+ import pandas as pd
4
+ import pytest
5
+
6
+ import gpath2vec
7
+ from gpath2vec.cli import _cluster_weights
8
+
9
+
10
+ def _ea_df():
11
+ return pd.DataFrame({
12
+ "cluster": ["A", "A", "B"],
13
+ "stId": ["R-HSA-X", "R-HSA-Y", "R-HSA-X"],
14
+ "fdr_bh": [0.01, 0.5, 0.2],
15
+ "oddsratio": [4.0, 1.1, 2.5],
16
+ "sig_pathway": [True, False, True],
17
+ })
18
+
19
+
20
+ def test_fdr_weight_over_significant_only():
21
+ out = _cluster_weights(_ea_df(), "fdr")
22
+ assert set(out) == {"A", "B"}
23
+ assert set(out["A"]) == {"R-HSA-X"}
24
+ assert out["A"]["R-HSA-X"] == pytest.approx(0.99)
25
+ assert out["B"]["R-HSA-X"] == pytest.approx(0.8)
26
+
27
+
28
+ def test_oddsratio_weight():
29
+ out = _cluster_weights(_ea_df(), "oddsratio")
30
+ assert out["A"]["R-HSA-X"] == pytest.approx(4.0)
31
+ assert out["B"]["R-HSA-X"] == pytest.approx(2.5)
32
+
33
+
34
+ def test_no_significant_pathways_is_empty():
35
+ df = _ea_df().assign(sig_pathway=False)
36
+ assert _cluster_weights(df, "fdr") == {}
37
+
38
+
39
+ def test_version_matches_distribution_metadata():
40
+ from importlib.metadata import version
41
+ assert gpath2vec.__version__ == version("gpath2vec")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes