Describe the bug
When passing a pandas DataFrame (a precomputed design matrix) directly to the design argument of DeseqDataSet, an AttributeError is raised later when creating a DeseqStats object.
Specifically, DeseqStats fails with:
AttributeError: 'DeseqDataSet' object has no attribute 'formulaic_contrasts'
This does not occur when design is provided as a formula string.
To Reproduce
from pydeseq2.utils import load_example_data
from pydeseq2.default_inference import DefaultInference
from formulaic_contrasts import FormulaicContrasts
from pydeseq2.dds import DeseqDataSet
from pydeseq2.ds import DeseqStats
counts_df = load_example_data(
modality="raw_counts",
dataset="synthetic",
debug=False,
)
metadata = load_example_data(
modality="metadata",
dataset="synthetic",
debug=False,
)
inference = DefaultInference(n_cpus=8)
design = FormulaicContrasts(
metadata, '~ C(condition, contr.treatment(base="B"))'
).design_matrix
dds = DeseqDataSet(
counts=counts_df,
metadata=metadata,
design=design,
refit_cooks=True,
inference=inference,
)
dds.deseq2()
ds = DeseqStats(dds, contrast=["condition", "B", "A"], inference=inference)
This raises:
AttributeError: 'DeseqDataSet' object has no attribute 'formulaic_contrasts'
pydeseq2 version: 0.5.4
Expected behavior
Either:
- Passing a design matrix directly should be fully supported, and
DeseqStats should work without error, or
- A clear and explicit error should be raised earlier, indicating that
design must be a formula string (or that additional information such as contrasts is required).
Screenshots
Desktop (please complete the following information):
Describe the bug
When passing a pandas DataFrame (a precomputed design matrix) directly to the
designargument ofDeseqDataSet, anAttributeErroris raised later when creating aDeseqStatsobject.Specifically,
DeseqStatsfails with:This does not occur when
designis provided as a formula string.To Reproduce
This raises:
pydeseq2 version: 0.5.4
Expected behavior
Either:
DeseqStatsshould work without error, ordesignmust be a formula string (or that additional information such as contrasts is required).Screenshots
Desktop (please complete the following information):