Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# https://docs.readthedocs.io/en/stable/config-file/v2.html
version: 2
build:
os: ubuntu-20.04
os: ubuntu-24.04
tools:
python: "3.10"
sphinx:
configuration: docs/conf.py
# disable this for more lenient docs builds
fail_on_warning: true
python:
install:
- method: pip
path: .
extra_requirements:
- doc
- full
python: "3.13"
jobs:
create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv venv
- uv pip install .[doc,full]
build:
html:
- uv run sphinx-build -T -W -b html docs $READTHEDOCS_OUTPUT/html

submodules:
include: all
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All functions have been rewritten to follow the new API, errors when running pre
- `viper` now correctly estimates shadow regulons when network weights are values other than -1 or +1
- `wsum` and `wmean` are deprecated, instead now the method `waggr` allows to run both methods and any custom function. This makes it easier to quickly test new enrichment methods without having to deal with `decoupler`'s implementation
- Databases from Omnipath can now be accessed through the new `op` module
- Use `decoupler.op.<resource_name>` to access a database
- Use `decoupler.op.<resource_name>` to access a database
- Removed the `omnipath` package as a dependancy
- Fixed `collectri` to the publication version instead of the OmniPath one
- Made `progeny` only return significant genes by default instead of the top N genes per pathway
Expand Down Expand Up @@ -63,7 +63,7 @@ All functions have been rewritten to follow the new API, errors when running pre
- Added `obsbar` to plot size of metadata columns in `anndata.AnnData.obs`
- Added `order` to plot sources or features along a continous process such as a trajectory
- Added `order_targets` to plot the targets of a given source along a continous process
-
-
- New preprocessing functions in the `pp` module
- Added two functions to format networks, `adjmat` to return an adjacency matrix, and `idxmax` to return a list of sets
- Added `filter_samples` to filter pseudobulk profiles after running `pseudobulk`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# decoupler - Ensemble of methods to infer enrichment scores
<img src="https://github.com/saezlab/decoupleR/blob/master/inst/figures/logo.svg?raw=1" align="right" width="120" class="no-scaled-link" />


[![Tests][badge-tests]][tests]
[![Documentation][badge-docs]][documentation]
Expand Down
4 changes: 2 additions & 2 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ div.cell_output table.dataframe {

/* Adjust the logo size */
.logo img {
width: 50%; /* or any percentage you want */
width: 50%; /* or any percentage you want */
height: auto; /* maintain aspect ratio */
}

img.no-scaled-link {
background: transparent !important;
}
}
2 changes: 1 addition & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ pp

pl
tl
```
```
2 changes: 1 addition & 1 deletion docs/api/mt.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@

mt.decouple
mt.consensus
```
```
2 changes: 1 addition & 1 deletion docs/api/op.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
op.show_resources
op.show_organisms
op.translate
```
```
2 changes: 1 addition & 1 deletion docs/api/pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
pl.order
pl.source_targets
pl.volcano
```
```
18 changes: 9 additions & 9 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ @article{pydeseq
author = {Muzellec, Boris and Teleńczuk, Maria and Cabeli, Vincent and Andreux, Mathieu},
editor = {Ponty, Yann},
year = {2023},
month = sep
month = sep
}

