ANCOMBC2 error: Error in { : task 1 failed - "values must be length 1, but FUN(X[[2]]) result is length 0"

I am currently having issues with running ANCOMBC2 with a dataset obtained from metabarcoding results targeting the D2 of the LSU from arbuscular mycorrhizal fungi (AMF). I am not sure why I am getting this error, since I have successfully run this same command in other instances (e.g.: with bacterial and fungal datasets).

I am using using the conda version 2026.1 of QIIME2. This is the command that I am running:

qiime composition ancombc2 --i-table asv-table.qza --m-metadata-file metadata-amf-v1.tsv --p-fixed-effects-formula group --p-reference-levels 'group::young' --o-ancombc2-output ancombc2-results-ref-young.qza

This is the error message I get:

/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/unifrac/init.py:9: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
Traceback (most recent call last):
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/q2cli/commands.py", line 573, in call
results = self._execute_action(
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/q2cli/commands.py", line 645, in _execute_action
results = action(**arguments)
File "", line 2, in ancombc2
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/rachis/sdk/action.py", line 307, in bound_callable
outputs = self.callable_executor(
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/rachis/sdk/action.py", line 496, in callable_executor
output_views = self._callable(**view_args)
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/q2_composition/_ancombc2.py", line 93, in ancombc2
output = r_ancombc2.ancombc2(
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/rpy2/robjects/functions.py", line 208, in call
return (super(SignatureTranslatedFunction, self)
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/rpy2/robjects/functions.py", line 131, in call
res = super(Function, self).call(*new_args, **new_kwargs)
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/rpy2/rinterface_lib/conversion.py", line 45, in _
cdata = function(*args, **kwargs)
File "/home/usuari/anaconda3/envs/qiime2-amplicon-2026.1/lib/python3.10/site-packages/rpy2/rinterface.py", line 817, in call
raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in { : task 1 failed - "values must be length 1,
but FUN(X[[2]]) result is length 0"

Plugin error from composition:

Error in { : task 1 failed - "values must be length 1,
but FUN(X[[2]]) result is length 0"

Do you have any idea what could be the issue?

Cheers,

Hello!
I had this issue, but I don't remember what caused it and how I fixed it :confused:.

First two guesses are:

  • Check that your "group" column in the metadata file is named exactly "group" and it contains "young" as one of the levels.
  • check that your asv-table.qza contains "young" samples as well as samples from other groups.

Best,

1 Like

Hi @timanix,

Thanks for your suggestion. I have already check that I have indeed a “group” column and that there are some “young” entries on both the metadata and the ASV table. I think this error has something to do with the amount of ASVs I got, which is less than 500. As a result, I have switched to LEfSe and it works.

Best,