<p>You can't (easily) use a single design, since clone is nested within diabetic status, so you were correct using two separate designs. Your designs are correct.</p>

<p>If you really wanted to use a single design for some reason, it'd be <code>~clone+structure</code> and for the latter comparison you'd end up using a rather complicated contrast (something like <code>c(rep(c(1,-1), 3), 0)</code>). I really can't recommend that unless you have a very compelling reason, since it's vastly easier to think in terms of factors for your experiment and you're not hurting anything by fitting twice.</p>

CC BY-SA 4.0
2019-08-06T10:45:59.143Z
thank you for the feedback.
mario rossi
CC BY-SA 4.0
2019-08-05T20:42:37.723Z
2019-08-05T20:42:37.723Z
Devon Ryan
<p>I am not sure I am building the proper design formula for the question I want to answer</p>

<p>I have the following samples with three factors; clone, the structure and the condition.</p>

<pre><code>clone structure diabetic
1 07        2D      Dia
2 21        2D     Ctrl
3 23        2D      Dia
4 32        2D     Ctrl
5 34        2D      Dia
6 43        2D     Ctrl
7 07        3D      Dia
8 21        3D     Ctrl
9 23        3D      Dia
10 32        3D     Ctrl
11 34        3D      Dia
12 43        3D     Ctrl
</code></pre>

<p>I want to pull the differentially expressed genes for structure (2D vs 3D) blocking by clone, and the one differentially expressed by condition 
 (regardless of the structure variable).</p>

<p>I am not sure how to build the design in one call, therefore I have produced the first object to pull 2D vs 3D blocking by clone using the following.</p>

<pre><code>des_structure &lt;- DESeqDataSetFromHTSeqCount(sampleTable = samples,
                                       directory = "../data/htseq_geneCounts/",
                                       design= ~ clone+structure)
</code></pre>

<p>for the condition controlled by structure I have used</p>

<pre><code>des_condidtion &lt;- ddsHTSeq_diabetic &lt;- DESeqDataSetFromHTSeqCount(sampleTable = samples,
                                                 directory = "../data/htseq_geneCounts/",
                                                 design= ~ structure+diabetic)
</code></pre>

<p>I am not sure whether this is the best way to build the designs.</p>

<rna-seq><deseq2><design>
design formula question
# design formula question

(Asked by: username_0 on 2019-08-05)

I am not sure I am building the proper design formula for the question I want to answer
I have the following samples with three factors; clone, the structure and the condition.
clone structure diabetic
1 07        2D      Dia
2 21        2D     Ctrl
3 23        2D      Dia
4 32        2D     Ctrl
5 34        2D      Dia
6 43        2D     Ctrl
7 07        3D      Dia
8 21        3D     Ctrl
9 23        3D      Dia
10 32        3D     Ctrl
11 34        3D      Dia
12 43        3D     Ctrl

I want to pull the differentially expressed genes for structure (2D vs 3D) blocking by clone, and the one differentially expressed by condition 
 (regardless of the structure variable).
I am not sure how to build the design in one call, therefore I have produced the first object to pull 2D vs 3D blocking by clone using the following.
des_structure <- DESeqDataSetFromHTSeqCount(sampleTable = samples,
                                       directory = "../data/htseq_geneCounts/",
                                       design= ~ clone+structure)

for the condition controlled by structure I have used
des_condidtion <- ddsHTSeq_diabetic <- DESeqDataSetFromHTSeqCount(sampleTable = samples,
                                                 directory = "../data/htseq_geneCounts/",
                                                 design= ~ structure+diabetic)

I am not sure whether this is the best way to build the designs.

**Tags:** rna-seq, deseq2, design

---

## 1 answers

### Answer by username_1 on 2019-08-05. Score: 6 | Accepted answer

You can't (easily) use a single design, since clone is nested within diabetic status, so you were correct using two separate designs. Your designs are correct.

If you really wanted to use a single design for some reason, it'd be `~clone+structure` and for the latter comparison you'd end up using a rather complicated contrast (something like `c(rep(c(1,-1), 3), 0)`). I really can't recommend that unless you have a very compelling reason, since it's vastly easier to think in terms of factors for your experiment and you're not hurting anything by fitting twice.

> **Comments:**
> **username_0**: thank you for the feedback.  

---

