Skip to content

Commit 2440581

Browse files
Merge pull request #18 from OpenMS/copilot/add-experimentaldesign-support
Add Py_ExperimentalDesign wrapper with pandas DataFrame and file storage support
2 parents 18ba9fd + f9cb0dc commit 2440581

File tree

6 files changed

+861
-1
lines changed

6 files changed

+861
-1
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,56 @@ search engine can be when built with the high-level helpers in
189189
`openms_python`. Reuse the test as inspiration for bespoke pipelines or as a
190190
regression harness when experimenting with search-related utilities.
191191

192+
## Experimental design support
193+
194+
Managing multi-sample, multi-fraction experiments? The `Py_ExperimentalDesign`
195+
wrapper makes it straightforward to work with OpenMS experimental design files
196+
that describe sample layouts, fractionation schemes, and labeling strategies.
197+
`tests/test_py_experimentaldesign.py` provides comprehensive examples of loading
198+
and querying experimental designs, including support for fractionated workflows,
199+
label-free and labeled quantitation setups, and integration with feature maps,
200+
consensus maps, and identification results. The wrapper exposes Pythonic
201+
properties for quick access to sample counts, fraction information, and design
202+
summaries—perfect for building sample-aware quantitation pipelines or validating
203+
experimental metadata before analysis.
204+
205+
```python
206+
from openms_python import Py_ExperimentalDesign
207+
import pandas as pd
208+
209+
# Load an experimental design from a TSV file
210+
design = Py_ExperimentalDesign.from_file("design.tsv")
211+
212+
# Quick access to design properties
213+
print(f"Samples: {design.n_samples}")
214+
print(f"MS files: {design.n_ms_files}")
215+
print(f"Fractionated: {design.is_fractionated}")
216+
217+
# Get a summary
218+
design.print_summary()
219+
220+
# Convert to pandas DataFrame for analysis
221+
df = design.to_dataframe()
222+
223+
# Create from a pandas DataFrame
224+
df = pd.DataFrame({
225+
'Fraction_Group': [1, 1, 2, 2],
226+
'Fraction': [1, 2, 1, 2],
227+
'Spectra_Filepath': ['f1.mzML', 'f2.mzML', 'f3.mzML', 'f4.mzML'],
228+
'Label': [1, 1, 1, 1],
229+
'Sample': [1, 1, 2, 2]
230+
})
231+
design = Py_ExperimentalDesign.from_dataframe(df)
232+
233+
# Store to file
234+
design.store("output_design.tsv")
235+
236+
# Create from existing OpenMS objects
237+
from openms_python import Py_ConsensusMap
238+
consensus = Py_ConsensusMap.from_file("results.consensusXML")
239+
design = Py_ExperimentalDesign.from_consensus_map(consensus)
240+
```
241+
192242
### Iterate over containers and metadata
193243

194244
All sequence-like wrappers (feature maps, consensus maps, identification containers,

openms_python/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .py_feature import Py_Feature
2727
from .py_featuremap import Py_FeatureMap
2828
from .py_consensusmap import Py_ConsensusMap
29+
from .py_experimentaldesign import Py_ExperimentalDesign
2930
from .py_identifications import (
3031
ProteinIdentifications,
3132
PeptideIdentifications,
@@ -101,6 +102,7 @@ def get_example(name: str, *, load: bool = False, target_dir: Union[str, Path, N
101102
"Py_Feature",
102103
"Py_FeatureMap",
103104
"Py_ConsensusMap",
105+
"Py_ExperimentalDesign",
104106
"ProteinIdentifications",
105107
"PeptideIdentifications",
106108
"Identifications",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Fraction_Group Fraction Spectra_Filepath Label Sample
2+
1 1 sample1_fraction1.mzML 1 1
3+
1 2 sample1_fraction2.mzML 1 1
4+
1 3 sample1_fraction3.mzML 1 1
5+
2 1 sample2_fraction1.mzML 1 2
6+
2 2 sample2_fraction2.mzML 1 2
7+
2 3 sample2_fraction3.mzML 1 2

0 commit comments

Comments
 (0)