Skip to content
pachterlabPublic

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

XgenePy

XgenePy is a Python port of the XgeneR package for modeling cis and trans regulatory differences between homozygous strains. It mirrors the core XgeneR workflow while replacing the R edgeR dependency with the Python edgepython package.

The package centers on:

  • building the same allele-aware design matrices used by XgeneR
  • fitting negative binomial GLMs with edgepython
  • testing cis and trans hypotheses
  • generating the same assignment and proportion-cis summaries
  • producing diagnostic plots in matplotlib

Install

Create the conda environment:

conda env create -f environment.yaml
conda activate xgenepy

Then install the package in editable mode:

pip install -e .

Example

import pandas as pd
from xgenepy import FitObject, fit_edgepython, get_assignments_and_plot

counts = pd.read_csv("data/BATcold_ballinger_counts.csv", index_col=0)
metadata = pd.read_csv("data/BATcold_ballinger_metadata.csv", index_col=0)

fit_obj = FitObject(counts=counts, metadata=metadata, trans_model="log_additive")
fit_obj = fit_edgepython(fit_obj)

results = get_assignments_and_plot(fit_obj, make_plot=False)
print(results.dataframe.head())

With multiple conditions (fields_to_test), fit_edgepython runs the tests passed in test; notebooks/multi_condition_example.ipynb shows how to build per-condition cis and trans tests.

Validation

With edgepython 0.5.0 or later (which matches edgeR 5.0), XgenePy reproduces the XgeneR reference values in XgeneR/tests/fixtures to within 1e-6 for both trans models, in the single- and multiple-condition examples. To check, with an XgeneR checkout next to this repository:

python tests/validate_against_xgener.py --xgener-root ../XgeneR

pytest runs the same check when it finds ../XgeneR (or $XGENER_ROOT).

Project Layout

  • src/xgenepy/model.py: model construction, design matrices, contrasts, and fitting
  • src/xgenepy/plotting.py: plotting and assignment helpers
  • data/: copied example datasets from XgeneR, including BATcold, cold, and full Ballinger files
  • notebooks/: Jupyter notebook equivalents of the XgeneR vignettes
  • tests/: pytest coverage for design and fitting, and the comparison with XgeneR
  • scripts/: example script for running the BATcold dataset

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages