**140**wrote:

Hi guys,

I am a bit confused about the statistics for paired samples in edgeR.

I have 4 different treatments, A, B, C and D, each one with 4 samples. 2 of those samples are "before" treatment and the other 2 are "after" treatment.

If iam correct, checking the edgeR manual, the design of the model matrix should be:

```
> groups <- factor(targets$Group)
> treatment <- factor(targets$Treatment, levels=c("before","after"))
> design <- model.matrix(~groups+treatment)
```

But in the case I have a data that is a simple table containing the genes in the first column and de samples in the other columns, how can I construct the model matrix to accept this table format?

I think I can simple open the table as a matrix and atributte the factors to the samples:

```
> my_table <- data.matrix(my_table, row.names.default(my_table))
> groups <- factor(c(A1,A2,A3,A4,B1,B2,B3,B4,C1,C2,C3,C4,D1,D2,D3,D4))
> treatment <- factor(c("before", "before", "after", "after","before", "before", "after", "after","before", "before", "after", "after",))
> design <- design.matrix(~groups+treatment)
> y <- DGEList(counts=my_table, group=groups)
```

But I don't know if this is correct.

Does anyone can help with that, I'd really appreciate it.

Thanks