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

Model doesn't complain if a complex interaction contrast is specified that wasn't fit with the interaction in the design #693

Open
Zethson opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Zethson
Copy link
Member

Zethson commented Jan 4, 2025

Report

Raised by @emdann in #682 (comment)

The model doesn't complain if you try to specify a complex interaction contrast on a model that wasn't fit with the interaction in the design, but just throws nonsense results.

Following example from the tutorial:

# Exclude patient with progressive disease, or not full rank for interaction
pdata2 = pdata[pdata.obs['Efficacy'] != 'PD'].copy()

# Bad design definition without interaction
pds2 = pt.tl.PyDESeq2(adata=pdata2, design="~ Efficacy + Treatment")
pds2.fit()

interaction_contrast = (
    pds2.cond(Treatment="Chemo", Efficacy="PR") - pds2.cond(Treatment="Chemo", Efficacy="SD")
) - (
    pds2.cond(Treatment="Anti-PD-L1+Chemo", Efficacy="PR") - pds2.cond(Treatment="Anti-PD-L1+Chemo", Efficacy="SD")
)
res_df = pds2.test_contrasts(contrasts=interaction_contrast)

No complaint, but the results are broken:

Log2 fold change & Wald test p-value, contrast vector: [0. 0. 0.]
           baseMean  log2FoldChange  lfcSE  stat  pvalue  padj
A1BG      16.408605             0.0    0.0   NaN     NaN   NaN
A1BG-AS1   1.958737             0.0    0.0   NaN     NaN   NaN
A1CF       0.002053             0.0    0.0   NaN     NaN   NaN
A2M       30.296881             0.0    0.0   NaN     NaN   NaN
A2M-AS1    0.557092             0.0    0.0   NaN     NaN   NaN
...             ...             ...    ...   ...     ...   ...
ZXDC       6.114098             0.0    0.0   NaN     NaN   NaN
ZYG11A     0.093600             0.0    0.0   NaN     NaN   NaN
ZYG11B     3.404941             0.0    0.0   NaN     NaN   NaN
ZYX       77.175203             0.0    0.0   NaN     NaN   NaN
ZZEF1      9.752162             0.0    0.0   NaN     NaN   NaN

While results make sense if I specify the design properly pds2 = pt.tl.PyDESeq2(adata=pdata2, design="~ Efficacy + Treatment + Efficacy*Treatment").

Do we want this to happen? Can we add an informative error if the contrast vector is all zeros?

Version information

No response

@Zethson Zethson added the bug Something isn't working label Jan 4, 2025
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

No branches or pull requests

1 participant