<p>This typically happens when Age is a factor rather than numeric column, so each unique row is nested with itself. Design <code>~BrS_BASELINE_PATTERN + Gender</code> is fine, there is no nesting, so this narrows it down to the Age column. Cannot check as you do not provide reproducible data via <code>dput()</code>.</p>

CC BY-SA 4.0
2023-07-07T14:49:33.700Z
Thank you for your fast response, by converting it to a numeric column it works. Still have this note though
Alessia Avon
CC BY-SA 4.0
2023-07-07T14:51:59.897Z
`the design formula contains one or more numeric variables with integer values, specifying a model with increasing fold change for higher values. did you mean for this to be a factor? if so, first convert
  this variable to a factor using the factor() function the design formula contains one or more numeric variables that have mean or standard deviation larger than 5 (an arbitrary threshold to trigger this message). Including numeric variables with large mean can induce collinearity with the intercept. Users should center and scale numeric variables in the design to improve GLM convergence.`
Alessia Avon
CC BY-SA 4.0
2023-07-07T21:14:00.447Z
This now goes into the realm of how you should design your analysis which is not what the question is about. There are many previous threads via google, e.g. on Bioconductor support site on numeric covariates. Numeric covariates like age assumes that there is a relationship between age and expression, which is questionable. It can be that old is different than young, but a 40-yo is unlikely to have double or have expression as compared to a 20-yo, but this is what this would assume with a numeric covariates. Scaling age is an option, or categorizing (young-middle-old).
ATpoint
CC BY-SA 4.0
2023-07-07T13:54:04.643Z
2023-07-07T13:54:04.643Z
ATpoint
<p>I am using the Deseq2 package to perform a DE analysis on multiple factors.</p>
<p>So, basically to perform the analysis I consider patients characterized by the Brugada Syndrome type 1 and other patients that instead are controls.</p>
<p>In order to have equal numbers of PZ and CTRs I included in my analysis all the PZ of type 1, that in this case are 8 samples, and I selected 8 random CTRs among the full dataset the CTRs that I have for this batch (in total are 40).</p>
<p>To select the random CTRs I used the sample_n function:</p>
<pre class="lang-r prettyprint-override"><code>random_CTR_samples_IGATECH&lt;-sample_n(samples_IGATECH_ALL_CTR,8)
</code></pre>
<p>Anyway I created the design matrix that looks like this including also the Age variable as well as the Gender one since I want to test also the effect of those in my data, (NON_INDUCIBLE)= CTR:</p>
<pre class="lang-r prettyprint-override"><code>       Sample BrS_BASELINE_PATTERN Gender Age
1  DG1340                    1      M  44
2  DG1383                    1      F  35
3  DG1453                    1      F  55
4  DG1455                    1      F  53
5  DG1473                    1      M  33
6  DG1557                    1      M  45
7  DG1578                    1      F  57
8  DG1590                    1      M  42
9  DG1380       NON_INDUCIBILE      M  20
10 DG1381       NON_INDUCIBILE      F  52
11 DG1382       NON_INDUCIBILE      M  49
12 DG1565       NON_INDUCIBILE      M  30
13 DG1594       NON_INDUCIBILE      F  42
14 DG1620       NON_INDUCIBILE      M  40
15 DG1633       NON_INDUCIBILE      F  62
16 DG1652       NON_INDUCIBILE      M  21
</code></pre>
<p>and I filtered the Count matrix for the samples present in the design one. So I have</p>
<pre class="lang-r prettyprint-override"><code>head(Counts_IGATECH_ALL_1_random_CTR)
            DG1340 DG1383 DG1453 DG1455 DG1473 DG1557 DG1578 DG1590 DG1380 DG1381 DG1382 DG1565 DG1594 DG1620 DG1633 DG1652
ENSG00000114771      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000129673      0      1      0      0      1      0      0      1      0      1      0      0      0      0      0      0
ENSG00000144452      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000143921      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000173357      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000161103      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
</code></pre>
<p>When I run the <code>DESeqDataSetFromMatrix</code> function I get this error:</p>
<pre class="lang-r prettyprint-override"><code>converting counts to integer mode
factor levels were dropped which had no samples
Error in checkFullRank(modelMatrix) : 
  the model matrix is not full rank, so the model cannot be fit as specified.
  One or more variables or interaction terms in the design formula are linear
  combinations of the others and must be removed.

  Please read the vignette section 'Model matrix not full rank':

  vignette('DESeq2')
