Skip to content

Commit a9025cf

Browse files
committed
add python
1 parent 525b29d commit a9025cf

5 files changed

Lines changed: 865 additions & 6 deletions

File tree

README.Rmd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ knitr::opts_chunk$set(
3030

3131
> **To cite `markeR` please use:**
3232
>
33-
> Martins-Silva R, Kaizeler A, Barbosa-Morais N (2025). _markeR: an R Toolkit for Evaluating Gene Sets as Phenotypic Markers_. Gulbenkian Institute for Molecular Medicine, Faculdade de Medicina, Universidade de Lisboa, Lisbon, Portugal. R package version 1.0.0, https://github.com/DiseaseTranscriptomicsLab/markeR.
33+
> Martins-Silva R, Kaizeler A, Barbosa-Morais NL (2025). _markeR: An R Toolkit for Evaluating Gene Signatures as Phenotypic Markers_. doi:10.18129/B9.bioc.markeR, R package version 1.1.0, https://bioconductor.org/packages/markeR.
3434
3535
The folder `inst/Paper/` is in the **paper** branch and contains all scripts and materials used in the original `markeR` paper to reproduce analyses and figures. You can browse it [here](https://github.com/DiseaseTranscriptomicsLab/markeR/tree/paper/inst/Paper).
3636

@@ -52,6 +52,7 @@ The folder `inst/Paper/` is in the **paper** branch and contains all scripts and
5252
- [4. Visualisation and Evaluation](#4-visualisation-and-evaluation)
5353
- [5. Individual Gene Exploration (Optional)](#5-individual-gene-exploration-optional)
5454
- [6. Compare with Reference Gene Sets (Optional)](#6-compare-with-reference-gene-sets-optional)
55+
- [Python Bridge](#python-bridge)
5556
- [Contact](#contact)
5657

5758

@@ -237,6 +238,16 @@ the ratio of the number of genes in common over the total number of genes in the
237238

238239
Filters can be applied based on similarity thresholds (e.g., minimum Jaccard, OR, or Fisher's test p-value).
239240

241+
## Python Bridge
242+
243+
For users who prefer Python, a lightweight bridge is available in
244+
`inst/python/` that allows calling any `markeR` function from a Python
245+
environment via [`rpy2`](https://rpy2.github.io/). It includes a tutorial
246+
workflow script and a generic command-line wrapper. See
247+
[`inst/python/README.md`](inst/python/README.md) for installation
248+
instructions and usage examples.
249+
250+
240251
## Contact
241252

242253
📩 For any questions or concerns, feel free to reach out:

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ across experimental and clinical phenotypes.
2424

2525
> **To cite `markeR` please use:**
2626
>
27-
> Martins-Silva R, Kaizeler A, Barbosa-Morais N (2025). *markeR: an R
28-
> Toolkit for Evaluating Gene Sets as Phenotypic Markers*. Gulbenkian
29-
> Institute for Molecular Medicine, Faculdade de Medicina, Universidade
30-
> de Lisboa, Lisbon, Portugal. R package version 1.0.0,
31-
> <https://github.com/DiseaseTranscriptomicsLab/markeR>.
27+
> Martins-Silva R, Kaizeler A, Barbosa-Morais NL (2025). *markeR: An R
28+
> Toolkit for Evaluating Gene Signatures as Phenotypic Markers*.
29+
> <doi:10.18129/B9.bioc.markeR>, R package version 1.0.0,
30+
> <https://bioconductor.org/packages/markeR>.
3231
3332
The folder `inst/Paper/` is in the **paper** branch and contains all
3433
scripts and materials used in the original `markeR` paper to reproduce
@@ -54,6 +53,7 @@ analyses and figures. You can browse it
5453
(Optional)](#5-individual-gene-exploration-optional)
5554
- [6. Compare with Reference Gene Sets
5655
(Optional)](#6-compare-with-reference-gene-sets-optional)
56+
- [Python Bridge](#python-bridge)
5757
- [Contact](#contact)
5858

5959
## Installation
@@ -285,6 +285,15 @@ metrics are implemented:
285285
Filters can be applied based on similarity thresholds (e.g., minimum
286286
Jaccard, OR, or Fisher’s test p-value).
287287

288+
## Python Bridge
289+
290+
For users who prefer Python, a lightweight bridge is available in
291+
`inst/python/` that allows calling any `markeR` function from a Python
292+
environment via [`rpy2`](https://rpy2.github.io/). It includes a
293+
tutorial workflow script and a generic command-line wrapper. See
294+
[`inst/python/README.md`](inst/python/README.md) for installation
295+
instructions and usage examples.
296+
288297
## Contact
289298

290299
📩 For any questions or concerns, feel free to reach out:

inst/python/README.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# markeR Python Bridge
2+
3+
This workspace provides two simple Python helpers for using the
4+
Bioconductor R package **markeR** via `rpy2`.
5+
6+
- `markeR_to_python.py` provides a minimal example workflow
7+
demonstrating how to load the example data and call a specific
8+
function, serving as a template for users who wish to structure
9+
their own analysis script in Python.
10+
- `run_marker_function.py` is a generic command‑line wrapper that can
11+
invoke *any* function exported by the markeR package.
12+
13+
## Prerequisites
14+
15+
* R (>=.4.5) installed and on your `PATH`.
16+
* A Python virtual environment. Install dependencies with:
17+
18+
```bash
19+
python -m venv .venv
20+
source .venv/bin/activate
21+
pip install -r requirements.txt
22+
```
23+
24+
## Quick start
25+
26+
### 1. Run the tutorial workflow
27+
28+
```bash
29+
python markeR_to_python.py --tutorial --output tutorial.png
30+
open tutorial.png
31+
```
32+
33+
This executes an example from the markeR vignette; consult the
34+
original R tutorial (link below) for a step‑by‑step description of each
35+
analysis step.
36+
37+
### 2. Call any markeR function
38+
39+
```bash
40+
python run_marker_function.py PlotScores \
41+
--data counts_example \
42+
--metadata metadata_example \
43+
--gene_sets genesets_example \
44+
--Variable "Condition" \
45+
--method logmedian \
46+
--nrow 1 \
47+
--output my_plot.png
48+
```
49+
50+
All parameters are passed as `--name value` pairs. Use `--help-function` or
51+
refer to the online reference manual for argument names. The two scripts
52+
are described briefly below.
53+
54+
---
55+
56+
## Tutorial script (`markeR_to_python.py`)
57+
58+
A minimal Python example illustrating how to call markeR from within a Python
59+
environment. It loads the example datasets, runs a selected function, and
60+
generates a corresponding plot. The script is intended as a template for users
61+
who wish to structure and extend their own analysis workflows in Python.
62+
63+
```bash
64+
python markeR_to_python.py --tutorial [--output file.png]
65+
```
66+
67+
---
68+
69+
## Flexible CLI caller (`run_marker_function.py`)
70+
71+
This wrapper constructs and executes R code on the fly, so you can run any
72+
markeR function without _writing_ R. It handles type conversion, data
73+
loading and optional PNG output.
74+
75+
Basic syntax:
76+
77+
```bash
78+
python run_marker_function.py FUNCTION_NAME [OPTIONS]
79+
```
80+
81+
Useful options:
82+
83+
* `--param value` – named argument for the R function
84+
* `--output filename.png` – capture plot output
85+
* `--width` / `--height` – PNG dimensions (pixels; default 800×600)
86+
* `--help-function` – show documentation link/usage hint
87+
* `--verbose` – display generated R code prior to execution
88+
89+
Example (scores only, no plot):
90+
91+
```bash
92+
python run_marker_function.py CalculateScores \
93+
--data counts_example \
94+
--metadata metadata_example \
95+
--gene_sets genesets_example \
96+
--method logmedian
97+
```
98+
99+
Example saving a plot to PNG (with custom dimensions):
100+
101+
```bash
102+
python run_marker_function.py PlotScores \
103+
--data counts_example \
104+
--metadata metadata_example \
105+
--gene_sets genesets_example \
106+
--Variable "Condition" \
107+
--method logmedian \
108+
--nrow 1 \
109+
--width 800 \
110+
--height 400 \
111+
--output my_plot.png
112+
```
113+
---
114+
115+
## Built‑in example data
116+
117+
`counts_example`, `metadata_example` and `genesets_example` are loaded
118+
automatically and mirror the objects used in the tutorial. They let you
119+
try commands without supplying your own datasets.
120+
121+
---
122+
123+
## Tips & troubleshooting
124+
125+
* Add `--verbose` to see the exact R code being run – handy when a
126+
parameter doesn’t behave as expected.
127+
* If `--output` fails, check write permissions and ensure the directory
128+
exists.
129+
* Installation problems usually indicate R is missing; make sure `R` is
130+
on your path before installing Python dependencies.
131+
132+
---
133+
134+
## References
135+
136+
* [markeR on Bioconductor](https://bioconductor.org/packages/markeR)
137+
* [Official R tutorial](https://diseasetranscriptomicslab.github.io/markeR/articles/Article_BenchmarkingMode.html)
138+
* [Reference manual](https://diseasetranscriptomicslab.github.io/markeR/reference/)
139+
* Paper: https://www.biorxiv.org/content/10.64898/2025.12.05.692517
140+
141+
---
142+
143+
*Notes:* scripts install markeR via BiocManager if it’s not already present.
144+
Warnings from `ggplot2` (e.g. about `aes_string()`) are harmless and come
145+
from the package itself.

0 commit comments

Comments
 (0)