lianos / sparrow

Take command of your set enrichment analyses.
https://lianos.github.io/sparrow/
MIT License
20 stars 1 forks source link

Assertion on contrast failed #18

Open RussBainer opened 1 year ago

RussBainer commented 1 year ago

Dear maintainer, thank you for making this delightful package. I am trying to use it to perform an enrichment analysis using fits derived from a pseudobulk analysis, and am catching an error:

sparrow::seas(gsd = gsdb, x = metadata(fits.risk[[x]])$v, 
                         design = metadata(fits.risk[[x]])$fit$design, contrast = metadata(fits.risk[[x]])$fit$contrasts[,"Risk_genotypeTRUE"], 
                         methods = c('camera', 'fgsea'), feature.max.padj = 0.001)
Warning in .local(x, ...) :
  Deactivating 140 gene sets because conformation of GeneSetDb to the target creates gene sets smaller than 2 or greater than Inf

Error in calculateIndividualLogFC(x, design, contrast, treat.lfc = treat.lfc,  : 
  Assertion on 'contrast' failed: Must have length <= 4, but has length 5.
> 
> x <- 'ATL'
> metadata(fits.risk[[x]])$fit$design
   (Intercept) CohortMCD SexMale eGFR_Bx Risk_genotypeTRUE
1            1         0       1 101.727                 1
2            1         1       1  23.285                 1
3            1         0       0 107.653                 0
4            1         1       0  78.557                 0
5            1         0       1  68.520                 1
6            1         0       0  64.046                 0
7            1         0       1  84.839                 0
8            1         1       1  61.602                 0
9            1         0       1  33.666                 0
10           1         0       1  19.367                 1
11           1         0       1  21.972                 1
12           1         1       0  80.348                 0
13           1         0       1 112.467                 0
14           1         0       1  57.139                 1
15           1         1       1 149.864                 0
16           1         0       1 114.610                 1
17           1         1       0  90.385                 0
18           1         0       1  79.794                 1
19           1         0       1  96.773                 0
attr(,"assign")
[1] 0 1 2 3 4
attr(,"contrasts")
attr(,"contrasts")$Cohort
[1] "contr.treatment"

attr(,"contrasts")$Sex
[1] "contr.treatment"

attr(,"contrasts")$Risk_genotype
[1] "contr.treatment"

> metadata(fits.risk[[x]])$fit$contrasts[,"Risk_genotypeTRUE"]
        Intercept         CohortMCD           SexMale           eGFR_Bx Risk_genotypeTRUE 
                0                 0                 0                 0                 1

Can you please help me understand this error message? Kindest Regards.

RussBainer commented 1 year ago

As an update, I was able to make this work if I just specified a column in design, which is thankfully an available option here.

Still curious about the error and how to deal with situations where a user needs to do "column arithmetic".