<p>There's a good reason to not allow <code>+</code> and <code>-</code> in the columns. It's because once you do that you get coefficients that can then start with a <code>+</code> or <code>-</code>, which is illegal in R and most other languages. In R, legal variable names consist of:</p>

<blockquote>
  <p>A syntactically valid name consists of letters, numbers and the
       dot or underline characters and starts with a letter or the dot
       not followed by a number.</p>
</blockquote>

<p>That doesn't really explain the error message you saw, of course. That can be solved by thinking about what R does to invalid character in names. Namely, it replaces them by a dot. So <code>+</code> and <code>-</code> get converted to <code>X.</code> and <code>X.</code>, which are of course identical and are what's really leading to the error message your saw. If you had used <code>+cre</code> and <code>-</code> it would have worked.</p>

<p>As an aside, you'll want to think in terms of positive and negative Cre if you talk to a biologist, since that's the appropriate terminology for it.</p>

CC BY-SA 4.0
2018-11-04T22:17:17.150Z
2018-11-04T22:17:17.150Z
Devon Ryan
<p>Weirdly enough, <code>+</code> and <code>-</code> are apparently not allowed in the column. After mapping them to longer strings it started to work:</p>

<pre><code>library(plyr)
cre_id = revalue(samples$cre, c('-' = 'minus', '+' = 'plus'))

sampleTable &lt;- data.frame(
  ID = samples<span class="math-container">$id,
  Group = samples$</span>group,
  Cre = cre_id
)
</code></pre>

<p>and it looks like that:</p>

<pre><code>       ID   Group   Cre
1  Bla_36   IL4 minus
2  Bla_38   IL4 minus
3  Bla_11   IL4 minus
4  Bla_17   IL4 minus
5  Bla_20   IL4  plus
6  Bla_21   IL4  plus
7   Bla_8   IL4  plus
8  Bla_22   IL4  plus
9   Bla_7   IL4  plus
10 Bla_35   PBS minus
11 Bla_37   PBS minus
12 Bla_13   PBS minus
13  Bla_1   PBS minus
14  Bla_9   PBS  plus
15 Bla_23   PBS  plus
16 Bla_19   PBS  plus
17 Bla_24   PBS  plus
</code></pre>

<p>I do not understand though, why...</p>

CC BY-SA 4.0
2018-11-02T23:28:21.367Z
2018-11-02T23:28:21.367Z
Nikita Vlasenko
<p>When I try to import the data using <code>DESeq2</code> package:</p>

<pre><code>dds &lt;- DESeqDataSetFromTximport(txi, sampleTable, ~Group + Cre)
</code></pre>

<p>I am getting the error:</p>

<blockquote>
  <p>Error in validObject(.Object) : 
    invalid class “DESeqDataSet” object: levels of factors in the design have non-unique level names after make.names() is applied.
    best to only uobject letters and numbers for levels of factors in the design</p>
</blockquote>

<p>Here is how my <code>sampleTable</code> looks like:</p>

<pre><code>    ID      Group Cre
1  Bla_36   IL4   -
2  Bla_38   IL4   -
3  Bla_11   IL4   -
4  Bla_17   IL4   -
5  Bla_20   IL4   +
6  Bla_21   IL4   +
7   Bla_8   IL4   +
8  Bla_22   IL4   +
9   Bla_7   IL4   +
10 Bla_35   PBS   -
11 Bla_37   PBS   -
12 Bla_13   PBS   -
13  Bla_1   PBS   -
14  Bla_9   PBS   +
15 Bla_23   PBS   +
16 Bla_19   PBS   +
17 Bla_24   PBS   +
</code></pre>

<p>What am I doing wrong here? And how to make it working?</p>

<r><deseq2>
levels of factors in the design have non-unique level names after make.names() is applied
# levels of factors in the design have non-unique level names after make.names() is applied

(Asked by: username_0 on 2018-11-02)

When I try to import the data using DESeq2 package:
dds <- DESeqDataSetFromTximport(txi, sampleTable, ~Group + Cre)

I am getting the error:

Error in validObject(.Object) : 
    invalid class “DESeqDataSet” object: levels of factors in the design have non-unique level names after make.names() is applied.
    best to only uobject letters and numbers for levels of factors in the design

Here is how my sampleTable looks like:
    ID      Group Cre
1  Bla_36   IL4   -
2  Bla_38   IL4   -
3  Bla_11   IL4   -
4  Bla_17   IL4   -
5  Bla_20   IL4   +
6  Bla_21   IL4   +
7   Bla_8   IL4   +
8  Bla_22   IL4   +
9   Bla_7   IL4   +
10 Bla_35   PBS   -
11 Bla_37   PBS   -
12 Bla_13   PBS   -
13  Bla_1   PBS   -
14  Bla_9   PBS   +
15 Bla_23   PBS   +
16 Bla_19   PBS   +
17 Bla_24   PBS   +

What am I doing wrong here? And how to make it working?

**Tags:** r, deseq2

---

## 2 answers

### Answer by username_1 on 2018-11-04. Score: 3 | Accepted answer

There's a good reason to not allow `+` and `-` in the columns. It's because once you do that you get coefficients that can then start with a `+` or `-`, which is illegal in R and most other languages. In R, legal variable names consist of:

> A syntactically valid name consists of letters, numbers and the
> dot or underline characters and starts with a letter or the dot
> not followed by a number.

That doesn't really explain the error message you saw, of course. That can be solved by thinking about what R does to invalid character in names. Namely, it replaces them by a dot. So `+` and `-` get converted to `X.` and `X.`, which are of course identical and are what's really leading to the error message your saw. If you had used `+cre` and `-` it would have worked.

As an aside, you'll want to think in terms of positive and negative Cre if you talk to a biologist, since that's the appropriate terminology for it.


---

### Answer by username_0 on 2018-11-02. Score: 2

Weirdly enough, + and - are apparently not allowed in the column. After mapping them to longer strings it started to work:
library(plyr)
cre_id = revalue(samples$cre, c('-' = 'minus', '+' = 'plus'))

sampleTable <- data.frame(
  ID = samples$id,
  Group = samples$group,
  Cre = cre_id
)

and it looks like that:
       ID   Group   Cre
1  Bla_36   IL4 minus
2  Bla_38   IL4 minus
3  Bla_11   IL4 minus
4  Bla_17   IL4 minus
5  Bla_20   IL4  plus
6  Bla_21   IL4  plus
7   Bla_8   IL4  plus
8  Bla_22   IL4  plus
9   Bla_7   IL4  plus
10 Bla_35   PBS minus
11 Bla_37   PBS minus
12 Bla_13   PBS minus
13  Bla_1   PBS minus
14  Bla_9   PBS  plus
15 Bla_23   PBS  plus
16 Bla_19   PBS  plus
17 Bla_24   PBS  plus

I do not understand though, why...


---