</code></pre>
<p>and the function i ran is:</p>
<pre class="lang-r prettyprint-override"><code>dds_IGATECH_1_random_CTR&lt;- DESeqDataSetFromMatrix(countData = round(Counts_IGATECH_ALL_1_random_CTR),
                                               colData = design_IGATECH_1_random_CTR,
                                               design = ~ Age + Gender + BrS_BASELINE_PATTERN)
</code></pre>
<p>I revised my design matrix multiple times and tried to change also the combinations of the CTRs to have a different one and see if that would solve the problem but it didn't work, and I cannot figure out what it can be.</p>
<p>Thank you in advance for any suggestion.</p>
<p>Update</p>
<p>Design matrix:</p>
<pre class="lang-r prettyprint-override"><code>dput(design_IGATECH_1_random_CTR)

structure(list(Sample = c(&quot;DG1340&quot;, &quot;DG1383&quot;, &quot;DG1453&quot;, &quot;DG1455&quot;, 
&quot;DG1473&quot;, &quot;DG1557&quot;, &quot;DG1578&quot;, &quot;DG1590&quot;, &quot;DG1376&quot;, &quot;DG1379&quot;, &quot;DG1573&quot;, 
&quot;DG1575&quot;, &quot;DG1579&quot;, &quot;DG1598&quot;, &quot;DG1627&quot;, &quot;DG1633&quot;), BrS_BASELINE_PATTERN = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c(&quot;1&quot;, 
&quot;2&quot;, &quot;NON_INDUCIBILE&quot;), class = &quot;factor&quot;), Gender = structure(c(2L, 
1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L), levels = c(&quot;F&quot;, 
&quot;M&quot;), class = &quot;factor&quot;), Age = structure(c(23L, 15L, 32L, 31L, 
13L, 24L, 34L, 21L, 29L, 27L, 30L, 10L, 19L, 28L, 18L, 37L), levels = c(&quot;17&quot;, 
&quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;28&quot;, &quot;29&quot;, &quot;30&quot;, &quot;32&quot;, 
&quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;40&quot;, &quot;41&quot;, &quot;42&quot;, &quot;43&quot;, &quot;44&quot;, 
&quot;45&quot;, &quot;46&quot;, &quot;48&quot;, &quot;49&quot;, &quot;50&quot;, &quot;51&quot;, &quot;52&quot;, &quot;53&quot;, &quot;55&quot;, &quot;56&quot;, &quot;57&quot;, 
&quot;58&quot;, &quot;61&quot;, &quot;62&quot;, &quot;63&quot;, &quot;64&quot;, &quot;69&quot;), class = &quot;factor&quot;)), row.names = c(NA, 
-16L), class = &quot;data.frame&quot;)
</code></pre>
<p>The NON_INDUCIBLE data are different since i have generated a new design matrix again, but the format is the same</p>

<r><rna-seq><differential-expression><deseq2>
Issue with Differential Gene expression analysis with Deseq2
# Issue with Differential Gene expression analysis with Deseq2

(Asked by: username_0 on 2023-07-07)

I am using the Deseq2 package to perform a DE analysis on multiple factors.
So, basically to perform the analysis I consider patients characterized by the Brugada Syndrome type 1 and other patients that instead are controls.
In order to have equal numbers of PZ and CTRs I included in my analysis all the PZ of type 1, that in this case are 8 samples, and I selected 8 random CTRs among the full dataset the CTRs that I have for this batch (in total are 40).
To select the random CTRs I used the sample_n function:
random_CTR_samples_IGATECH<-sample_n(samples_IGATECH_ALL_CTR,8)

Anyway I created the design matrix that looks like this including also the Age variable as well as the Gender one since I want to test also the effect of those in my data, (NON_INDUCIBLE)= CTR:
       Sample BrS_BASELINE_PATTERN Gender Age
1  DG1340                    1      M  44
2  DG1383                    1      F  35
3  DG1453                    1      F  55
4  DG1455                    1      F  53
5  DG1473                    1      M  33
6  DG1557                    1      M  45
7  DG1578                    1      F  57
8  DG1590                    1      M  42
9  DG1380       NON_INDUCIBILE      M  20
10 DG1381       NON_INDUCIBILE      F  52
11 DG1382       NON_INDUCIBILE      M  49
12 DG1565       NON_INDUCIBILE      M  30
13 DG1594       NON_INDUCIBILE      F  42
14 DG1620       NON_INDUCIBILE      M  40
15 DG1633       NON_INDUCIBILE      F  62
16 DG1652       NON_INDUCIBILE      M  21

