<p>I think this is a bug in the input data.</p>
<p>At a wild guess what I think is happening is the input data is not regarded as paired, hence the error <code>paired = paired</code>. The other weird error is <code>x must be numeric</code>. Firstly,</p>
<ul>
<li>how are you scoring missing data, its not via <code>-</code> by any chance? Missing data must be via <code>nan</code> type syntax.</li>
<li>are you sure there are no heading bugs? Like a header is getting dragged into the numeric data?</li>
</ul>
<p>Wilcoxan is a non-parametric T test, so the wet root and dry root must match exactly the same sample. Thus it is not a general wet root versus generic dry root, but wet and dry from the same specimen. If this is the data you have the program doesn't think it is matching.</p>
<p>If it is truely paired, again I think the source of error is you have some missing value which is leaving the pairings unequal lengths or else a header bug.</p>
<p>If the data genuinely isn't paired, then I would look at the Mann-Whitney U test, it would be easier in this scenario.</p>
<p>I don't use R syntax (just pandas dataframes) so can't say whether the syntax in the first example is valid, but it is pretty clear regarding your input. In Python you'd generally just give it the entire dataframe and tell it to go figure.</p>
<p>The reality is that loads of programs do Wilcoxan, you don't need to use R if its a one-off test. Obviously if this a part of a pipeline (automation) thats a bit different.</p>

CC BY-SA 4.0
2020-10-11T06:21:37.923Z
Hi Michael, I have merged two factor (region & season) into single one and then did annova test followed by posthoc and it work well. Should I update the code?
bioinfonext
CC BY-SA 4.0
2020-10-11T08:03:39.140Z
No that's fine thanks. You can answer your own question however, but are not obliged to do so.
M__
CC BY-SA 4.0
2020-10-07T11:48:30.267Z
2020-10-07T16:35:37.420Z
2020-10-07T16:35:37.420Z
M__
<p>I am trying to do Wilcox test to detect the significant difference in alpha diversity but it is showing an error? physeqN2 is a phyloseq object and Season is a metadata column.</p>
<pre><code>results = estimate_richness(physeqN2, measures = 'Chao1')

d = sample_data(physeqN2)

# calculate Wilcox Test
Wet.root = results[d[,'Season'] == 'Wet',]
Dry.root = results[d[,'Season'] == 'Dry',]
pmv &lt;-pairwise.wilcox.test(Wet.root, Dry.root)

capture.output(pmv, file = &quot;chao1.16s.wet_vs_Dry.root.txt&quot;)

Error;
Error in wilcox.test.default(xi, xj, paired = paired, ...) :
  'x' must be numeric
Calls: pairwise.wilcox.test ... compare.levels -&gt; wilcox.test -&gt; wilcox.test.def                                                                                        ault
Execution halted
</code></pre>
<p>I hvae tried to do it in another way but here also getting error?</p>
<pre><code>alpha.diversity &lt;- estimate_richness(physeqN2, measures=c(&quot;Chao1&quot;))


## Wilcox on observed richness
data &lt;- cbind(sample_data(physeqN2), alpha.diversity)
pmv &lt;-pairwise.wilcox.test(Chao1 ~ Season, data)

capture.output(pmv, file = &quot;chao1.16s.wet_vs_Dry.root.txt&quot;)

Error:

Error in if (length(ans) == 0L || as.character(ans[[1L]])[1L] == &quot;~&quot;) { :
  missing value where TRUE/FALSE needed
Calls: pairwise.wilcox.test ... sapply -&gt; lapply -&gt; FUN -&gt; compare.levels -&gt; [ -&gt; [.formula
Execution halted
</code></pre>
<p>Many thanks</p>

CC BY-SA 4.0
2020-10-07T11:33:48.087Z
Is the data truely paired?
M__
CC BY-SA 4.0
2020-10-07T12:29:14.527Z
?pairwise.wilcox.test, Your syntax is wrong in both examples pairwise.wilcox.test(results,d) seems more likely. But as Michael mentioned you might not want to do a paired test.
Greg
<bioconductor><r><microbiology>
alpha diversity wilcox.test
# alpha diversity wilcox.test

(Asked by: username_0 on 2020-10-07)

I am trying to do Wilcox test to detect the significant difference in alpha diversity but it is showing an error? physeqN2 is a phyloseq object and Season is a metadata column.
results = estimate_richness(physeqN2, measures = 'Chao1')

d = sample_data(physeqN2)

# calculate Wilcox Test
Wet.root = results[d[,'Season'] == 'Wet',]
Dry.root = results[d[,'Season'] == 'Dry',]
pmv <-pairwise.wilcox.test(Wet.root, Dry.root)

capture.output(pmv, file = "chao1.16s.wet_vs_Dry.root.txt")

Error;
Error in wilcox.test.default(xi, xj, paired = paired, ...) :
  'x' must be numeric
Calls: pairwise.wilcox.test ... compare.levels -> wilcox.test -> wilcox.test.def                                                                                        ault
Execution halted

I hvae tried to do it in another way but here also getting error?
alpha.diversity <- estimate_richness(physeqN2, measures=c("Chao1"))


## Wilcox on observed richness
data <- cbind(sample_data(physeqN2), alpha.diversity)
pmv <-pairwise.wilcox.test(Chao1 ~ Season, data)

capture.output(pmv, file = "chao1.16s.wet_vs_Dry.root.txt")

Error:

Error in if (length(ans) == 0L || as.character(ans[[1L]])[1L] == "~") { :
  missing value where TRUE/FALSE needed
Calls: pairwise.wilcox.test ... sapply -> lapply -> FUN -> compare.levels -> [ -> [.formula
Execution halted

Many thanks

**Tags:** bioconductor, r, microbiology
> **Comments:**
> **username_1**: Is the data truely paired?  
> **username_2**: ?pairwise.wilcox.test, Your syntax is wrong in both examples pairwise.wilcox.test(results,d) seems more likely. But as Michael mentioned you might not want to do a paired test.  

---

## 1 answers

### Answer by username_1 on 2020-10-07. Score: 0

I think this is a bug in the input data.

At a wild guess what I think is happening is the input data is not regarded as paired, hence the error `paired = paired`. The other weird error is `x must be numeric`. Firstly,

* how are you scoring missing data, its not via `-` by any chance? Missing data must be via `nan` type syntax.
* are you sure there are no heading bugs? Like a header is getting dragged into the numeric data?

Wilcoxan is a non-parametric T test, so the wet root and dry root must match exactly the same sample. Thus it is not a general wet root versus generic dry root, but wet and dry from the same specimen. If this is the data you have the program doesn't think it is matching.

If it is truely paired, again I think the source of error is you have some missing value which is leaving the pairings unequal lengths or else a header bug.

If the data genuinely isn't paired, then I would look at the Mann-Whitney U test, it would be easier in this scenario.

I don't use R syntax (just pandas dataframes) so can't say whether the syntax in the first example is valid, but it is pretty clear regarding your input. In Python you'd generally just give it the entire dataframe and tell it to go figure.

The reality is that loads of programs do Wilcoxan, you don't need to use R if its a one-off test. Obviously if this a part of a pipeline (automation) thats a bit different.

> **Comments:**
> **username_0**: Hi Michael, I have merged two factor (region & season) into single one and then did annova test followed by posthoc and it work well. Should I update the code?  
> **username_1**: No that's fine thanks. You can answer your own question however, but are not obliged to do so.  

---

