Skip to main content

PyRRA: Python Implementation of the RobustRankAggreg R package

Disclaimer: The PyRRA (Python Robust Rank Aggregation) project is an attempted port of the RobustRankAggreg R package (v1.2.1; cran.r-project.org/web/packages/RobustRankAggreg). PyRRA is under development and the outputs between the original R package and this Python implementation are not guaranteed to be identical. This python reimplementation is independent of the original authors and code maintainers (DOI: 10.1093/bioinformatics/btr709).

License: MIT

PyRRA is a Python implementation of the Robust Rank Aggregation method, ported from the RobustRankAggreg (RRA) R package. RRA enables robust aggregation of ranked lists with missing/unmatched elements. PyRRA enables reproducible meta-analyses, gene integration, and other robust ranking applications right from Python.


Features

  • PyRRA is still under development - please report bugs, missing features, or incorrect results
  • Robust aggregation of partial or full ranked lists (no requirement that sets overlap)
  • Ports of RRA's rankMatrix, betaScores, rhoScores, and all aggregation methods (RRA, stuart, mean, min, median, geom.mean)
  • Validated with cross-language testing against the original R package
  • Helper utilities for thresholding, multiple testing correction, and Stuart p-value computation

Installation

Suggested Conda environment:

conda env create -f environment.yml 
conda activate pyrra

Install from PyPi (recommended):

pip install pyrra

Install directly from source via pip:

pip install .

Usage

from pyrra import rank_matrix, aggregate_ranks

# A list of ranked gene symbols (or any unique items)
glists = [
    ['b', 'c', 'd', 'a'],
    ['h', 'b', 'f', 'e', 'd', 'c', 'g', 'a', 'j', 'i'],
    ['m', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b']
]

rank_mat = rank_matrix(glists)
print(rank_mat)
#           L1   L2   L3
# a  1.000000 0.125  NaN
# b  0.250000 0.175 0.917
# ...

# Aggregate with the default RRA method
agg = aggregate_ranks(glist=glists, method='RRA')
print(agg.head())
#     Name     Score
# 0      ...     ...

You can also pass a pandas DataFrame rank matrix to aggregate_ranks via rmat=....

Aggregation Methods

  • RRA (default)
  • stuart: Stuart-Aerts p-value
  • min, mean, median, geom.mean: Aggregate using these statistics

Advanced Arguments

  • full (default=False): Set True if all input lists are full rankings (for structural NA treatment)
  • N: Total number of rankable items (overrides default: union of elements)
  • exact (default: auto): Use exact p-value (slower, may be numerically unstable for many lists)
  • top_cutoff: Vector of cutoff values (for sensitivity when lists are truncated at different points)

API Reference

rank_matrix(glist, N=None, full=False)

  • Converts ranked lists to a normalized rank matrix.
  • Parameters:
    • glist: list of lists
    • N: total number of rankable elements (default: union of glist)
    • full: If True, treat all as full-length rankings with NA for structural gaps
  • Returns: pandas DataFrame

aggregate_ranks(glist=None, rmat=None, N=None, method='RRA', full=False, exact=None, top_cutoff=None)

  • Main aggregation method (RRA, mean, min, etc).
  • Returns: pandas DataFrame of scores, sorted.

Citing


Contributors

Elly Poretsky (@eporetsky) — Python port, test suite, data validation. Disclaimer: This is an independent Python implementation of RobustRankAggreg. Identical results are not guaranteed.


See Also


Comparison with the R implementation

For users seeking direct comparison and validation against the original R RobustRankAggreg package, see the output in compare/comprehensive_comparison.txt or follow the instructions below to run your own validations:

cd compare

# Conda environment with Python and R
conda env create -f environment.yml 
conda activate pyrra_compare
pip install pyrra

# Run tests to comparee
python comprehensive_comparison.py

The comparison uses pd.testing.assert_frame_equal(py_res, r_res, check_dtype=False, atol=1e-12) to validate that Python and R outputs are numerically identical within a tolerance of 1e-12.

Total tests: 7
Passed: 7
Failed: 0

🎉 ALL TESTS PASSED! Python and R implementations are identical.

Metadata

Release files for PyRRA 0.1.1

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

Source distribution (sdist)

Source distribution for PyRRA 0.1.1
File Size Uploaded Provenance Actions
pyrra-0.1.1.tar.gz 9.0 kB With provenance Details for pyrra-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 18.2 kB

Release files / pyrra-0.1.1.tar.gz

Download URL pyrra-0.1.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5f871006080e845b979a8eac3cf5ba99b0b9b4a1dd3b808badcd9fe9122769f3
BLAKE2b-256 checksum
How to use checksums
b10d0aced6f10da7579705a47e3ca13d91cdcfc40de615579c16f81bf01d2ce5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 29, 2025.

Transparency log

Release files / pyrra-0.1.1-py3-none-any.whl

Download URL pyrra-0.1.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed4e16de244c51dc4caf2dfd975ea37fee6410b6e30963cd23334e09ca2066f4
BLAKE2b-256 checksum
How to use checksums
1aac540ec0ce499b0e82157808281423c5317299eb24c14910c6a8df67216acc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 29, 2025.

Transparency log

Security for PyRRA 0.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyrra-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 29, 2025.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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