and I filtered the Count matrix for the samples present in the design one. So I have
head(Counts_IGATECH_ALL_1_random_CTR)
            DG1340 DG1383 DG1453 DG1455 DG1473 DG1557 DG1578 DG1590 DG1380 DG1381 DG1382 DG1565 DG1594 DG1620 DG1633 DG1652
ENSG00000114771      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000129673      0      1      0      0      1      0      0      1      0      1      0      0      0      0      0      0
ENSG00000144452      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000143921      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000173357      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
ENSG00000161103      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0

When I run the DESeqDataSetFromMatrix function I get this error:
converting counts to integer mode
factor levels were dropped which had no samples
Error in checkFullRank(modelMatrix) : 
  the model matrix is not full rank, so the model cannot be fit as specified.
  One or more variables or interaction terms in the design formula are linear
  combinations of the others and must be removed.

  Please read the vignette section 'Model matrix not full rank':

  vignette('DESeq2')

and the function i ran is:
dds_IGATECH_1_random_CTR<- DESeqDataSetFromMatrix(countData = round(Counts_IGATECH_ALL_1_random_CTR),
                                               colData = design_IGATECH_1_random_CTR,
                                               design = ~ Age + Gender + BrS_BASELINE_PATTERN)

I revised my design matrix multiple times and tried to change also the combinations of the CTRs to have a different one and see if that would solve the problem but it didn't work, and I cannot figure out what it can be.
Thank you in advance for any suggestion.
Update
Design matrix:
dput(design_IGATECH_1_random_CTR)

structure(list(Sample = c("DG1340", "DG1383", "DG1453", "DG1455", 
"DG1473", "DG1557", "DG1578", "DG1590", "DG1376", "DG1379", "DG1573", 
"DG1575", "DG1579", "DG1598", "DG1627", "DG1633"), BrS_BASELINE_PATTERN = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c("1", 
"2", "NON_INDUCIBILE"), class = "factor"), Gender = structure(c(2L, 
1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L), levels = c("F", 
"M"), class = "factor"), Age = structure(c(23L, 15L, 32L, 31L, 
13L, 24L, 34L, 21L, 29L, 27L, 30L, 10L, 19L, 28L, 18L, 37L), levels = c("17", 
"20", "21", "22", "23", "24", "25", "26", "28", "29", "30", "32", 
"33", "34", "35", "37", "38", "39", "40", "41", "42", "43", "44", 
"45", "46", "48", "49", "50", "51", "52", "53", "55", "56", "57", 
"58", "61", "62", "63", "64", "69"), class = "factor")), row.names = c(NA, 
-16L), class = "data.frame")

The NON_INDUCIBLE data are different since i have generated a new design matrix again, but the format is the same

**Tags:** r, rna-seq, differential-expression, deseq2

---

## 1 answers

### Answer by username_1 on 2023-07-07. Score: 4

This typically happens when Age is a factor rather than numeric column, so each unique row is nested with itself. Design `~BrS_BASELINE_PATTERN + Gender` is fine, there is no nesting, so this narrows it down to the Age column. Cannot check as you do not provide reproducible data via `dput()`.

> **Comments:**
> **username_0**: Thank you for your fast response, by converting it to a numeric column it works. Still have this note though  
> **username_0**: `the design formula contains one or more numeric variables with integer values, specifying a model with increasing fold change for higher values. did you mean for this to be a factor? if so, first convert   this variable to a factor using the factor() function the design formula contains one or more numeric variables that have mean or standard deviation larger than 5 (an arbitrary threshold to trigger this message). Including numeric variables with large mean can induce collinearity with the intercept. Users should center and scale numeric variables in the design to improve GLM convergence.`  
> **username_1**: This now goes into the realm of how you should design your analysis which is not what the question is about. There are many previous threads via google, e.g. on Bioconductor support site on numeric covariates. Numeric covariates like age assumes that there is a relationship between age and expression, which is questionable. It can be that old is different than young, but a 40-yo is unlikely to have double or have expression as compared to a 20-yo, but this is what this would assume with a numeric covariates. Scaling age is an option, or categorizing (young-middle-old).  

---

