Errors in qza to phyloseq


I am new to qiime2 and R. Just started to work with the basic script of qza to phyloseq, but I am having trouble with the below errors.

may <- qiime2R::qza_to_phyloseq(features = "maytable.qza",tree = "mayrooted-tree.qza", metadata = "sample-metadatamay.tsv", taxonomy = "mayvsearch-result.qza").

Error in validObject(.Object) : invalid class “phyloseq” object:
Component sample names do not match.
Try sample_names()

Error in validObject(.Object) :
invalid class “sample_data” object: Sample Data must have non-zero dimensions.

I tried a lot from changing metadata file from tsv file to csv but still the errors stands.
I checked over all the other topics which is similar, but none of it gave a positive result. I am unable to figure out where is the mistake. Kindly help.

Thank you

Hello @11145,

Welcome to the forums! :qiime2:

This is pretty common when importing data with phyloseq:

This means that the sample names inside your maytable.qza and sample-metadatamay.tsv are different, so phyloseq does not know how to make them match.

As suggested, the sample_names() function is helpful here, because it lets you see what sample name are inside those files so you can edit them to match.

Try this:


qza_to_phyloseq(features = "maytable.qza") %>%

qza_to_phyloseq(metadata = "sample-metadatamay.tsv") %>%

Here, I'm importing the feature table and metadata table separately, then using the sample_names() to see how the names are different. The difference is probably something small like Sample1 vs sample1 or Sample-1.

Once you edit your sample-metadatamay.tsv file so the sample names match, try importing this again and let me know how it goes! That should also solve the 'non-zero dimensions' error!

Thank you Colin, it solved the problem.

1 Like