When I ran the command below, I got an error message (displayed by verbose). However, this command was okay last month.
From the message below, the error is related to the installed R version???
May you please help me to understand the problem and how to figure it out?
qiime diversity adonis \--i-distance-matrix unwe
ighted_unifrac_distance_matrix.qza \--m-metadata-file metadataq.tsv \--o-visualization unweighted-adonis-year-treat.qzv \--p-formula Year+PathogenTreatment \--verbose
Running external command line application. This may print messages to stdout and/or stderr.
The command being run is below. This command cannot be manually re-run as it will depend on temporary files that no longer exist.
Command: run_adonis.R /tmp/tmpe0l6z4ju/dm.tsv /tmp/tmpe0l6z4ju/md.tsv Year+PathogenTreatment 999 1 /tmp/qiime2-temp-nz9dap_i/adonis.tsv
R version 3.5.1 (2018-07-02)
Loading required package: permute
Loading required package: lattice
This is vegan 2.5-6
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
Calls: adonis ... model.matrix -> model.matrix.default -> contrasts<-
Traceback (most recent call last):
File "/home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/q2cli/commands.py", line 328, in __call__
results = action(**arguments)
File "</home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/decorator.py:decorator-gen-430>", line 2, in adonis
File "/home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/qiime2/sdk/action.py", line 240, in bound_callable
File "/home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/qiime2/sdk/action.py", line 445, in _callable_executor_
ret_val = self._callable(output_dir=temp_dir, **view_args)
File "/home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/q2_diversity/_beta/_visualizer.py", line 375, in adonis
File "/home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/q2_diversity/_beta/_visualizer.py", line 401, in _run_command
File "/home/eman/anaconda3/envs/qiime2-2019.10/lib/python3.6/subprocess.py", line 418, in run
subprocess.CalledProcessError: Command '['run_adonis.R', '/tmp/tmpe0l6z4ju/dm.tsv', '/tmp/tmpe0l6z4ju/md.tsv', 'Year+PathogenTreatment', '999', '1', '/tmp/qiime2-temp-nz9dap_i/adonis.tsv']' returned non-zero exit status 1.
I have 2 levels for the year variable (2016 and 2017), and I entered them as (“2016”, “2017”) in the metadata file, so the year is not treated as numbers.
For pathogen treatment, I have also 2 levels; C and E
Honestly I am not sure what the problem is here, the metadata look okay — but obviously the issue lies with the PathogenTreatment column:
Ultimately this is error is coming from R, and it sounds like this is a common error with several R packages that is somewhat difficult to diagnose and reproduce. This stackoverflow post has a very detailed answer for how to diagnose and troubleshoot this — I recommend following these steps in R to figure out what is wrong with your metadata.
Please follow up here if you are able to solve this issue — we have not seen this error before with adonis (except in cases where missing data or missing levels were obvious sources) so this will be useful for the community in case others run into this.