pflex 1.3__tar.gz → 1.4.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 (34) hide show
  1. {pflex-1.3 → pflex-1.4.1}/PKG-INFO +3 -4
  2. {pflex-1.3 → pflex-1.4.1}/README.md +1 -1
  3. {pflex-1.3 → pflex-1.4.1}/docs/getting-started.md +1 -1
  4. {pflex-1.3 → pflex-1.4.1}/docs/user-guide.md +21 -3
  5. {pflex-1.3 → pflex-1.4.1}/pyproject.toml +96 -97
  6. {pflex-1.3 → pflex-1.4.1}/src/pflex/__init__.py +4 -4
  7. {pflex-1.3 → pflex-1.4.1}/src/pflex/analysis.py +30 -8
  8. {pflex-1.3 → pflex-1.4.1}/src/pflex/examples/basic_usage.py +1 -1
  9. pflex-1.4.1/src/pflex/plotting.py +1739 -0
  10. {pflex-1.3 → pflex-1.4.1}/src/pflex/preprocessing.py +4 -2
  11. pflex-1.4.1/src/pflex/style.py +37 -0
  12. {pflex-1.3 → pflex-1.4.1}/uv.lock +1942 -1960
  13. pflex-1.3/src/pflex/plotting.py +0 -1974
  14. pflex-1.3/tests/test_mpr_filters.py +0 -176
  15. pflex-1.3/tests/test_plotting_labels.py +0 -205
  16. {pflex-1.3 → pflex-1.4.1}/.gitignore +0 -0
  17. {pflex-1.3 → pflex-1.4.1}/.python-version +0 -0
  18. {pflex-1.3 → pflex-1.4.1}/LICENSE +0 -0
  19. {pflex-1.3 → pflex-1.4.1}/docs/index.md +0 -0
  20. {pflex-1.3 → pflex-1.4.1}/docs/installation.md +0 -0
  21. {pflex-1.3 → pflex-1.4.1}/mkdocs.yml +0 -0
  22. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/__init__.py +0 -0
  23. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/example_input/__init__.py +0 -0
  24. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/example_input/skin_cell_lines_corum_genes.parquet +0 -0
  25. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/example_input/soft_tissue_cell_lines_corum_genes.parquet +0 -0
  26. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/CORUM.parquet +0 -0
  27. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/GOBP.parquet +0 -0
  28. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/PATHWAY.parquet +0 -0
  29. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/__init__.py +0 -0
  30. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/corum.csv +0 -0
  31. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/gobp.csv +0 -0
  32. {pflex-1.3 → pflex-1.4.1}/src/pflex/data/functional_standard/pathway.csv +0 -0
  33. {pflex-1.3 → pflex-1.4.1}/src/pflex/logging_config.py +0 -0
  34. {pflex-1.3 → pflex-1.4.1}/src/pflex/utils.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: pflex
3
- Version: 1.3
3
+ Version: 1.4.1
4
4
  Summary: pflex is a benchmarking toolkit for evaluating CRISPR screen results against biological functional standards. The toolkit computes gene-level and module-level performance metrics, helping researchers systematically assess the biological relevance and resolution of their CRISPR screening data.
5
5
  Author-email: Yasir Demirtas <tyasird@hotmail.com>
6
6
  License-File: LICENSE
@@ -10,7 +10,6 @@ Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.10
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Requires-Python: >=3.10
13
- Requires-Dist: adjusttext
14
13
  Requires-Dist: art
15
14
  Requires-Dist: bitarray
16
15
  Requires-Dist: emoji
@@ -148,7 +147,7 @@ config = {
148
147
  },
149
148
  "plotting": {
150
149
  "save_plot": True,
151
- "output_type": "png",
150
+ "output_type": "pdf",
152
151
  },
153
152
  }
154
153
  ```
@@ -117,7 +117,7 @@ config = {
117
117
  },
118
118
  "plotting": {
119
119
  "save_plot": True,
120
- "output_type": "png",
120
+ "output_type": "pdf",
121
121
  },
122
122
  }
123
123
  ```
@@ -42,7 +42,7 @@ config = {
42
42
  },
43
43
  "plotting": {
44
44
  "save_plot": True,
45
- "output_type": "png",
45
+ "output_type": "pdf",
46
46
  },
47
47
  }
48
48
 
@@ -70,7 +70,7 @@ config = {
70
70
  },
71
71
  "plotting": {
72
72
  "save_plot": True,
73
- "output_type": "png",
73
+ "output_type": "pdf",
74
74
  },
