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

pseudoBulkDGE interaction term #122

Open
ynpan910 opened this issue Aug 10, 2024 · 2 comments
Open

pseudoBulkDGE interaction term #122

ynpan910 opened this issue Aug 10, 2024 · 2 comments

Comments

@ynpan910
Copy link

ynpan910 commented Aug 10, 2024

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
Copy link
Collaborator

LTLA commented Aug 10, 2024

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
Copy link
Author

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

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

No branches or pull requests

2 participants