Skip to main content

pFLEX

PyPI Python License Build Build system Lint CLI

Abstract

Genetic networks derived from omics data are a powerful tool for systematic gene function prediction. Performance evaluation of such predictions is crucial to judge the data and computational pipeline for network construction, but unbalanced functional standards often cause hidden evaluation biases. To visualize and mitigate such biases, we previously developed the R package FLEX. Here, we present the pFLEX genetic network benchmarking tool as Python library with new and improved functionality. pFLEX improves overall runtime 4.1 to 15.8-fold. It offers additional evaluation metrics that allow for easy comparison of precision recall performance at the module or pathway resolution between genetic networks. We demonstrate the utility of pFLEX for evaluating tissue-specific co-essentiality networks and data normalization strategies of the Cancer Dependency Map, as well as for cell line-specific Perturb-Seq-derived networks. This illustrates the requirement for biological module-resolved precision recall metrics in pFLEX for sensitive and fast evaluation of genetic networks.


Features

  • Precision-recall curve generation for ranked gene lists
  • Evaluation using CORUM-derived modules, GO terms, and pathways
  • Module-level resolution analysis and visualization
  • Easy integration into CRISPR screen workflows
  • Packaged DepMap example inputs filtered to CORUM genes

Installation

pFLEX is developed and tested with Python 3.10. We recommend installing it in a dedicated Python 3.10 environment to keep the package and its scientific Python dependencies separate from other projects.

Create venv:

conda create -n p310 python=3.10
conda activate p310
pip install uv

Install pFLEX via pip:

uv pip install pflex

or:

pip install pflex

or install pFLEX via git to develop the package locally:

git clone https://github.com/tyasird/pFLEX.git
cd pFLEX
uv pip install -e .

Usage

Full documentation is available at https://tyasird.github.io/pFLEX/.

Input Data

pFLEX expects each input dataset as a matrix with genes in rows and screens, samples, or cell lines in columns.

Gene ACH-000014 ACH-000219 ACH-000274
A2M -0.125 -0.215 0.065
AATF 0.042 -0.088 -0.016
BCL6 -0.019 0.112 -0.074

CSV, Excel, and Parquet files are supported. Parquet is recommended for larger matrices.

The packaged example inputs are real DepMap 25Q2 tissue subsets filtered to genes present in CORUM:

  • skin_cell_lines_corum_genes.parquet: 3,465 genes x 75 cell lines
  • soft_tissue_cell_lines_corum_genes.parquet: 3,465 genes x 46 cell lines

Use flex.example_input_path() to resolve packaged example inputs:

import pflex as flex

inputs = {
    "Skin": {
        "path": flex.example_input_path("skin_cell_lines_corum_genes.parquet"),
        "sort": "high",
        "color": "#4E79A7",
    },
    "Soft Tissue": {
        "path": flex.example_input_path("soft_tissue_cell_lines_corum_genes.parquet"),
        "sort": "high",
        "color": "#F28E2B",
    },
}

Configuration

config = {
    "functional_standard": "CORUM",
    "min_genes_in_module": 2,
    "min_genes_per_module_analysis": 2,
    "output_folder": "output",
    "analysis_genes": "shared",
    "jaccard": True,
    "preprocessing": {
        "fill_na": True,
    },
    "corr_function": "numpy_without_mask",
    "per_module": {
        "n_jobs": 8,
    },
    "plotting": {
        "save_plot": True,
        "output_type": "pdf",
    },
}

Common choices:

  • functional_standard: "CORUM", "GOBP", "PATHWAY", or a custom .csv path
  • analysis_genes: "shared" or "dataset_specific"
  • sort: "high" or "low" per input dataset
  • preprocessing.fill_na: fill missing values with gene means
  • corr_function: "numpy", "numpy_without_mask", "numba", or "pandas"
  • per_module.n_jobs: worker count for per-module analysis

Analysis Flow

flex.initialize(config)
data, common_genes = flex.load_datasets(inputs)
terms, _ = flex.load_functional_standard()

for name, dataset in data.items():
    corr = flex.perform_corr(dataset, config["corr_function"])
    flex.pra(name, corr, is_corr=True)
    flex.pra_per_module(name, corr, is_corr=True)
    flex.module_contributions(name)
    flex.mpr_prepare(name)

flex.plot_precision_recall_curve()
flex.plot_auc_scores()
flex.plot_significant_modules()
flex.plot_per_module_scatter(n_top=10)
flex.plot_per_module_scatter_by_size(n_top=10)
flex.plot_module_contributions()
flex.plot_mpr_summary()
flex.save_results_to_csv()

mpr_prepare() computes only the standard, unfiltered module-coverage mPR curve. plot_mpr_summary() plots that curve and the corresponding dataset-level mPR AUC values; it does not produce a duplicate global precision-recall plot.

The predefined complex-filter comparisons are optional and computed lazily:

for name in data:
    flex.mpr_filter(name)
    flex.globalpr_filter(name)

# Compare all complexes, removal of mtRibo / ETC I, and removal of
# small high-AUPRC complexes.
mpr_ax, mpr_filter_auc = flex.plot_mpr_filter()
globalpr_ax = flex.plot_globalpr_filter()

The calculation and plotting calls are intentionally separate. Calling a filter plotting function before its matching calculation raises an error that identifies the required preparation function.

See the User Guide for a detailed explanation of every input field, configuration key, function, return value, and output.


Quickstart

import pflex as flex

inputs = {
    "Skin": {
        "path": flex.example_input_path("skin_cell_lines_corum_genes.parquet"),
        "sort": "high",
        "color": "#4E79A7",
    },
    "Soft Tissue": {
        "path": flex.example_input_path("soft_tissue_cell_lines_corum_genes.parquet"),
        "sort": "high",
        "color": "#F28E2B",
    },
}

config = {
    "functional_standard": "CORUM",
    "output_folder": "output",
    "analysis_genes": "shared",
    "jaccard": True,
    "preprocessing": {
        "fill_na": True,
    },
    "corr_function": "numpy_without_mask",
}

flex.initialize(config)
data, _ = flex.load_datasets(inputs)

for name, dataset in data.items():
    corr = flex.perform_corr(dataset, config["corr_function"])
    flex.pra(name, corr, is_corr=True)

flex.plot_precision_recall_curve()
flex.plot_auc_scores()

For a runnable full workflow, see src/pflex/examples/basic_usage.py.


License

MIT

Metadata

Release files for pflex 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pflex 1.4
File Size Uploaded Provenance Actions
pflex-1.4.tar.gz 6.1 MB Without provenance Details for pflex-1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pflex 1.4
File Interpreter ABI Platform Actions
pflex-1.4-py3-none-any.whl Python 3 none any Details for pflex-1.4-py3-none-any.whl

Total release size: 12.0 MB

Release files / pflex-1.4.tar.gz

Download URL pflex-1.4.tar.gz
Size 6.1 MB
Tags Source
SHA-256 checksum
How to use checksums
030196ea658e518cf7ffe4f3f510347d00bb7cfca9f4063fffa365f77f5db618
BLAKE2b-256 checksum
How to use checksums
5f450e027edbb9a6a057e415a7fc937d945aecf733686b7d9068bdce215f8918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release files / pflex-1.4-py3-none-any.whl

Download URL pflex-1.4-py3-none-any.whl
Size 6.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
52e07e5c42fd35bf05ff477eefaa5085bc5762f5e15a7e570d10de0fb7e50207
BLAKE2b-256 checksum
How to use checksums
480edc0fde5e5f914c9e9bfba2941ac47aeaa690fb48b08d43d5ac24e548dae7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Security for pflex 1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page