phipsonlab / speckle

R package for analysing single cell data
GNU General Public License v3.0
48 stars 6 forks source link

Error (promise already under evaluation) when using propeller.ttest #4

Closed xinyixinyijiang closed 1 year ago

xinyixinyijiang commented 1 year ago

Hi,

Thank you for your package!

I got an error when running propeller.ttest when setting the sex information as covariate. These are the versions of packages I used

[1] limma_3.54.1                speckle_0.99.7

Here are my 8 samples: four samples (2Female, 2Male) each for two genotypes. I want to test whether cell proportions differ significantly between genotypes taking sex as a covariate.

#sample genotype sex
2 mut F
2 mut M
2 wt F
2 wt M

Here are my codes:

props <- getTransformedProps(
  seurat_obj$seurat_clusters,
  seurat_obj$sample_id,
  transform="logit")

samples <- read.csv('../GRCm39/samples.csv')
group <- samples$genotype
sex <- samples$sex
design <- model.matrix(~0+group+sex)
mycontr <- makeContrasts(grouphom-groupWT, levels=design)

propeller.ttest(
  prop.list = props,
  design = design,
  contrasts = mycontr,
  sort=TRUE)

And got an error for propeller.ttest:

Error in eBayes(fit.cont, robust = robust, trend = trend) :
promise already under evaluation: recursive default argument reference or earlier problems?

This is my design, contr, and str(props):

> design
  grouphom groupWT sexM
1        1       0    1
2        0       1    1
3        1       0    0
4        1       0    1
5        0       1    1
6        1       0    0
7        0       1    0
8        0       1    0
attr(,"assign")
[1] 1 1 2
attr(,"contrasts")
attr(,"contrasts")$group
[1] "contr.treatment"

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

> mycontr
          Contrasts
Levels     grouphom - groupWT
  grouphom                  1
  groupWT                  -1
  sexM                      0

> str(props)
List of 3
 $ Counts          : 'table' int [1:14, 1:8] 2281 8 66 129 138 95 26 36 4 8 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ clusters: chr [1:14] "0" "1" "2" "3" ...
  .. ..$ sample  : chr [1:8] "1" "2" "3" "4" ...
 $ TransformedProps: 'table' num [1:14, 1:8] 1.37 -5.82 -3.74 -3.05 -2.98 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ clusters: chr [1:14] "0" "1" "2" "3" ...
  .. ..$ sample  : chr [1:8] "1" "2" "3" "4" ...
 $ Proportions     : 'table' num [1:14, 1:8] 0.7995 0.0028 0.0231 0.0452 0.0484 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ clusters: chr [1:14] "0" "1" "2" "3" ...
  .. ..$ sample  : chr [1:8] "1" "2" "3" "4" ...

Do you have any idea how to fix this? Thank you very much!

basedank commented 1 year ago

I actually got around this error. You have to specify the arguments: robust, trend, and sort.

For example, here what I run that works:

prop.test.bc <- propeller.ttest(prop.list = bcprops, 
                             design = mydesignbc, 
                             contrasts = mycontrbc,
                             robust=TRUE,
                             trend=FALSE,
                             sort=TRUE)
xinyixinyijiang commented 1 year ago

Thanks a lot. This works for me as well.