MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
40 stars 22 forks source link

pseudoBulkDGE interaction term #122

Open ynpan910 opened 1 month ago

ynpan910 commented 1 month ago

Hello,

I'm doing DEG using the pseudoBulkDGE() function. I would like to test the interaction effect of sex * condition. Specifically the contrast of these three:

Disease.Female - Healthy.Female Disease.Male - Healthy.Male (Disease.Female-Healthy.Female)-(Disease.Male-Healthy.Male)

The output is like this:

Picture1

I wonder the pvalue is for which comparison? And how to get the pvalues for each comparison? Thanks a lot for any help!

My code:

library(scran) library(limma) library(edgeR)

sce<- SingleCellExperiment(assays=list(counts=rawcount), colData=metadata) groups<- colData(sce)[, c('cell_type_me', 'individualID')] summed<- aggregateAcrossCells(sce, groups)

colData(summed)$TS<- paste(colData(summed)$condition, colData(summed)$msex, sep='.') colData(summed)$TS<- factor(colData(summed)$TS, levels=c('Healthy.Male', 'Healthy.Female', 'Disease.Male', 'Disease.Female'))

design<- model.matrix(~0+TS+genotype+ncells+educ)

contr.matrix<- makeContrasts( DiseasevsHealthyinF=(TSDisease.Female-TSHealthy.Female), DiseasevsHealthyinM=(TSDisease.Male-TSHealthy.Male), Diff=(TSDisease.Female-TSHealthy.Female)-(TSDisease.Male-TSHealthy.Male), levels = colnames(design))

de.results<- pseudoBulkDGE(summed, label=summed$cell_type_me, design=~0+TS+genotype+ncells+educ, condition=summed$TS, contrast=contr.matrix)

results<- de.results[['celltypeA']] results<- as.data.frame(results) results<- results %>% arrange(PValue)

LTLA commented 1 month ago

It's for all of them at once.

pseudoBulkDGE() is just a thin wrapper around edgeR (or voom, depending on which option you picked). If you supply a contrast matrix to either of these frameworks, the null hypothesis is that all of the individual contrasts in the columns are true. In your case, the null would be that there is no disease effect in males AND there is no disease effect in females AND there is no interaction effect... though the last one is implied by the first two anyway.

It is likely that you just want to test one of them at a time, so just call pseudoBulkDGE() separately. With sorted=FALSE, you can easily just assemble a DataFrame with the columns you want from the output of all the calls.

ynpan910 commented 1 month ago

Thank you so much, Dr. Lun for the education. Really helpful. 😊