GabrielHoffman / variancePartition

Quantify and interpret divers of variation in multilevel gene expression experiments
http://gabrielhoffman.github.io/variancePartition/
60 stars 14 forks source link

makeContrastsDream for Interaction Guidance #105

Closed abadgerw closed 2 weeks ago

abadgerw commented 2 weeks ago

@GabrielHoffman thank you for a fantastic package!

Apologies for the naivety as this is new to me but I had a question about setting contrasts using makeContrastsDream.

My first analysis was to look at the impact of various stimulation on various cell lines and I ran the following code which I believe is correct and worked:

exprdata<-read.csv("Replicates Merged.csv", row.names=1)
metadata<-read.csv("Metadata.csv",row.names=1)
metadata$ID<-as.factor(metadata$ID)
precursors<-read.csv("Counts.csv",row.names=1)

form <- ~ 0 + Stim + (1 | ID)

compare <- makeContrastsDream(form, metadata, contrasts = c(compare3_1 = "StimFib - StimCon", compare3_2 = "StimFib - StimPDL", compare2_1 = "StimPDL - StimCon"))

fit <- dream(exprdata, form, metadata, compare, ddf = "Kenward-Roger")
fit2 <- variancePartition::eBayes(fit, robust=T, trend=log(precursors$Counts))

FibxCon<-variancePartition::topTable(fit, coef = "compare3_1", number=3469)
FibxPDL<-variancePartition::topTable(fit, coef = "compare3_2", number=3469)
PDLxCon<-variancePartition::topTable(fit, coef = "compare2_1", number=3469)

Of note, each cell line was plated in triplicate before stimulation. I merged the triplicates via median before running the model. Would it be better to keep the triplicates separate?

In addition, to take this further I wanted to assess the interaction of stimulation with a certain genotype. I am particularly interested in the following contrasts:

  1. Differences between genotypes without stimulation (both Con HLA Pos vs Con HLA Neg and PDL HLA Pos vs PDL HLA Neg conditions)
  2. Differences between genotypes with stimulation (Fib HLA Pos vs Fib HLA Neg)

Therefore, I planned to run an interaction model like this:

form <- ~ 0 + HLA*Stim + (1 | ID)

However, I am stuck on how to setup contrasts for this more complex model. I've attached my metadata file here for reference.

Metadata.csv

Any insight into the call I can make to makeContrastsDream for this interaction analysis? I looked at the example you provided here on GitHub for making contrasts but didn't see an example with an interaction to follow.

Thanks for your help!

abadgerw commented 2 weeks ago

Closed as I figured bioconductor would be a better place to discuss.