**180**wrote:

Hi,

I have data from 3 different conditions (normal, breast cancer, endometrial cancer) and different cell types (cd163_positive or negative) for each condition. I am interested in differentially expressed genes between conditions (e.g Breast_cancer vs Endometrial_cancer) but also between cell populations within the same condition but also across conditions (e.g Breast_cancercd163_positive-Breast_cancercd163_negative). Below is the pheno table and the code for making the contrasts.

- I am not sure how to make the (simple) contrasts : Breast_cancer vs Endometrial_cancer , Breast_cancer vs Normal, Endometrial_cancer vs Normal using the model below.
- Is the model below correct for the population comparisons ?

**pData**

Condition Population

Normal cd163_positive

Normal cd163_negative

Normal cd163_positive

Normal cd163_negative

Normal cd163_positive

Breast_cancer cd163_positive

Breast_cancer cd163_negative

Breast_cancer cd163_positive

Breast_cancer cd163_negative

Breast_cancer cd163_positive

Endometrial_cancer cd163_positive

Endometrial_cancer cd163_negative

Endometrial_cancer cd163_positive

Endometrial_cancer cd163_negative

Endometrial_cancer cd163_positive

Endometrial_cancer cd163_negative

```
f <- paste(pData$Condition,pData$:Population,sep="")
f <- factor(f)
design <- model.matrix(~0+f)
colnames(design) <- levels(f)
> colnames(design)
[1] "Breast_cancercd163_negative" "Breast_cancercd163_positive" "Endometrial_cancercd163_negative" "Endometrial_cancercd163_positive"
[5] "Normalcd163_negative" "Normalcd163_positive"
cont.matrix = makeContrasts(
BRC_posVsBRC_neg = Breast_cancercd163_positive-Breast_cancercd163_negative,
Norm_posVsNorm_neg = Normalcd163_positive-Normalcd163_negative,
END_posVsEND_neg = Endometrial_cancercd163_positive-Endometrial_cancercd163_negative,
BRC_posVsNorm_pos = Breast_cancercd163_positive-Normalcd163_positive,
BRC_posVsEND_pos = Breast_cancercd163_positive-Endometrial_cancercd163_positive,
END_posVsNorm_pos = Endometrial_cancercd163_positive-Normalcd163_positive,
BRC_negVsNorm_neg = Breast_cancercd163_negative-Normalcd163_negative,
BRC_negVsEND_neg = Breast_cancercd163_negative-Endometrial_cancercd163_negative,
END_negVsNorm_neg = Endometrial_cancercd163_negative-Normalcd163_negative,
levels=design)
v=voomWithQualityWeights(d, design = design,plot = TRUE)
vfit <- lmFit(v, design)
vfit <- contrasts.fit(vfit, contrasts=cont.matrix)
efit <- eBayes(vfit)
```

I know this is fairly simple but I am a bit confused. Thank you very much!

**1.1k**• written 2.6 years ago by Matina •

**180**