75
75
  "logging": {
76
76
  "visible_levels": ["DONE", "INFO", "WARNING"],
@@ -93,6 +93,7 @@ Configuration keys:
93
93
  - `per_module.n_jobs`: worker count for per-module analysis.
94
94
  - `plotting.save_plot`: when `True`, saves figures to `output_folder`.
95
95
  - `plotting.output_type`: figure extension, such as `"png"` or `"pdf"`.
96
+ - `plotting.dpi`: resolution of raster output such as PNG (default `300`). Vector formats (`"pdf"`, `"svg"`) keep text editable.
96
97
  - `logging.visible_levels`: log levels to print during the run. Available values are `"STARTED"`, `"PROGRESS"`, `"DONE"`, `"INFO"`, `"WARNING"`, and `"ERROR"`. A quiet run can use `["DONE", "WARNING"]`; a more verbose run can use `["STARTED", "PROGRESS", "DONE", "INFO", "WARNING"]`.
97
98
 
98
99
  ## Loading
@@ -179,6 +180,9 @@ flex.save_results_to_csv()
179
180
 
180
181
  Plotting functions read cached analysis results from the current run. If `plotting.save_plot` is `True`, figures are written to `output_folder`.
181
182
 
183
+ All figures are produced at their final print size (about 3 inches wide, a single journal column) with 8 pt Arial text and thin lines, so they can go into a manuscript without rescaling.
184
+ Each plot has a descriptive default title and a small grey caption under it (`title=` / `caption=` to change them, `""` to remove). Precision-recall, mPR and scatter plots use a square plot area whatever the axis range. Dataset legends go into an empty corner of the plot when one exists, otherwise outside on the right. The complex-filter comparisons (`plot_globalpr_filter`, `plot_mpr_filter`) show one small panel per filter, with datasets in their usual colours and solid lines; in `plot_panels` give them two columns: `(flex.plot_globalpr_filter, {}, 2)`.
185
+
182
186
  Global plots:
183
187
 
184
188
  - `plot_precision_recall_curve(line_width=2.0, hide_minor_ticks=True)` shows precision against the cumulative number of true-positive gene pairs. This is the main global performance curve; higher precision at the same true-positive count means better ranking.
@@ -187,14 +191,28 @@ Global plots:
187
191
  Per-module plots:
188
192
 
189
193
  - `plot_significant_modules()` counts how many functional-standard terms pass AUPRC thresholds `0.1`, `0.2`, `0.3`, `0.4`, and `0.5`. It returns the threshold-by-dataset count table, which helps compare how many terms are strongly recovered in each dataset.
190
- - `plot_per_module_scatter(n_top=10, ...)` compares per-module AUPRC values between pairs of datasets. Each point is one functional-standard term. Points near the diagonal perform similarly in both datasets; points far from the diagonal are terms that are stronger in one dataset.
194
+ - `plot_per_module_scatter(n_top=10, ...)` compares per-module AUPRC values between pairs of datasets. Each point is one functional-standard term. Points near the diagonal perform similarly in both datasets; points far from the diagonal are terms that are stronger in one dataset. The figure is publication-ready at its final size (3 × 3 in, 8 pt Arial, 0.25 pt borders, editable text in PDF/SVG). Every highlighted term (top `n_top` in either dataset, including terms top in both) is always labelled; `n_labels` is deprecated and ignored. Reference circle sizes (5, 10, 50 genes) are shown under the plot (`size_legend=False` to hide), using their first word (`short_labels=True`); nearby terms with the same short name share one label, and `label_map={"Full name": "Label"}` overrides individual labels. Labels that cannot be placed without overlap are left out with a warning.
191
195
  - `plot_per_module_scatter_by_size(n_labels=10, n_top=10, ...)` plots each term's per-module AUPRC against the number of genes used for that term. It helps distinguish compact high-performing terms from broader modules.
192
196
  - `plot_module_contributions(min_pairs=10, min_precision_cutoff=0.5, num_module_to_show=10, ...)` shows which terms contribute most to true-positive gene pairs across precision cutoffs. It requires `module_contributions(name)` first and helps identify which biological terms drive the global precision-recall curve.
193
197
 
198
+ Multi-panel figures:
199
+
200
+ - Every plot function accepts `ax=` and then draws into that axes instead of a new figure (nothing is saved). Functions that make one figure per dataset or pair take `dataset=` / `pair=` to choose which one.
201
+ - `plot_panels(panels, ncols=2, panel_size=(3.4, 3.6))` builds a figure labelled a, b, c, ... from those functions. Each entry is a function or a `(function, kwargs)` tuple; ticks, labels and legends are fitted inside each panel's cell, and the result is saved as `figure_panels.<output_type>` (`outname=` to change).
202
+
203
+ ```python
204
+ flex.plot_panels([
205
+ flex.plot_precision_recall_curve,
206
+ (flex.plot_per_module_scatter, {"pair": ("Skin", "Soft Tissue")}),
207
+ flex.plot_auc_scores,
208
+ flex.plot_mpr_module_coverage_curve,
209
+ ], ncols=2)
210
+ ```
211
+
194
212
  mPR preparation and plots:
195
213
 
196
214
  - `mpr_prepare(name, tp_th=1, percent_th=0.1)` prepares the single unfiltered module-coverage mPR curve for one dataset.
197
- - `plot_mpr_module_coverage_curve(dataset_names=None, colors=None, linewidth=1.8, show_markers="auto")` compares unfiltered mPR curves across datasets.
215
+ - `plot_mpr_module_coverage_curve(dataset_names=None, colors=None, linewidth=1.0, show_markers="auto")` compares unfiltered mPR curves across datasets.
198
216
  - `plot_mpr_summary(...)` creates the unfiltered module-coverage plot and the dataset-level mPR AUC plot. It does not create a global PR plot.
199
217
  - `mpr_filter(name, size_th=30, auprc_th=0.4, ...)` lazily computes the three predefined module-coverage filter variants. `plot_mpr_filter()` plots them and returns the variant AUC table alongside the axes.
200
218
  - `globalpr_filter(name, size_th=30, auprc_th=0.4, ...)` lazily computes the matching global PR variants. `plot_globalpr_filter()` plots them.
@@ -1,97 +1,96 @@
1
- [project]
2
- name = "pflex"
3
- version = "1.3"
4
- description = "pflex is a benchmarking toolkit for evaluating CRISPR screen results against biological functional standards. The toolkit computes gene-level and module-level performance metrics, helping researchers systematically assess the biological relevance and resolution of their CRISPR screening data."
5
- readme = "README.md"
6
- authors = [
7
- { name = "Yasir Demirtas", email = "tyasird@hotmail.com" }
8
- ]
9
- requires-python = ">=3.10"
10
- classifiers = [
11
- "Programming Language :: Python :: 3",
12
- "Programming Language :: Python :: 3.10",
13
- "Programming Language :: Python :: 3.11",
14
- "License :: OSI Approved :: MIT License",
15
- "Operating System :: OS Independent",
16
- ]
17
-
18
- dependencies = [
19
- "adjustText",
20
- "art",
21
- "bitarray",
22
- "emoji",
23
- "ipython",
24
- "joblib",
25
- "loguru",
26
- "matplotlib",
27
- "numba",
28
- "numpy",
29
- "pandas",
30
- "pyarrow",
31
- "python-slugify",
32
- "scikit-learn",
33
- "scipy",
34
- "tqdm",
35
- "importlib-resources",
36
- ]
37
-
38
- [project.scripts]
39
- pflex = "pflex:main"
40
-
41
- [build-system]
42
- requires = ["hatchling"]
43
- build-backend = "hatchling.build"
44
-
45
- [tool.ruff]
46
- ignore = ["F541"]
47
-
48
- [tool.setuptools]
49
- include-package-data = true
50
-
51
- [tool.setuptools.packages.find]
52
- include = ["pflex*"]
53
-
54
- [tool.setuptools.package-data]
55
- pflex = ["data/**/*.parquet", "data/**/*.csv", "data/**/*.tsv", "data/**/*.json", "data/**/*.txt", "data/**/*.xlsx", "data/**/*.xls", "data/**/*.h5", "data/**/*.hdf5"]
56
-
57
- [tool.hatch.build]
58
- exclude = [
59
- ".git",
60
- ".github",
61
- ".venv",
62
- "**/.env",
63
- "**/.env.*",
64
- "**/.ipynb_checkpoints",
65
- "**/.mypy_cache",
66
- "**/.pytest_cache",
67
- "**/.ruff_cache",
68
- "**/.tmp",
69
- "**/__pycache__",
70
- "**/*.pyc",
71
- "**/*.pyo",
72
- "**/result.pkl",
73
- "build",
74
- "dist",
75
- "examples/output",
76
- "site",
77
- "src/pflex/input/*",
78
- "src/pflex/output/*",
79
- "src/pflex/examples/output/*",
80
- "src/pflex/examples/.tmp/*",
81
- "tmp",
82
- "temp",
83
- "wheels",
84
- ]
85
-
86
- [tool.hatch.build.targets.wheel]
87
- packages = ["src/pflex"]
88
-
89
- [tool.uv.sources]
90
- pflex = { workspace = true }
91
-
92
- [dependency-groups]
93
- dev = [
94
- "pflex",
95
- "mkdocs",
96
- "mkdocs-material",
97
- ]
1
+ [project]
2
+ name = "pflex"
3
+ version = "1.4.1"
4
+ description = "pflex is a benchmarking toolkit for evaluating CRISPR screen results against biological functional standards. The toolkit computes gene-level and module-level performance metrics, helping researchers systematically assess the biological relevance and resolution of their CRISPR screening data."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Yasir Demirtas", email = "tyasird@hotmail.com" }
8
+ ]
9
+ requires-python = ">=3.10"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Programming Language :: Python :: 3.10",
13
+ "Programming Language :: Python :: 3.11",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+
18
+ dependencies = [
19
+ "art",
20
+ "bitarray",
21
+ "emoji",
22
+ "ipython",
23
+ "joblib",
24
+ "loguru",
25
+ "matplotlib",
26
+ "numba",
27
+ "numpy",
28
+ "pandas",
29
+ "pyarrow",
30
+ "python-slugify",
31
+ "scikit-learn",
32
+ "scipy",
33
+ "tqdm",
34
+ "importlib-resources",
35
+ ]
36
+
37
+ [project.scripts]
38
+ pflex = "pflex:main"
39
+
40
+ [build-system]
41
+ requires = ["hatchling"]
42
+ build-backend = "hatchling.build"
43
+
44
+ [tool.ruff]
45
+ ignore = ["F541"]
46
+
47
+ [tool.setuptools]
48
+ include-package-data = true
49
+
50
+ [tool.setuptools.packages.find]
51
+ include = ["pflex*"]
52
+
53
+ [tool.setuptools.package-data]
54
+ pflex = ["data/**/*.parquet", "data/**/*.csv", "data/**/*.tsv", "data/**/*.json", "data/**/*.txt", "data/**/*.xlsx", "data/**/*.xls", "data/**/*.h5", "data/**/*.hdf5"]
55
+
56
+ [tool.hatch.build]
57
+ exclude = [
58
+ ".git",
59
+ ".github",
60
+ ".venv",
61
+ "**/.env",
62
+ "**/.env.*",
63
+ "**/.ipynb_checkpoints",
64
+ "**/.mypy_cache",
65
+ "**/.pytest_cache",
66
+ "**/.ruff_cache",
67
+ "**/.tmp",
68
+ "**/__pycache__",
69
+ "**/*.pyc",
70
+ "**/*.pyo",
71
+ "**/result.pkl",
72
+ "build",
73
+ "dist",
74
+ "examples/output",
75
+ "site",
76
+ "src/pflex/input/*",
77
+ "src/pflex/output/*",
78
+ "src/pflex/examples/output/*",
79
+ "src/pflex/examples/.tmp/*",
80
+ "tmp",
81
+ "temp",
82
+ "wheels",
83
+ ]
84
+
85
+ [tool.hatch.build.targets.wheel]
86
+ packages = ["src/pflex"]
87
+
88
+ [tool.uv.sources]
89
+ pflex = { workspace = true }
90
+
91
+ [dependency-groups]
92
+ dev = [
93
+ "pflex",
94
+ "mkdocs",
95
+ "mkdocs-material",
96
+ ]
@@ -3,10 +3,10 @@ from .utils import dsave, dload
3
3
  from .preprocessing import example_input_path, get_example_data_path, load_datasets, get_common_genes, filter_matrix_by_genes, load_functional_standard, filter_duplicate_terms
