rmodel.matrix

R design.matrix issue -- dropped column in design matrix?


I'm having an odd problem while trying to set up a design matrix to do downstream pairwise differential expression analysis on RNAseq data. For the design matrix, I have both the donor information and each condition:

group<-factor(y$samples$group) #44 samples, 6 different conditions
sample<-factor(y$samples$samples) #44 samples, 11 different donors.
design<- model.matrix(~0+sample+group)
head(design)

      Donor11.CD8    Donor12.CD8    Donor14.CD8   Donor15.CD8   Donor16.CD8
1             1             0             0             0             0
2             1             0             0             0             0
3             1             0             0             0             0
4             1             0             0             0             0
5             1             0             0             0             0
6             1             0             0             0             0
       Donor17.CD8    Donor18.CD8   Donor19.CD8    Donor20.CD8   Donor3.CD8
1             0             0             0             0            0
2             0             0             0             0            0
3             0             0             0             0            0
4             0             0             0             0            0
5             0             0             0             0            0
6             0             0             0             0            0
        Donor4.CD8        Treatment2         Treatment3  Treatment4 Treatment5
1            0                  0                  0           0             0
2            0                  0                  0           0             1
3            0                  0                  0           1             0
4            0                  0                  0           0             0
5            0                  0                  1           0             0
6            0                  1                  0           0             0
        Treatment6
1             1
2             0
3             0
4             0
5             0
6             0
> 

The issue is that I seem to be losing a condition (treatment 1) when I form the design matrix, and I'm not sure why.

Many thanks, in advance, for your help!


Solution

  • That's not a problem. Treatment 1 is indicated by all 0 for the columns in the design matrix. Look at row 4 - zero for Treatments 2 through 6. That means it is Treatment 1. This is called a "treatment contrast" because the coefficients in the model contrast the named treatment against the "base" level, in this case the base level is Treatment1.