Skip to content

Fix AttributeError when design is a DataFrame#443

Merged
grst merged 1 commit intoscverse:mainfrom
Ekin-Kahraman:fix/dataframe-design-attributeerror
Apr 21, 2026
Merged

Fix AttributeError when design is a DataFrame#443
grst merged 1 commit intoscverse:mainfrom
Ekin-Kahraman:fix/dataframe-design-attributeerror

Conversation

@Ekin-Kahraman
Copy link
Copy Markdown
Contributor

Fixes #440.

When DeseqDataSet is created with a precomputed design matrix (DataFrame) instead of a formula string, cond() and contrast() raise a confusing AttributeError: 'DeseqDataSet' object has no attribute 'formulaic_contrasts'.

Added try/except guards with clear error messages directing users to pass contrast vectors directly. Follows the same pattern already used for the variables property (line 341-347).

When DeseqDataSet is created with a precomputed design matrix (DataFrame)
instead of a formula string, cond() and contrast() raise a confusing
AttributeError because formulaic_contrasts is never set.

Added guard with a clear error message directing users to pass contrast
vectors directly, matching the existing pattern used for the variables
property.

Fixes scverse#440.
@Ekin-Kahraman Ekin-Kahraman force-pushed the fix/dataframe-design-attributeerror branch from a8012f7 to e7f7366 Compare April 21, 2026 12:16
@grst grst merged commit 3d1c262 into scverse:main Apr 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DeseqStats fails with AttributeError when design is a pandas DataFrame

2 participants