@article{limma,
Expand Down Expand Up @@ -80,7 +80,7 @@ @article{decoupler
author = {Badia-i-Mompel, Pau and Vélez Santiago, Jesús and Braunger, Jana and Geiss, Celina and Dimitrov, Daniel and M\"{u}ller-Dott, Sophia and Taus, Petr and Dugourd, Aurelien and Holland, Christian H and Ramirez Flores, Ricardo O and Saez-Rodriguez, Julio},
editor = {Kuijjer, Marieke Lydia},
year = {2022},
month = jan
month = jan
}

@article{grn_review,
Expand Down Expand Up @@ -210,7 +210,7 @@ @article{panglaodb
publisher = {Oxford University Press (OUP)},
author = {Franzén, Oscar and Gan, Li-Ming and Bj\"{o}rkegren, Johan L M},
year = {2019},
month = jan
month = jan
}

@article{msvisium,
Expand Down Expand Up @@ -254,7 +254,7 @@ @article{hcop
publisher = {Oxford University Press (OUP)},
author = {Yates, Bethan and Gray, Kristian A and Jones, Tamsin E M and Bruford, Elspeth A},
year = {2021},
month = may
month = may
}

@article{omnipath,
Expand Down Expand Up @@ -325,7 +325,7 @@ @article{mofacell
publisher = {eLife Sciences Publications, Ltd},
author = {Ramirez Flores, Ricardo Omar and Lanzer, Jan David and Dimitrov, Daniel and Velten, Britta and Saez-Rodriguez, Julio},
year = {2023},
month = nov
month = nov
}

@article{scanpy,
Expand All @@ -339,7 +339,7 @@ @article{scanpy
publisher = {Springer Science and Business Media LLC},
author = {Wolf, F. Alexander and Angerer, Philipp and Theis, Fabian J.},
year = {2018},
month = feb
month = feb
}

@article{paga,
Expand All @@ -353,7 +353,7 @@ @article{paga
publisher = {Springer Science and Business Media LLC},
author = {Wolf, F. Alexander and Hamey, Fiona K. and Plass, Mireya and Solana, Jordi and Dahlin, Joakim S. and G\"{o}ttgens, Berthold and Rajewsky, Nikolaus and Simon, Lukas and Theis, Fabian J.},
year = {2019},
month = mar
month = mar
}

@article{pax5,
Expand Down Expand Up @@ -412,7 +412,7 @@ @article{gsva
publisher = {Springer Science and Business Media LLC},
author = {H\"{a}nzelmann, Sonja and Castelo, Robert and Guinney, Justin},
year = {2013},
month = jan
month = jan
}

@inproceedings{xgboost,
Expand Down Expand Up @@ -470,5 +470,5 @@ @article{zscore
publisher = {Springer Science and Business Media LLC},
author = {Yılmaz, Serhan and Ayati, Marzieh and Schlatzer, Daniela and undefinedi\c{c}ek, A. Erc\"{u}ment and Chance, Mark R. and Koyut\"{u}rk, Mehmet},
year = {2021},
month = feb
month = feb
}
31 changes: 16 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,16 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
dependencies = [
"adjusttext",
"anndata",
"numba",
"docrep",
"tqdm",
"requests",
"marsilea",
"adjustText",
"numba",
"requests",
"scipy<1.16", # https://github.com/statsmodels/statsmodels/issues/9584
# for debug logging (referenced from the issue template)
"session-info2",
]
optional-dependencies.full = [
"igraph",
"xgboost",
"ipywidgets",
"dcor",
"tqdm",
]
optional-dependencies.dev = [
"pre-commit",
Expand All @@ -59,16 +54,22 @@ optional-dependencies.doc = [
"sphinxcontrib-bibtex>=1",
"sphinxext-opengraph",
]
optional-dependencies.full = [
"dcor",
"igraph",
"ipywidgets",
"xgboost",
]
optional-dependencies.test = [
"coverage",
"pytest",
"statsmodels",
"dcor",
"gseapy",
"scanpy",
"igraph",
"xgboost",
"ipywidgets",
"dcor"
"pytest",
"scanpy",
"statsmodels",
"xgboost",
]
# https://docs.pypi.org/project_metadata/#project-urls
urls.Documentation = "https://decoupler.readthedocs.io/"
Expand Down
2 changes: 1 addition & 1 deletion src/decoupler/bm/metric/_hmean.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ def hmean(
hdf['score'] = hdf[h_cols].mean(axis=1, numeric_only=True)
hdf['score'] = (hdf['score'] - hdf['score'].min()) / (hdf['score'].max() - hdf['score'].min())
return hdf

12 changes: 6 additions & 6 deletions src/decoupler/mt/_aucell.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def _func_aucell(
the set appear in this ranking. Specifically, the enrichment score :math:`ES` is:

.. math::

{ES}_{i, F} = \int_0^1 {RecoveryCurve}_{i, F}(r_i) \, dr

Where:
- :math:`i` is the obervation
- :math:`F` is the feature set

- :math:`i` is the obervation
- :math:`F` is the feature set
- :math:`{RecoveryCurve}_{i, F}(r_i)` is the proportion of features from :math:`F` recovered in the top :math:`r_i`-fraction of the ranked list for observation :math:`i`

%(notest)s
Expand All @@ -92,7 +92,7 @@ def _func_aucell(
nobs, nvar = mat.shape
nsrc = starts.size
n_up = _validate_n_up(nvar, n_up)
m = f'aucell - calculating {nsrc} AUCs for {nvar} targets across {nobs} observations, categorizing features at rank={n_up}'
m = f'aucell - calculating {nsrc} AUCs for {nvar} targets across {nobs} observations, categorizing features at rank={n_up}'
_log(m, level='info', verbose=verbose)
es = np.zeros(shape=(nobs, nsrc))
for i in tqdm(range(mat.shape[0]), disable=not verbose):
Expand Down
4 changes: 2 additions & 2 deletions src/decoupler/mt/_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def consensus(

For each method, enrichment scores are split into positive and negative subsets
and transformed independently into z-scores.

1. Subset values based on sign (direction).
2. Mirror each subset into positive and negative values with the same magnitude.
3. Compute z-scores for each subset: :math:`z_i = \frac{x_i - \mu}{\sigma}`.
Expand All @@ -83,7 +83,7 @@ def consensus(

.. math::

ES = \frac{\sum_{m=1}^{M} z_{i}^{(m)}}{M}
ES = \frac{\sum_{m=1}^{M} z_{i}^{(m)}}{M}

Where:

Expand Down
4 changes: 2 additions & 2 deletions src/decoupler/mt/_gsea.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def _func_gsea(
statistic when a feature is in the set, and decreasing it when it is not.

.. math::
\delta(F, i) =

\delta(F, i) =
\begin{cases}
\frac{|r_i|}{\sum\limits_{j \in F} |r_j|} & \text{if feature } i \in F \\
-\frac{1}{l} & \text{if feature } i \notin F
Expand Down
10 changes: 5 additions & 5 deletions src/decoupler/mt/_gsva.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _mat_ecdf(
for j in range(mat.shape[1]):
D[:, j] = _ecdf(mat[:, j])
return D


@nb.njit(cache=True)
def _col_d(
Expand Down Expand Up @@ -317,19 +317,19 @@ def _func_gsva(
Gene Set Variation Analysis (GSVA) :cite:`gsva`.

Each feature is first transformed and smoothed using a kernel density estimation method:

- Gaussian
- Poisson
- Empirical cumulative distribution function

Features are then ranked based on a continuous metric (e.g., expression value, score, or correlation).

Then, a score for each feature in a set is computed by walking down the ranked list,
increasing a running-sum statistic when a feature belongs to the set and decreasing it otherwise.

.. math::
\delta(F, i) =

\delta(F, i) =
\begin{cases}
\frac{|r_i|}{\sum\limits_{j \in F} |r_j|} & \text{if feature } i \in F \\
-\frac{1}{l} & \text{if feature } i \notin F
Expand Down
2 changes: 1 addition & 1 deletion src/decoupler/mt/_mdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _func_mdt(
which are the weights of all feature sets :math:`F`. It uses the implementation provided by ``xgboost`` :cite:`xgboost`.

The enrichment score :math:`ES` for each :math:`F` is then calculated as the importance of each covariate in the model.

%(notest)s

%(params)s
Expand Down
2 changes: 1 addition & 1 deletion src/decoupler/mt/_mlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _func_mlm(
.. math::

p_{value} = 2 \times \mathrm{sf}(|ES|, \text{df})


%(params)s
%(tval)s
Expand Down
10 changes: 5 additions & 5 deletions src/decoupler/mt/_ora.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ def _func_ora(
:width: 100%

Over Representation Analysis (ORA) scheme.

The statistic is calculated as the Odds Ratio :math:`OR` with Haldane-Anscombe correction.

.. math::

\text{OR} = \log{\frac{\frac{a + 0.5}{b + 0.5}}{\frac{c + 0.5}{d + 0.5}}}

And the :math:`p_{value}` is obtained afer computing a two-tailed Fisher’s exact test with the same table.
Expand All @@ -206,16 +206,16 @@ def _func_ora(
nsrc = starts.size
if n_up is None:
n_up = int(np.max([np.ceil(0.05 * nvar), 2]))
m = f'ora - setting n_up={n_up}'
m = f'ora - setting n_up={n_up}'
_log(m, level='info', verbose=verbose)
if n_bg is None:
n_bg = 0
m = f'ora - not using n_bg, a feature specific background will be used instead'
m = f'ora - not using n_bg, a feature specific background will be used instead'
_log(m, level='info', verbose=verbose)
assert isinstance(n_up, (int, float)) and n_up > 0, 'n_up must be numeric and > 0'
assert isinstance(n_bm, (int, float)) and n_bm >= 0, 'n_bm must be numeric and positive'
assert isinstance(n_bg, (int, float)) and n_bg >= 0, 'n_bg must be numeric and positive'
m = f'ora - calculating {nsrc} scores across {nobs} observations with n_up={n_up}, n_bm={n_bm}, n_bg={n_bg}'
m = f'ora - calculating {nsrc} scores across {nobs} observations with n_up={n_up}, n_bm={n_bm}, n_bg={n_bg}'
_log(m, level='info', verbose=verbose)
es = np.zeros((nobs, nsrc))
pv = np.zeros((nobs, nsrc))
Expand Down
2 changes: 1 addition & 1 deletion src/decoupler/mt/_udt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _func_udt(
_check_import(xgboost, 'xgboost')
nobs = mat.shape[0]
nvar, nsrc = adj.shape
m = f'udt - fitting {nsrc} univariate decision tree models (XGBoost) of {nvar} targets across {nobs} observations'
m = f'udt - fitting {nsrc} univariate decision tree models (XGBoost) of {nvar} targets across {nobs} observations'
_log(m, level='info', verbose=verbose)
es = np.zeros(shape=(nobs, nsrc))
for i in tqdm(range(nobs), disable=not verbose):
Expand Down
Loading