Skip to content
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ reComBat is a PyPI package which can be installed via `pip`:
pip install reComBat
```

The project supports Python 3.10 through Python 3.13.

You can also clone the repository and install it locally via [Poetry](https://python-poetry.org/) by executing
```bash
poetry install
Expand Down
1,049 changes: 829 additions & 220 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ include = ["LICENSE"]
packages = [{ include="reComBat", from="." }]

[tool.poetry.dependencies]
python = ">=3.8,<3.11"
numpy = "^1.20.0"
sklearn = "^0.0"
tqdm = "^4.62.3"
fire = "^0.4.0"
pandas = "^1.3.4"

[tool.poetry.dev-dependencies]
python = ">=3.10,<3.14"
numpy = ">=2.2.3,<3.0"
scikit-learn = ">=1.5.2,<2.0"
joblib = ">=1.4.2,<2.0"
tqdm = ">=4.62.3,<5.0"
fire = ">=0.7.1,<1.0"
pandas = ">=2.2.3,<4.0"

[tool.poetry.group.dev.dependencies]
pytest = ">=8.3.5,<9.0"

[tool.poetry.scripts]
reComBat = "reComBat.cli:main"
Expand Down
2 changes: 1 addition & 1 deletion reComBat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# from __future__ import absolute_import
from .reComBat import reComBat

__version__ = '0.1.0'
__version__ = "0.1.4"
2 changes: 1 addition & 1 deletion reComBat/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run_recombat(data_file,

# Read in the data and batch files.
data = pd.read_csv(os.path.join(data_path,data_file),index_col=0)
batch = pd.read_csv(os.path.join(data_path,batch_file),index_col=0,squeeze=True)
batch = pd.read_csv(os.path.join(data_path,batch_file),index_col=0).squeeze("columns")

# Read in potential design matrices.
if X_file is not None:
Expand Down
60 changes: 60 additions & 0 deletions tests/test_python313_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import pandas as pd

from reComBat import reComBat
from reComBat.cli import run_recombat


def test_fit_transform_smoke():
data = pd.DataFrame(
[
[1.0, 2.0, 3.0, 4.0],
[1.2, 2.5, 2.8, 4.5],
[0.8, 1.7, 3.5, 3.7],
[9.5, 10.5, 12.0, 13.5],
[10.4, 11.2, 11.4, 12.8],
[8.9, 10.9, 12.6, 13.1],
],
index=["s1", "s2", "s3", "s4", "s5", "s6"],
columns=["g1", "g2", "g3", "g4"],
)
batches = pd.Series(["a", "a", "a", "b", "b", "b"], index=data.index, name="batch")

adjusted = reComBat(verbose=False).fit_transform(data, batches)

assert isinstance(adjusted, pd.DataFrame)
assert adjusted.shape == data.shape
assert adjusted.index.equals(data.index)
assert adjusted.columns.equals(data.columns)


def test_cli_reads_batch_series_and_writes_output(tmp_path):
data = pd.DataFrame(
[
[1.0, 2.0, 3.0, 4.0],
[1.2, 2.5, 2.8, 4.5],
[0.8, 1.7, 3.5, 3.7],
[9.5, 10.5, 12.0, 13.5],
[10.4, 11.2, 11.4, 12.8],
[8.9, 10.9, 12.6, 13.1],
],
index=["s1", "s2", "s3", "s4", "s5", "s6"],
columns=["g1", "g2", "g3", "g4"],
)
batches = pd.Series(["a", "a", "a", "b", "b", "b"], index=data.index, name="batch")

data.to_csv(tmp_path / "data.csv")
batches.to_frame().to_csv(tmp_path / "batches.csv")

run_recombat(
data_file="data.csv",
batch_file="batches.csv",
data_path=tmp_path,
out_path=tmp_path,
out_file="adjusted.csv",
verbose=False,
)

adjusted = pd.read_csv(tmp_path / "adjusted.csv", index_col=0)

assert adjusted.shape == data.shape
assert list(adjusted.columns) == list(data.columns)