4
4
  from .analysis import initialize, prepare_terms_for_dataset, pra, pra_per_module, fast_corr, perform_corr, is_symmetric, binary, has_mirror_of_first_pair, convert_full_to_half_matrix, drop_mirror_pairs, quick_sort, module_contributions, save_results_to_csv, update_matploblib_config, mpr_prepare, mpr_filter, globalpr_filter
5
5
  from .plotting import (
6
- adjust_text_positions, plot_precision_recall_curve, plot_aggregated_pra, plot_iqr_pra, plot_all_runs_pra, plot_per_module_scatter,
6
+ plot_precision_recall_curve, plot_aggregated_pra, plot_iqr_pra, plot_all_runs_pra, plot_per_module_scatter,
7
7
  plot_per_module_scatter_by_size, plot_module_contributions, plot_significant_modules, plot_auc_scores,
8
8
  plot_mpr_module_coverage_curve, plot_mpr_module_auc_scores, plot_mpr_summary,
9
- plot_mpr_filter, plot_globalpr_filter
9
+ plot_mpr_filter, plot_globalpr_filter, plot_panels
10
10
  )
11
11
 
12
12
  def main():
@@ -35,9 +35,9 @@ __all__ = [ "log", "example_input_path", "get_example_data_path", "fast_corr",
35
35
  "filter_matrix_by_genes", "load_functional_standard", "filter_duplicate_terms", "pra", "pra_per_module",
36
36
  "prepare_terms_for_dataset",
37
37
  "perform_corr", "is_symmetric", "binary", "has_mirror_of_first_pair", "convert_full_to_half_matrix",
38
- "drop_mirror_pairs", "quick_sort", "module_contributions", "adjust_text_positions", "plot_precision_recall_curve",
38
+ "drop_mirror_pairs", "quick_sort", "module_contributions", "plot_precision_recall_curve",
39
39
  "plot_aggregated_pra", "plot_iqr_pra", "plot_all_runs_pra", "plot_per_module_scatter", "plot_per_module_scatter_by_size", "plot_module_contributions",
40
40
  "plot_significant_modules", "plot_auc_scores", "plot_mpr_module_auc_scores", "save_results_to_csv", "update_matploblib_config",
41
- "mpr_prepare", "mpr_filter", "globalpr_filter", "plot_mpr_filter", "plot_globalpr_filter",
41
+ "mpr_prepare", "mpr_filter", "globalpr_filter", "plot_mpr_filter", "plot_globalpr_filter", "plot_panels",
42
42
  "plot_mpr_module_coverage_curve", "plot_mpr_summary", "main"
43
43
  ]
