HelenaLC / muscat

Multi-sample multi-group scRNA-seq analysis tools
165 stars 33 forks source link

How to set up interactions? #99

Closed AnjaliC4 closed 2 years ago

AnjaliC4 commented 2 years ago

Hi,

I would like to analyze interaction effects. My design is: design <- model.matrix(~ 0 + group_id + COV1 + COV2 + COV3, data = data). I would like to set up contrasts in a way that I analyze the interaction of group_idCOV1. Where group_id has two levels: A & B and COV1 also have two levels: Group1 & Group2. For this purpose - I did -
design <- model.matrix(~ 0 + group_id
COV1 + group_id+ COV1 + COV2 + COV3, data = data). This results in: group_idCOV1 as one column in design matrix. While I think it should have two columns - group_id-ACOV1, group_id-BCOV1. With two columns I can set up contrast like this: contrast <-makeContrasts(Case_vs_Control = (group_id-ACOV1 - group_id-B*COV1),levels = make.names(colnanmes).

Please let me know what is the right way to set up a design and contrast matrix in my case. Thanks.

HelenaLC commented 2 years ago

I'd say this is not a muscat-specific issue, but a general question regarding how to set up the model.matrix with interaction terms... there are lots of resources out there explaining the differences between different designs (e.g., when searching for "R model matrix with interaction terms" or similar). An example with explanation is given here in section "Interactions using a two-factor model". Similar questions have also been discussed on the BiocSupport site, and another good resource is the edgeR user guide.