Skip to content

BUG fix slogdet bug#110

Merged
BorisMuzellec merged 3 commits intomainfrom
fix_slogdet_bug
Apr 6, 2023
Merged

BUG fix slogdet bug#110
BorisMuzellec merged 3 commits intomainfrom
fix_slogdet_bug

Conversation

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

What does your PR implement? Be specific.

This PR fixes bugs when using pydeseq2 with pandas 2.0.

Code to reproduce the issue

First bug
counts_df = load_example_data(
    modality="raw_counts",
    dataset="synthetic",
    debug=False,
)

clinical_df = load_example_data(
    modality="clinical",
    dataset="synthetic",
    debug=False,
)


dds = DeseqDataSet(
    counts=counts_df,
    clinical=clinical_df,
    refit_cooks=True,
    design_factors="condition",
)

dds.deseq2()

would output

Fitting size factors...
... done in 0.00 seconds.

Fitting dispersions...

UFuncTypeError: Cannot cast ufunc 'slogdet' input from dtype('O') to dtype('float64') with casting rule 'same_kind'
Second bug

After fixing the first bug, DeseqDataSet.refit() would throw anndata.ImplicitModificationWarnings, making the tests fail.

Fix

The first bug is caused by pydeseq2.utils.build_design_matrix outputting boolean columns with pandas API changes. This PR fixes it by casting the design matrix to int, which is compatible with older versions of pandas.

The second bug arrises when copying anndata objects with empty indexes. This PR fixes it by checking that indexes are non-empty prior to copying.

@BorisMuzellec BorisMuzellec requested a review from a user April 5, 2023 09:31
Copy link
Copy Markdown
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, thanks

pydeseq2/dds.py Outdated
# Only replace if genes are not all zeroes after outlier replacement
to_replace[to_replace] = ~new_all_zeroes

print(to_replace)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, you caught me red-handed doing print debugging :)

@BorisMuzellec BorisMuzellec merged commit 10ba823 into main Apr 6, 2023
@BorisMuzellec BorisMuzellec deleted the fix_slogdet_bug branch April 6, 2023 08:27
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.

2 participants