<p>I am rookie to using limma package. My data looks like this in excel: first column is the gene name, first raw is sample name, and under each sample name is the gene expression value (4 replicates per sample, I have sample wt and mu). I want to find out the significant expressed genes between mu vs wt.</p>

<p>and I write code like this:</p>

<pre>
<code>sample=read.csv(&quot;sample.csv&quot;,header=T,row.names=1)
logsample=log2(sample)
design=model.matrix(~0+c(rep(&#39;wt&#39;,4),rep(&#39;mu&#39;,4)))
colnames(design)=c(&quot;wt&quot;,&quot;mu&quot;)
cm=makeContrasts(mu-wt,levels=design)
fit=lmFit(logsample,design)
fit2=contrasts.fit(fit,cm)
fit3=eBayes(fit2)
result=topTable(fit3,number=Inf,adjust=&quot;BH&quot;,sort.by=&quot;none&quot;)</code></pre>

<p>I am not sure I did it correctly. Please help me to check, many thanks!! I log2 transformed the intensity. The data is already normalized by other software; I am not sure I should use makeContrasts or not.</p>

<p>Thanks!!</p>

Your code looks good to me to find genes differentially expressed between the 4 WT and 4 mu, which I guess it is what you want.

As Devon Ryan suggested, you can leave the intercept and skip the contrasts. This should be equivalent to your code:

```
design=model.matrix(~1+c(rep('wt',4),rep('mu',4)))
colnames(design)=c("wt","mu")
fit=lmFit(logsample,design)
fit<- eBayes(fit)
results<- topTable(fit,number=Inf,adjust="BH",sort.by="none", coef= 2)
```

However, I don't see any harm in explicitly fitting contrasts, actually I find it clearer.

I think in general it's good to look at a couple of genes from the output of `topTable()` and make sure the model is doing what you expect by comparing to the values in the normalized matrix. E.g. in your case:

    results$logFC[1]

Should be equal to (given rounding errors):

    mean(logsample[1, 1:4]) - mean(logsample[1, 5:8])