@@ -25,6 +25,10 @@ from .preprocessing import (
25
25
  load_functional_standard,
26
26
  )
27
27
  from .utils import dsave, dload, _sanitize, normalize_analysis_genes
28
+ from .style import PUBLICATION_RC
29
+
30
+ # numpy 2.0 renamed trapz to trapezoid; numpy 2.5 removed the old name.
31
+ _trapz = getattr(np, "trapezoid", None) or np.trapz
28
32
 
29
33
  import matplotlib as mpl
30
34
 
@@ -129,7 +133,7 @@ def initialize(config={}):
129
133
  def update_matploblib_config(config=None, font_family="Arial", layout="single"):
130
134
  """
131
135
  Configure matplotlib settings optimized for Nature journal figures:
132
- - 7 pt fonts (labels, ticks, legend), 9 pt titles
136
+ - 8 pt fonts everywhere (style.PUBLICATION_RC), 300 dpi output
133
137
  - Thin spines (0.5 pt), ticks out (left/bottom only), no minor ticks
134
138
  - No grid, clean minimalist look
135
139
  - Colorblind-friendly Tableau 10 color cycle
@@ -226,6 +230,13 @@ def update_matploblib_config(config=None, font_family="Arial", layout="single"):
226
230
  "pdf.use14corefonts": False,
227
231
  "svg.fonttype": "none",
228
232
  })
233
+ # Same 8 pt style as pflex's own plots (style.PUBLICATION_RC), so user
234
+ # figures and pflex figures match.
235
+ mpl.rcParams.update(PUBLICATION_RC)
236
+ mpl.rcParams["font.sans-serif"] = [font_family] + [
237
+ f for f in PUBLICATION_RC["font.sans-serif"] if f != font_family
238
+ ]
239
+ mpl.rcParams["savefig.dpi"] = config.get("plotting", {}).get("dpi", 300)
229
240
 
230
241
 
231
242
  def _sort_ascending_for_dataset(dataset_name):
@@ -388,7 +399,7 @@ def _corrected_auc(df: pd.DataFrame) -> float:
388
399
  valid = df[["precision", "recall"]].replace([np.inf, -np.inf], np.nan).dropna()
389
400
  if len(valid) < 2:
390
401
  return np.nan
391
- return np.trapz(valid["precision"], valid["recall"]) - valid["precision"].iloc[-1]
402
+ return _trapz(valid["precision"], valid["recall"]) - valid["precision"].iloc[-1]
392
403
 
393
404
  def _build_gene_to_pair_indices(pairwise_df):
394
405
  indices = pairwise_df.index.values
@@ -497,7 +508,7 @@ def _process_chunk(chunk_terms, min_genes, memmap_path, gene_to_pair_indices):
497
508
  # Compute regular AUC
498
509
  local_auc_scores[idx] = metrics.auc(recall, precision)
499
510
  # Compute corrected AUC using the same logic as _corrected_auc function
500
- local_corrected_auc_scores[idx] = np.trapz(precision, recall) - precision.iloc[-1]
511
+ local_corrected_auc_scores[idx] = _trapz(precision, recall) - precision.iloc[-1]
501
512
 
502
513
  return {'auc': local_auc_scores, 'corrected_auc': local_corrected_auc_scores}
503
514
 
@@ -870,7 +881,7 @@ def perform_corr(df, corr_func):
870
881
  corr = np.ma.corrcoef(M)
871
882
  arr = corr.filled(np.nan)
872
883
  df_corr = pd.DataFrame(arr, index=df.index, columns=df.index)
873
- np.fill_diagonal(df_corr.values, np.nan)
884
+ df_corr = _nan_diagonal(df_corr)
874
885
  # check shape is x_axis x x_axis
875
886
  if df_corr.shape != (x_axis, x_axis):
876
887
  raise ValueError(f"Correlation matrix shape mismatch: expected ({x_axis}, {x_axis}), got {df_corr.shape}")
@@ -880,7 +891,7 @@ def perform_corr(df, corr_func):
880
891
  elif corr_func == "numpy_without_mask":
881
892
  corr = np.corrcoef(df.values)
882
893
  df_corr = pd.DataFrame(corr, index=df.index, columns=df.index)
883
- np.fill_diagonal(df_corr.values, np.nan)
894
+ df_corr = _nan_diagonal(df_corr)
884
895
  if df_corr.shape != (x_axis, x_axis):
885
896
  raise ValueError(f"Correlation matrix shape mismatch: expected ({x_axis}, {x_axis}), got {df_corr.shape}")
886
897
  log.done("Correlation.")
@@ -889,7 +900,7 @@ def perform_corr(df, corr_func):
889
900
 
890
901
  elif corr_func == "numba":
891
902
  corr = fast_corr(df)
892
- np.fill_diagonal(corr.values, np.nan)
903
+ corr = _nan_diagonal(corr)
893
904
  if corr.shape != (x_axis, x_axis):
894
905
  raise ValueError(f"Correlation matrix shape mismatch: expected ({x_axis}, {x_axis}), got {corr.shape}")
895
906
  log.done("Correlation using Numba.")
@@ -898,11 +909,22 @@ def perform_corr(df, corr_func):
898
909
  else:
899
910
  # Compute correlations and modify diagonal in-place
900
911
  corr = df.T.corr()
901
- np.fill_diagonal(corr.values, np.nan)
912
+ corr = _nan_diagonal(corr)
902
913
  if corr.shape != (x_axis, x_axis):
903
914
  raise ValueError(f"Correlation matrix shape mismatch: expected ({x_axis}, {x_axis}), got {corr.shape}")
904
915
  return corr
905
916
 
917
+ def _nan_diagonal(corr):
918
+ """Return ``corr`` with NaN on the diagonal (self-correlations).
919
+
920
+ Works on a copy: with pandas >= 3 (copy-on-write) ``DataFrame.values`` is
921
+ read-only, so filling it in place raises.
922
+ """
923
+ arr = corr.to_numpy(dtype=float, copy=True)
924
+ np.fill_diagonal(arr, np.nan)
925
+ return pd.DataFrame(arr, index=corr.index, columns=corr.columns)
926
+
927
+
906
928
  def fast_corr(df):
907
929
  @njit(parallel=True)
908
930
  def compute_corr(data):
@@ -1504,7 +1526,7 @@ def _mpr_modules_auc(
1504
1526
  if x.size < 2:
1505
1527
  return 0.0
1506
1528
 
1507
- return float(np.trapz(y, x))
1529
+ return float(_trapz(y, x))
1508
1530
 
1509
1531
 
1510
1532
 
@@ -30,7 +30,7 @@ default_config = {
30
30
  "analysis_genes": "shared", # or "dataset_specific" (genes present per dataset)
31
31
  "plotting": {
32
32
  "save_plot": True,
33
- "output_type": "png",
33
+ "output_type": "pdf",
34
34
  },
35
35
  "preprocessing": {
36
36
  "fill_na": True,