q2-classifier error - linkage must be computed on at least two observations


I am running the q2-classifier plugin and got the following error:

Plugin error from sample-classifier:

Linkage must be computed on at least two observations.

I found a post in the forum that began to address this error, but it looks like the user stopped responding at some point and there was no resolution.(Plugin error - feature-table)

What does this error mean?

Please let me know if you need any other information from me in order to help with this.

Thanks in advance for your assistance!

Welcome, @jrw187!

This error message is coming from q2-feature-table, not q2-sample-classifier (though some pipelines in q2-sample-classifier wrap the former, so this is probably why you are receiving that error).

This error message indicates that there is a single sample in your feature table, so no linkage can be computed between sample pairs. You should check out the input table to make sure everything looks okay, and check your parameter settings to, e.g., make sure you are not collapsing your entire table into one sample based on some metadata value.

If that does not guide you to a solution, please let us know what your full command and full error message are, to help us troubleshoot. Thanks!

Hello @Nicholas_Bokulich ,

After I read your initial response, I went back and looked at the feature table and it looked fine. I looked at my metadata file as well and couldn’t see any obvious issue there.

So to trouble-shoot a bit more, I ran the qiime sample-classifier classify-samples command using a different categorical variable column and the qiime sample-classifier regress-samples command on a continuous variable column using the same feature table and metadata file. Both of these worked without a problem. So this tells me there is something going on with the metadata column for the original variable that I was testing. I tried renaming the column (didn’t work) and then re-naming the variables (didn’t work). Weirdly enough, I have run other commands with this metadata column (for example, testing beta diversity significance) and didn’t have an issue.

At this point, I am not really that concerned with being able to run this - I am convinced based on all the other analysis that I have done that the composition of ASVs isn’t going to be predictive for this variable. But I don’t like leaving a puzzle unsolved, so thought I would follow up here and see if you had any thoughts on what could be going on. The command that I was using and the full error message are below. For reference, when I ran this for another categorical variable (as I indicated above), all I did was substitute a different column name - the rest of the code was exactly the same - and it ran fine.

qiime sample-classifier classify-samples \

–i-table feature-frequency-filtered-wc-table.qza
–m-metadata-file 2018_Rot_wc.tsv
–m-metadata-column WC
–p-estimator RandomForestClassifier
–p-n-estimators 100
–p-random-state 123
–output-dir wc-classifier
Traceback (most recent call last):
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2cli/commands.py”, line 328, in call
results = action(**arguments)
File “</home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/decorator.py:decorator-gen-148>”, line 2, in classify_samples
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 484, in callable_executor
outputs = self._callable(scope.ctx, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_sample_classifier/classify.py”, line 183, in classify_samples
group_samples=True, missing_samples=missing_samples)
File “</home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/decorator.py:decorator-gen-485>”, line 2, in heatmap
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 484, in callable_executor
outputs = self._callable(scope.ctx, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_sample_classifier/classify.py”, line 440, in heatmap
clustermap, = make_heatmap(table, **clustermap_params)
File “</home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/decorator.py:decorator-gen-489>”, line 2, in heatmap
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 452, in callable_executor
ret_val = self._callable(output_dir=temp_dir, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_feature_table/_heatmap/_visualizer.py”, line 142, in heatmap
cbar_kws={‘label’: cbar_label})
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/seaborn/matrix.py”, line 1366, in clustermap
tree_kws=tree_kws, **kwargs)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/seaborn/matrix.py”, line 1183, in plot
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/seaborn/matrix.py”, line 1039, in plot_dendrograms
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/seaborn/matrix.py”, line 747, in dendrogram
label=label, rotate=rotate)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/seaborn/matrix.py”, line 562, in init
self.dendrogram = self.calculate_dendrogram()
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/seaborn/matrix.py”, line 642, in calculate_dendrogram
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/scipy/cluster/hierarchy.py”, line 3278, in dendrogram
is_valid_linkage(Z, throw=True, name=‘Z’)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/scipy/cluster/hierarchy.py”, line 2264, in is_valid_linkage
raise ValueError('Linkage must be computed on at least two ’
ValueError: Linkage must be computed on at least two observations.

Thanks for your time in helping me with this!

Hi @jrw187,
Thanks for the extra details.

The classify-samples pipeline runs a bunch of individual steps for classification, then creates a heatmap to visualize differences between sample classes, and that’s where your error is occurring. Samples are grouped by sample class to make an overview of sample classes (with the expectation that qiime sample-classifier heatmap can be run separately to look at abundances in each group), and your feature table appears to be collapsed to a single sample.

This seems to indicate that there is only one class in your data — can you please confirm that all samples in your feature table/metadata have the same value for metadata column WC? That’s also consistent with your observation that this command works fine on other metadata columns.

Please let me know what you find!

Hi @Nicholas_Bokulich,

No, I have 4 different values in the metadata column WC. I tried just re-naming them A, B, C, D for simplicity’s sake to see if it would run (it didn’t). Strangest thing. Especially considering then when I ran the beta significance command specifying that column, there was no problem - I got an output that showed differences (or lack thereof!) between the 4 groups. I also ran ANCOM with that same column specified - this also ran fine and the output showed the 4 groups. I didn’t have a problem until I got to the sample classifier.

Thank you,

Some classes must be dropping out somewhere along the way, either that or you have only one important feature, which makes less sense.

I think the best way to diagnose will be to run the steps of the pipeline individually, and inspect the outputs along the way. You can see the steps of the pipeline in the flowchart here:

That flowchart is a little out of date, there is an extra step to build a heatmap at the end now, with qiime sample-classifier heatmap. Everything should run smoothly up to that step, but then you should inspect the inputs to see what they look like, and can play with the parameters on that command to see if using --p-no-group works. Let me know what you find!

Good luck!

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