# ADONIS Df wrong

**URL:** https://forum.qiime2.org/t/adonis-df-wrong/27739
**Category:** Technical Support
**Tags:** adonis
**Created:** [September 22, 2023, 5:23pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739 "2023-09-22T17:23:27Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![chiara](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@chiara](https://forum.qiime2.org/u/chiara)
#### Post date: [September 22, 2023, 5:23pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/1 "2023-09-22T17:23:27Z")

</div>

Hello,

I am reaching out for an issue with Adonis.  
The result gives me a wrong Df per level, it assigns 1 Df instead of 4.

Can you please help me to figure out the reason? Is the result reliable?

Thank you in advance for your help.  
Chiara

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [September 23, 2023, 9:01pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/2 "2023-09-23T21:01:50Z")

</div>

Hello Chiara,

We may be able to help.

Can you post the full command you ran, along with the input metadata file?

---

<div class="post-metadata">

### Author: ![chiara](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@chiara](https://forum.qiime2.org/u/chiara)
#### Post date: [September 25, 2023, 6:33am UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/3 "2023-09-25T06:33:15Z")

</div>

Hello,

Thank you very much for your help.  
Here it is the command:

```bash
qiime diversity adonis \
  --i-distance-matrix bray_curtis_distance_matrix.qza \
  --m-metadata-file METADATA.txt \
  --p-formula "Depth*Temperature*SALINITY" \
  --o-visualization adonisleaf.qzv

```

Here is the metadata copied by a txt file

| #SampleID | description | Region | Type | Depth | Temperature | leaf\_area | SALINITY |
| --- | --- | --- | --- | --- | --- | --- | --- |
| deep\_far\_ag\_1 | CS\_deep | CS | LEAF | 18 | 27 | 3.2 | 26.35 |
| deep\_far\_ag\_4 | CS\_deep | CS | LEAF | 18 | 27 | 3.1 | 26.35 |
| deep\_far\_ag\_3 | CS\_deep | CS | LEAF | 18 | 27 | 3 | 26.35 |
| shallow\_ag\_1 | CS\_shallow | CS | LEAF | 10 | 27 | 2.3 | 26.45 |
| shallow\_ag\_2 | CS\_shallow | CS | LEAF | 10 | 27 | 2.2 | 26.45 |
| shallow\_ag\_3 | CS\_shallow | CS | LEAF | 10 | 27 | 2.6 | 26.45 |
| 43 | EMS\_deep | EMS | LEAF | 14 | 26 | 1.2 | 26.6 |
| 45 | EMS\_deep | EMS | LEAF | 14 | 26 | 1.3 | 26.6 |
| 43-LM1 | EMS\_deep | EMS | LEAF | 14 | 26 | 1.1 | 26.6 |
| 44-LM1 | EMS\_deep | EMS | LEAF | 14 | 26 | 1.4 | 26.6 |
| 45-LM1 | EMS\_deep | EMS | LEAF | 14 | 26 | 0.9 | 26.6 |
| 1 | EMS\_shallow | EMS | LEAF | 7 | 27 | 0.7 | 26.53 |
| 13-LM1 | EMS\_shallow | EMS | LEAF | 7 | 27 | 0.8 | 26.53 |
| 14-LM1 | EMS\_shallow | EMS | LEAF | 7 | 27 | 0.9 | 26.53 |
| 15-LM1 | EMS\_shallow | EMS | LEAF | 7 | 27 | 0.9 | 26.53 |
| 14mR1 | RS\_deep | RS | LEAF | 14 | 27 | 4.1 | 21.2 |
| 14mR2 | RS\_deep | RS | LEAF | 14 | 23 | 4.4 | 21.2 |
| 14mR3 | RS\_deep | RS | LEAF | 14 | 23 | 3.3 | 21.2 |
| 9mR1 | RS\_shallow | RS | LEAF | 9 | 23 | 4 | 21.33 |
| 9mR2 | RS\_shallow | RS | LEAF | 9 | 23 | 4.2 | 21.33 |
| 9mR3 | RS\_shallow | RS | LEAF | 9 | 23 | 3.8 | 21.33 |

Thank you very much!  
I look forward to hearing from you.

Best regards,  
Chiara

---

<div class="post-metadata">

### Author: ![chiara](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@chiara](https://forum.qiime2.org/u/chiara)
#### Post date: [September 25, 2023, 1:54pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/4 "2023-09-25T13:54:13Z")

</div>

Thanks @colinbrislawn for editing my command.

I wish to underline that the script I launched was in that correct form, but for some reasons, I could not copy paste it properly.  
Thus, unfortunately the issue is not a typing error.

Can you please help me to figure the error out?

Thank you very much in advance!

Best,  
Chiara

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [September 25, 2023, 1:56pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/5 "2023-09-25T13:56:38Z")

</div>

Hello Chiara,

Thanks for posting that!

Here's the issue:

```bash
--p-formula "Depth*Temperature*SALINITY"

```

ADONIS uses that R formula (examples from [datacamp](https://www.datacamp.com/tutorial/r-formula-tutorial) and [R4DS](https://r4ds.github.io/bookclub-tmwr/r-formula-syntax.html).).

Calling `*` between your variables will 'cross' them, including both variables and their interaction effect in the model. You are crossing three variables, so inside that formula are a lot of effects! One of the combinations has fewer than 4 levels leading to 1 Degree of Freedom.

ADONIS does not work like a typical linear model! Instead of considering explanatory variables equally, **the adonis() test partitions out predictive variables one at a time in the order of your choosing.** This means that the order of these interaction effects will change the meaning of the ADONIS result.

Modeling is tricky and there's a lot to try next.

I would suggest trying formulas like  
`--p-formula "Depth + Temperature"`  
`--p-formula "Depth * Temperature"`  
and see for yourself how crossing works. 🔎

P.S. Your code is 100% correct, I put it into a box for ✨ esthetics ✨

---

<div class="post-metadata">

### Author: ![chiara](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@chiara](https://forum.qiime2.org/u/chiara)
#### Post date: [September 25, 2023, 2:53pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/6 "2023-09-25T14:53:12Z")

</div>

Thank you very much @colinbrislawn for your suggestions.  
I apologize, but I wish to ask you another suggestion: what formula would you suggest to run a multivariate test?  
In my outcome all the Df were 1 not only the one with less than 4 levels. I also tried to run "Temperature \* Salinity" but still the Df were 1 for both factors. How should I interprete this?

Thank you a lot for your help.

Best,  
Chiara

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [September 25, 2023, 3:10pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/7 "2023-09-25T15:10:51Z")

</div>

Hello Chiara,

That's a great question because it's really central to your study. The exact same formula may make perfect sense or be confounding depending on sample blocking and how your cohorts were set up.

This is a perfect question to bring to the PI who designed the study, or to the statistician on your team. Who chose to use these cohorts?

> [@chiara](#):
>
> I also tried to run "Temperature \* Salinity" but still the Df were 1 for both factors. How should I interprete this?

Df = 1 means there were two groups. The number of groups comes from the R formulas you use.

(ADONIS is a clever twist on the ANOVA test. This [comprehensive walkthrough of the ANOVA test](https://people.richland.edu/james/lecture/m113/anova.html) may be helpful.)

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [October 26, 2023, 9:11pm UTC](https://forum.qiime2.org/t/adonis-df-wrong/27739/8 "2023-10-26T21:11:22Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
