Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: raise error when cooks outliers should have been refitted but were not #48

Merged
merged 5 commits into from
Jan 13, 2023

Conversation

BorisMuzellec
Copy link
Collaborator

@BorisMuzellec BorisMuzellec commented Jan 12, 2023

This PR addresses issue #46 by raising an AssertionError if one tries to initialize a DeseqStats object from a DeseqDataSet with refit_cooks=True but whose outliers were not refit.

This is detected by checking that the DeseqDataSet has a replaced attribute.

A corresponding pytest was also added.

Closes #46.

…ed DeseqDataSet has "refit_cooks" set to True but Cooks outlier were not refitted
…ing a DeseqStats object from a DeseqDataSet object whose Cooks outliers were not refitted but should have been
@BorisMuzellec BorisMuzellec added the bug Something isn't working label Jan 12, 2023
Comment on lines 197 to 201
assert hasattr(dds, "replaced"), (
"dds has 'refit_cooks' set to True but Cooks outliers have not been "
"refitted. Please run 'dds.refit()' first or set 'dds.refit_cooks' "
"to False."
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an AssertionError, what about raising an AttributeError? Otherwise LGTM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, an AttributeError might be more appropriate indeed

@BorisMuzellec BorisMuzellec requested a review from a user January 13, 2023 13:02
Copy link
Collaborator

@maikia maikia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
if in the description of the PR you use: closes #issue_number the issue will automatically be closed when the PR is merged ( there are other possible keywords: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue )

tests/test_edge_cases.py Outdated Show resolved Hide resolved
@BorisMuzellec
Copy link
Collaborator Author

if in the description of the PR you use: closes #issue_number the issue will automatically be closed when the PR is merged ( there are other possible keywords: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue )

Thanks, I didn't know we could do that :)

@BorisMuzellec BorisMuzellec merged commit ca2fda5 into main Jan 13, 2023
@BorisMuzellec BorisMuzellec deleted the cooks_not_refit_warning branch January 13, 2023 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wald-test error if no Cook distance refit is performed
2 participants