Conversation
…ne geometric mean
…complete git history of pdex2 into this repository.
Summary of ChangesHello @noamteyssier, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request represents a major refactoring of the pdex library, simplifying its API and core logic. The previous implementation with multiple backends and metrics has been replaced with a streamlined approach centered around a single pdex function with different modes (ref, all, on_target), leveraging numba-mwu for efficient Mann-Whitney U tests. The changes significantly improve code clarity and maintainability. My review focuses on the new implementation's correctness, efficiency, and documentation clarity. I've identified a minor inefficiency, an inconsistency in project configuration, and opportunities to clarify the documentation regarding FDR correction. Overall, this is an excellent and well-executed refactor.
| readme = "README.md" | ||
| authors = [{ name = "noam teyssier", email = "noam.teyssier@arcinstitute.org" }] | ||
| requires-python = ">=3.10" | ||
| requires-python = ">=3.11" |
There was a problem hiding this comment.
The .python-version file specifies Python 3.13, while this file allows >=3.11. For consistency and to prevent potential issues with environment setup tools like pyenv, it's recommended to align these. If the project is intended to be developed and tested primarily on 3.13, consider changing this to >=3.13. If Python 3.11+ is supported, consider changing .python-version to 3.11 to ensure development and testing against the minimum supported version.
| fc = float(fold_change(np.array([target_mean]), np.array([ref_mean]))[0]) | ||
| pc = float(percent_change(np.array([target_mean]), np.array([ref_mean]))[0]) |
There was a problem hiding this comment.
Calling the Numba-jitted fold_change and percent_change functions for single scalar values is inefficient as it involves creating temporary NumPy arrays in each loop iteration. Since the underlying calculations are simple, they can be performed directly on the scalar target_mean and ref_mean values. This will be more performant and readable.
| fc = float(fold_change(np.array([target_mean]), np.array([ref_mean]))[0]) | |
| pc = float(percent_change(np.array([target_mean]), np.array([ref_mean]))[0]) | |
| with np.errstate(divide="ignore", invalid="ignore"): | |
| fc = float(np.log2(target_mean / ref_mean)) | |
| pc = float((target_mean - ref_mean) / ref_mean) | |
| | `percent_change` | (target_mean - ref_mean) / ref_mean | | ||
| | `p_value` | Mann-Whitney U p-value | | ||
| | `statistic` | Mann-Whitney U statistic | | ||
| | `fdr` | FDR-corrected p-value (per-group, across genes) | |
There was a problem hiding this comment.
The description for FDR correction is accurate for ref and all modes, but can be misleading for on_target mode. In on_target mode, FDR is corrected across groups, not per-group across genes (since there's only one gene per group). It would be clearer to specify this distinction.
| | `fdr` | FDR-corrected p-value (per-group, across genes) | | |
| | `fdr` | FDR-corrected p-value. For `ref` and `all` modes, this is applied per-group across genes. For `on_target` mode, it is applied across groups. | |
| | `fdr` | float | FDR-corrected p-value, applied per-group across genes | | ||
|
|
||
| `target_mean` and `ref_mean` are always in natural (count) space regardless of `is_log1p` or `geometric_mean`. | ||
| FDR is corrected within each group (across genes), not globally across all (group, gene) pairs. |
There was a problem hiding this comment.
This statement about FDR correction is accurate for ref and all modes, but not for on_target mode, where correction happens across groups. To avoid confusion, it would be helpful to clarify how FDR is handled in each case.
| FDR is corrected within each group (across genes), not globally across all (group, gene) pairs. | |
| FDR is corrected within each group (across genes) for `"ref"` and `"all"` modes, not globally across all (group, gene) pairs. For `"on_target"` mode, FDR is corrected across all tested groups. |
No description provided.