maxcombat 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of maxcombat might be problematic. Click here for more details.
- {maxcombat-0.2.2/src/maxcombat.egg-info → maxcombat-0.2.3}/PKG-INFO +49 -48
- {maxcombat-0.2.2 → maxcombat-0.2.3}/README.md +48 -47
- {maxcombat-0.2.2 → maxcombat-0.2.3}/pyproject.toml +6 -1
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat/__init__.py +1 -1
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat/cli.py +14 -4
- {maxcombat-0.2.2 → maxcombat-0.2.3/src/maxcombat.egg-info}/PKG-INFO +49 -48
- {maxcombat-0.2.2 → maxcombat-0.2.3}/tests/test_cli.py +5 -3
- {maxcombat-0.2.2 → maxcombat-0.2.3}/LICENSE +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/setup.cfg +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat/core.py +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat/utils.py +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat.egg-info/SOURCES.txt +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat.egg-info/dependency_links.txt +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat.egg-info/entry_points.txt +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat.egg-info/requires.txt +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/src/maxcombat.egg-info/top_level.txt +0 -0
- {maxcombat-0.2.2 → maxcombat-0.2.3}/tests/test_tutorial_data.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maxcombat
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Scalable batch-effect correction based on reComBat
|
|
5
5
|
Author: Olivier Coen
|
|
6
6
|
License: MIT
|
|
@@ -36,9 +36,9 @@ Dynamic: license-file
|
|
|
36
36
|
|
|
37
37
|
Scalable batch-effect correction based on [reComBat](https://github.com/BorgwardtLab/reComBat) (Michael F. Adamer, BSD-3-Clause).
|
|
38
38
|
|
|
39
|
-
This package is
|
|
39
|
+
This package is intended as a replacement for `reComBat`, whenever users require a high level of scalability.
|
|
40
40
|
|
|
41
|
-
It was originally developed for [nf-core/stableexpression](https://nf-co.re/stableexpression/).
|
|
41
|
+
It was originally developed for [nf-core/stableexpression](https://nf-co.re/stableexpression/) to correct batch effect among a potentially very large number of expression datasets.
|
|
42
42
|
|
|
43
43
|
## Citation
|
|
44
44
|
|
|
@@ -48,54 +48,17 @@ If you use `maxcombat` for your analysis, please cite [the original reComBat pap
|
|
|
48
48
|
## Installation
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
pip install maxcombat
|
|
52
|
-
# or
|
|
53
51
|
conda install -c bioconda maxcombat
|
|
52
|
+
# or
|
|
53
|
+
uv add maxcombat
|
|
54
|
+
# or
|
|
55
|
+
pip install maxcombat
|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
## Usage
|
|
57
59
|
|
|
58
|
-
### From Python
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```python
|
|
62
|
-
from maxcombat import MaxCombat
|
|
63
|
-
|
|
64
|
-
data = ... # (n_genes, n_samples) array
|
|
65
|
-
batches = ... # (n_samples,) array of batch labels
|
|
66
|
-
|
|
67
|
-
model = MaxCombat() # default model: elastic_net
|
|
68
|
-
model.fit(data,batches)
|
|
69
|
-
model.transform(data,batches)
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
or:
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
corrected = model.fit_transform(data, batches)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Optional: with covariates and / or a reference batch:
|
|
79
|
-
```python
|
|
80
|
-
preserved_covariates = ... # (n_samples, k) covariates to be considered during batch effect correction: the biological signal that must be preserved
|
|
81
|
-
dropped_covariates = ... # (n_samples, k) covariates to be ignored during batch effect correction (batch-related confounders)
|
|
82
|
-
|
|
83
|
-
model = MaxCombat(model="elastic_net", reference_batch="batch_1")
|
|
84
|
-
corrected = model.fit_transform(data, batches, preserved_covariates, dropped_covariates)
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Categorical covariates must be one-hot encoded beforehand
|
|
88
|
-
(e.g. sklearn.preprocessing.OneHotEncoder(drop="first")); numerical
|
|
89
|
-
covariates are passed as is.
|
|
90
|
-
|
|
91
|
-
Non-parametric empirical Bayes (leave-one-out, more expensive):
|
|
92
|
-
```python
|
|
93
|
-
model = MaxCombat(parametric=False, model="linear", n_jobs=8)
|
|
94
|
-
```
|
|
95
|
-
|
|
96
60
|
### From the command line
|
|
97
61
|
|
|
98
|
-
|
|
99
62
|
```bash
|
|
100
63
|
maxcombat \
|
|
101
64
|
--counts counts.parquet \
|
|
@@ -187,7 +150,46 @@ sample_E,6.9
|
|
|
187
150
|
|
|
188
151
|
`--clip-negative-values`: clip negative values to 0 after correction (useful for specific downstream analyses requiring only positive values)
|
|
189
152
|
|
|
190
|
-
`--out-
|
|
153
|
+
`--out-float32`: convert corrected data to float32 before export (useful for very large datasets)
|
|
154
|
+
|
|
155
|
+
`--out-ndigits`: round corrected data to `n` decimal digits before export (useful for very large datasets)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
### Import as a Python package
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from maxcombat import MaxCombat
|
|
162
|
+
|
|
163
|
+
data = ... # (n_genes, n_samples) array
|
|
164
|
+
batches = ... # (n_samples,) array of batch labels
|
|
165
|
+
|
|
166
|
+
model = MaxCombat() # default model: elastic_net
|
|
167
|
+
model.fit(data,batches)
|
|
168
|
+
model.transform(data,batches)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
or:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
corrected = model.fit_transform(data, batches)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Optional: with covariates and / or a reference batch:
|
|
178
|
+
```python
|
|
179
|
+
preserved_covariates = ... # (n_samples, k) covariates to be considered during batch effect correction: the biological signal that must be preserved
|
|
180
|
+
dropped_covariates = ... # (n_samples, k) covariates to be ignored during batch effect correction (batch-related confounders)
|
|
181
|
+
|
|
182
|
+
model = MaxCombat(model="elastic_net", reference_batch="batch_1")
|
|
183
|
+
corrected = model.fit_transform(data, batches, preserved_covariates, dropped_covariates)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
> [!NOTE]
|
|
187
|
+
> Categorical covariates must be one-hot encoded beforehand (e.g. sklearn.preprocessing.OneHotEncoder(drop="first")); numerical covariates are passed as is.
|
|
188
|
+
|
|
189
|
+
Non-parametric empirical Bayes (leave-one-out, more expensive):
|
|
190
|
+
```python
|
|
191
|
+
model = MaxCombat(parametric=False, model="linear", n_jobs=8)
|
|
192
|
+
```
|
|
191
193
|
|
|
192
194
|
## Feature improvement over `reComBat`
|
|
193
195
|
|
|
@@ -195,9 +197,8 @@ sample_E,6.9
|
|
|
195
197
|
- Genes as rows, samples as columns (the usual omics convention, unlike reComBat)
|
|
196
198
|
- Automatic removal of orphan samples (samples alone in their batch)
|
|
197
199
|
- Optional clipping of negative output values (safety net for count data)
|
|
198
|
-
-
|
|
199
|
-
-
|
|
200
|
-
- Possibility to export data in `float32`, to reduce to memory footprint when dealing with a very large dataset
|
|
200
|
+
- [CLI]: Automatic detection of input and output file extension (`parquet` / `csv` / `tsv`)
|
|
201
|
+
- [CLI]: Possibility to export data in `float32` and / or to reduce the number of decimal digits, to reduce to memory footprint when dealing with a very large dataset
|
|
201
202
|
|
|
202
203
|
## License
|
|
203
204
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
Scalable batch-effect correction based on [reComBat](https://github.com/BorgwardtLab/reComBat) (Michael F. Adamer, BSD-3-Clause).
|
|
7
7
|
|
|
8
|
-
This package is
|
|
8
|
+
This package is intended as a replacement for `reComBat`, whenever users require a high level of scalability.
|
|
9
9
|
|
|
10
|
-
It was originally developed for [nf-core/stableexpression](https://nf-co.re/stableexpression/).
|
|
10
|
+
It was originally developed for [nf-core/stableexpression](https://nf-co.re/stableexpression/) to correct batch effect among a potentially very large number of expression datasets.
|
|
11
11
|
|
|
12
12
|
## Citation
|
|
13
13
|
|
|
@@ -17,54 +17,17 @@ If you use `maxcombat` for your analysis, please cite [the original reComBat pap
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
pip install maxcombat
|
|
21
|
-
# or
|
|
22
20
|
conda install -c bioconda maxcombat
|
|
21
|
+
# or
|
|
22
|
+
uv add maxcombat
|
|
23
|
+
# or
|
|
24
|
+
pip install maxcombat
|
|
23
25
|
```
|
|
24
26
|
|
|
25
27
|
## Usage
|
|
26
28
|
|
|
27
|
-
### From Python
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```python
|
|
31
|
-
from maxcombat import MaxCombat
|
|
32
|
-
|
|
33
|
-
data = ... # (n_genes, n_samples) array
|
|
34
|
-
batches = ... # (n_samples,) array of batch labels
|
|
35
|
-
|
|
36
|
-
model = MaxCombat() # default model: elastic_net
|
|
37
|
-
model.fit(data,batches)
|
|
38
|
-
model.transform(data,batches)
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
or:
|
|
42
|
-
|
|
43
|
-
```python
|
|
44
|
-
corrected = model.fit_transform(data, batches)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Optional: with covariates and / or a reference batch:
|
|
48
|
-
```python
|
|
49
|
-
preserved_covariates = ... # (n_samples, k) covariates to be considered during batch effect correction: the biological signal that must be preserved
|
|
50
|
-
dropped_covariates = ... # (n_samples, k) covariates to be ignored during batch effect correction (batch-related confounders)
|
|
51
|
-
|
|
52
|
-
model = MaxCombat(model="elastic_net", reference_batch="batch_1")
|
|
53
|
-
corrected = model.fit_transform(data, batches, preserved_covariates, dropped_covariates)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Categorical covariates must be one-hot encoded beforehand
|
|
57
|
-
(e.g. sklearn.preprocessing.OneHotEncoder(drop="first")); numerical
|
|
58
|
-
covariates are passed as is.
|
|
59
|
-
|
|
60
|
-
Non-parametric empirical Bayes (leave-one-out, more expensive):
|
|
61
|
-
```python
|
|
62
|
-
model = MaxCombat(parametric=False, model="linear", n_jobs=8)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
29
|
### From the command line
|
|
66
30
|
|
|
67
|
-
|
|
68
31
|
```bash
|
|
69
32
|
maxcombat \
|
|
70
33
|
--counts counts.parquet \
|
|
@@ -156,7 +119,46 @@ sample_E,6.9
|
|
|
156
119
|
|
|
157
120
|
`--clip-negative-values`: clip negative values to 0 after correction (useful for specific downstream analyses requiring only positive values)
|
|
158
121
|
|
|
159
|
-
`--out-
|
|
122
|
+
`--out-float32`: convert corrected data to float32 before export (useful for very large datasets)
|
|
123
|
+
|
|
124
|
+
`--out-ndigits`: round corrected data to `n` decimal digits before export (useful for very large datasets)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Import as a Python package
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from maxcombat import MaxCombat
|
|
131
|
+
|
|
132
|
+
data = ... # (n_genes, n_samples) array
|
|
133
|
+
batches = ... # (n_samples,) array of batch labels
|
|
134
|
+
|
|
135
|
+
model = MaxCombat() # default model: elastic_net
|
|
136
|
+
model.fit(data,batches)
|
|
137
|
+
model.transform(data,batches)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
or:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
corrected = model.fit_transform(data, batches)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Optional: with covariates and / or a reference batch:
|
|
147
|
+
```python
|
|
148
|
+
preserved_covariates = ... # (n_samples, k) covariates to be considered during batch effect correction: the biological signal that must be preserved
|
|
149
|
+
dropped_covariates = ... # (n_samples, k) covariates to be ignored during batch effect correction (batch-related confounders)
|
|
150
|
+
|
|
151
|
+
model = MaxCombat(model="elastic_net", reference_batch="batch_1")
|
|
152
|
+
corrected = model.fit_transform(data, batches, preserved_covariates, dropped_covariates)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
> [!NOTE]
|
|
156
|
+
> Categorical covariates must be one-hot encoded beforehand (e.g. sklearn.preprocessing.OneHotEncoder(drop="first")); numerical covariates are passed as is.
|
|
157
|
+
|
|
158
|
+
Non-parametric empirical Bayes (leave-one-out, more expensive):
|
|
159
|
+
```python
|
|
160
|
+
model = MaxCombat(parametric=False, model="linear", n_jobs=8)
|
|
161
|
+
```
|
|
160
162
|
|
|
161
163
|
## Feature improvement over `reComBat`
|
|
162
164
|
|
|
@@ -164,9 +166,8 @@ sample_E,6.9
|
|
|
164
166
|
- Genes as rows, samples as columns (the usual omics convention, unlike reComBat)
|
|
165
167
|
- Automatic removal of orphan samples (samples alone in their batch)
|
|
166
168
|
- Optional clipping of negative output values (safety net for count data)
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
- Possibility to export data in `float32`, to reduce to memory footprint when dealing with a very large dataset
|
|
169
|
+
- [CLI]: Automatic detection of input and output file extension (`parquet` / `csv` / `tsv`)
|
|
170
|
+
- [CLI]: Possibility to export data in `float32` and / or to reduce the number of decimal digits, to reduce to memory footprint when dealing with a very large dataset
|
|
170
171
|
|
|
171
172
|
## License
|
|
172
173
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "maxcombat"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "Scalable batch-effect correction based on reComBat"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -52,3 +52,8 @@ markers = [
|
|
|
52
52
|
"cli: cli tests, used in bioconda CI",
|
|
53
53
|
"tutorial: tests aiming at reproducing results from the original reComBat, using tutorial data"
|
|
54
54
|
]
|
|
55
|
+
|
|
56
|
+
[dependency-groups]
|
|
57
|
+
dev = [
|
|
58
|
+
"pytest>=9.2.0",
|
|
59
|
+
]
|
|
@@ -81,12 +81,16 @@ def parse_args() -> argparse.Namespace:
|
|
|
81
81
|
help="CSV with a 'sample' column plus covariates of unwanted variation (e.g. RIN, sex) other than batch (e.g. batch-related confounders).",
|
|
82
82
|
)
|
|
83
83
|
parser.add_argument(
|
|
84
|
-
"--out
|
|
84
|
+
"--out", type=Path, dest="outfile", required=True,
|
|
85
|
+
help="Output Parquet file"
|
|
86
|
+
)
|
|
87
|
+
parser.add_argument(
|
|
88
|
+
"--out-float32", action="store_true", dest="cast_output_to_float32",
|
|
85
89
|
help="Cast corrected data to float32 before export to save memory",
|
|
86
90
|
)
|
|
87
91
|
parser.add_argument(
|
|
88
|
-
"--out",
|
|
89
|
-
help="
|
|
92
|
+
"--out-ndigits", dest="nb_digits_output", type=int,
|
|
93
|
+
help="Number of digits to keep in the output. Defaults to all digits",
|
|
90
94
|
)
|
|
91
95
|
parser.add_argument(
|
|
92
96
|
"--cpus", type=int,
|
|
@@ -195,9 +199,15 @@ def main() -> None:
|
|
|
195
199
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
196
200
|
|
|
197
201
|
out_df = pl.DataFrame(corrected, schema=samples)
|
|
202
|
+
|
|
203
|
+
if args.nb_digits_output is not None:
|
|
204
|
+
logger.info(f"Rounding output to {args.nb_digits_output} digits")
|
|
205
|
+
out_df = out_df.select(pl.all().round(args.nb_digits_output))
|
|
206
|
+
|
|
198
207
|
if args.cast_output_to_float32:
|
|
208
|
+
logger.info("Casting output to float32")
|
|
199
209
|
out_df = out_df.select(pl.all().cast(pl.Float32))
|
|
200
|
-
|
|
210
|
+
|
|
201
211
|
out_df = pl.concat([gene_ids, out_df], how="horizontal")
|
|
202
212
|
|
|
203
213
|
logger.info(f"Exporting corrected counts to {args.outfile}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maxcombat
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Scalable batch-effect correction based on reComBat
|
|
5
5
|
Author: Olivier Coen
|
|
6
6
|
License: MIT
|
|
@@ -36,9 +36,9 @@ Dynamic: license-file
|
|
|
36
36
|
|
|
37
37
|
Scalable batch-effect correction based on [reComBat](https://github.com/BorgwardtLab/reComBat) (Michael F. Adamer, BSD-3-Clause).
|
|
38
38
|
|
|
39
|
-
This package is
|
|
39
|
+
This package is intended as a replacement for `reComBat`, whenever users require a high level of scalability.
|
|
40
40
|
|
|
41
|
-
It was originally developed for [nf-core/stableexpression](https://nf-co.re/stableexpression/).
|
|
41
|
+
It was originally developed for [nf-core/stableexpression](https://nf-co.re/stableexpression/) to correct batch effect among a potentially very large number of expression datasets.
|
|
42
42
|
|
|
43
43
|
## Citation
|
|
44
44
|
|
|
@@ -48,54 +48,17 @@ If you use `maxcombat` for your analysis, please cite [the original reComBat pap
|
|
|
48
48
|
## Installation
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
pip install maxcombat
|
|
52
|
-
# or
|
|
53
51
|
conda install -c bioconda maxcombat
|
|
52
|
+
# or
|
|
53
|
+
uv add maxcombat
|
|
54
|
+
# or
|
|
55
|
+
pip install maxcombat
|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
## Usage
|
|
57
59
|
|
|
58
|
-
### From Python
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```python
|
|
62
|
-
from maxcombat import MaxCombat
|
|
63
|
-
|
|
64
|
-
data = ... # (n_genes, n_samples) array
|
|
65
|
-
batches = ... # (n_samples,) array of batch labels
|
|
66
|
-
|
|
67
|
-
model = MaxCombat() # default model: elastic_net
|
|
68
|
-
model.fit(data,batches)
|
|
69
|
-
model.transform(data,batches)
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
or:
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
corrected = model.fit_transform(data, batches)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Optional: with covariates and / or a reference batch:
|
|
79
|
-
```python
|
|
80
|
-
preserved_covariates = ... # (n_samples, k) covariates to be considered during batch effect correction: the biological signal that must be preserved
|
|
81
|
-
dropped_covariates = ... # (n_samples, k) covariates to be ignored during batch effect correction (batch-related confounders)
|
|
82
|
-
|
|
83
|
-
model = MaxCombat(model="elastic_net", reference_batch="batch_1")
|
|
84
|
-
corrected = model.fit_transform(data, batches, preserved_covariates, dropped_covariates)
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Categorical covariates must be one-hot encoded beforehand
|
|
88
|
-
(e.g. sklearn.preprocessing.OneHotEncoder(drop="first")); numerical
|
|
89
|
-
covariates are passed as is.
|
|
90
|
-
|
|
91
|
-
Non-parametric empirical Bayes (leave-one-out, more expensive):
|
|
92
|
-
```python
|
|
93
|
-
model = MaxCombat(parametric=False, model="linear", n_jobs=8)
|
|
94
|
-
```
|
|
95
|
-
|
|
96
60
|
### From the command line
|
|
97
61
|
|
|
98
|
-
|
|
99
62
|
```bash
|
|
100
63
|
maxcombat \
|
|
101
64
|
--counts counts.parquet \
|
|
@@ -187,7 +150,46 @@ sample_E,6.9
|
|
|
187
150
|
|
|
188
151
|
`--clip-negative-values`: clip negative values to 0 after correction (useful for specific downstream analyses requiring only positive values)
|
|
189
152
|
|
|
190
|
-
`--out-
|
|
153
|
+
`--out-float32`: convert corrected data to float32 before export (useful for very large datasets)
|
|
154
|
+
|
|
155
|
+
`--out-ndigits`: round corrected data to `n` decimal digits before export (useful for very large datasets)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
### Import as a Python package
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from maxcombat import MaxCombat
|
|
162
|
+
|
|
163
|
+
data = ... # (n_genes, n_samples) array
|
|
164
|
+
batches = ... # (n_samples,) array of batch labels
|
|
165
|
+
|
|
166
|
+
model = MaxCombat() # default model: elastic_net
|
|
167
|
+
model.fit(data,batches)
|
|
168
|
+
model.transform(data,batches)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
or:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
corrected = model.fit_transform(data, batches)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Optional: with covariates and / or a reference batch:
|
|
178
|
+
```python
|
|
179
|
+
preserved_covariates = ... # (n_samples, k) covariates to be considered during batch effect correction: the biological signal that must be preserved
|
|
180
|
+
dropped_covariates = ... # (n_samples, k) covariates to be ignored during batch effect correction (batch-related confounders)
|
|
181
|
+
|
|
182
|
+
model = MaxCombat(model="elastic_net", reference_batch="batch_1")
|
|
183
|
+
corrected = model.fit_transform(data, batches, preserved_covariates, dropped_covariates)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
> [!NOTE]
|
|
187
|
+
> Categorical covariates must be one-hot encoded beforehand (e.g. sklearn.preprocessing.OneHotEncoder(drop="first")); numerical covariates are passed as is.
|
|
188
|
+
|
|
189
|
+
Non-parametric empirical Bayes (leave-one-out, more expensive):
|
|
190
|
+
```python
|
|
191
|
+
model = MaxCombat(parametric=False, model="linear", n_jobs=8)
|
|
192
|
+
```
|
|
191
193
|
|
|
192
194
|
## Feature improvement over `reComBat`
|
|
193
195
|
|
|
@@ -195,9 +197,8 @@ sample_E,6.9
|
|
|
195
197
|
- Genes as rows, samples as columns (the usual omics convention, unlike reComBat)
|
|
196
198
|
- Automatic removal of orphan samples (samples alone in their batch)
|
|
197
199
|
- Optional clipping of negative output values (safety net for count data)
|
|
198
|
-
-
|
|
199
|
-
-
|
|
200
|
-
- Possibility to export data in `float32`, to reduce to memory footprint when dealing with a very large dataset
|
|
200
|
+
- [CLI]: Automatic detection of input and output file extension (`parquet` / `csv` / `tsv`)
|
|
201
|
+
- [CLI]: Possibility to export data in `float32` and / or to reduce the number of decimal digits, to reduce to memory footprint when dealing with a very large dataset
|
|
201
202
|
|
|
202
203
|
## License
|
|
203
204
|
|
|
@@ -199,7 +199,7 @@ def test_cli_with_preserved_covariates(tmp_path):
|
|
|
199
199
|
"--max-iter", "100",
|
|
200
200
|
"--conv-criterion", "1e-3",
|
|
201
201
|
"--no-optimize-params",
|
|
202
|
-
"--out-
|
|
202
|
+
"--out-float32",
|
|
203
203
|
"--out", str(out),
|
|
204
204
|
)
|
|
205
205
|
assert proc.returncode == 0, f"CLI failed:\n{stderr}"
|
|
@@ -234,7 +234,8 @@ def test_cli_with_covariates_and_reference_batch(tmp_path):
|
|
|
234
234
|
"--max-iter", "100",
|
|
235
235
|
"--conv-criterion", "1e-3",
|
|
236
236
|
"--no-optimize-params",
|
|
237
|
-
"--out-
|
|
237
|
+
"--out-float32",
|
|
238
|
+
"--out-ndigits", "8",
|
|
238
239
|
"--out", str(out),
|
|
239
240
|
)
|
|
240
241
|
assert proc.returncode == 0, f"CLI failed:\n{stderr}"
|
|
@@ -258,6 +259,7 @@ def test_cli_no_parametric(tmp_path):
|
|
|
258
259
|
"--counts", str(counts),
|
|
259
260
|
"--design", str(design),
|
|
260
261
|
"--no-parametric",
|
|
261
|
-
"--out", str(out)
|
|
262
|
+
"--out", str(out),
|
|
263
|
+
"--out-ndigits", "1"
|
|
262
264
|
)
|
|
263
265
|
assert proc.returncode == 0, f"CLI failed:\n{stderr}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|