qza_to_phyloseq error Component sample names do not match. and invalid class “sample_data” object: Sample Data must have non-zero dimensions.


I am using function qza_to_phyloseq function in qiime2R to create a phyloseq object. When using read_qza individually on my qza files (feature table, taxonomy, and phylogenetic tree) and read.table on my metadata.txt everything appears okay. However, when I run qza_to_phyloseq function I get an error message: Error in validObject(.Object) : invalid class “phyloseq” object:
Component sample names do not match.
Try sample_names()

Initially, I used numbers for my sampleid column of my metadata file. Following recommendations in this post here and discussion here, I reindexed my samples in my feature table with qiime feature-table group from “#” to “Sample#” and changed my metadata file accordingly under column sampleid. I validated the new metadata file with keemei.

GreenOnly4660PhyloseqObj <- qza_to_phyloseq(
features = “qza_files/rarefied_table_4660_eelgrass_GreenOnly_reindexed.qza”,
tree = “qza_files/2019_eelgrass_runs_1_3_16S_rep_sequences_deblur_aligned_masked_rooted_tree.qza”,
taxonomy = “qza_files/2019_eelgrass_runs_1_3_16S_rep_sequences_deblur_sklearn_naive_bayes_taxonomy.qza”,
metadata = “reindex_samplenumber/EelgrassMicrobiomeWaterSamples2019MetadataFullquotetrue_sampleid.txt”
Error in validObject(.Object) : invalid class “phyloseq” object:
Component sample names do not match.
Try sample_names()

no common values for row names and column names

Any ideas what could be the source of this error? My metadata file was generated by write.table in R and validated with Keemei.
rarefied_table_4660_eelgrass_GreenOnly_reindexed.qza (1.7 MB)
EelgrassMicrobiomeWaterSamples2019MetadataFullquotetrue_sampleid.txt (294.5 KB)

This a quirk coming from the use of quotations in your metadata file. If you remove them then qza_to_phyloseq should work as expected. Alternately you could always build your phyloseq object manually. A quick check of the overlap would suggest you have sequence data for 248 out of the 656 samples, was this to be expected?

noquote_EelgrassMicrobiomeWaterSamples2019MetadataFullquotetrue_sampleid.txt (268.6 KB)

1 Like

Thank you. You’re my hero.

Yes, this is correct regarding sequence data and samples. The feature table samples (columns) are a subset of those found in the metadata file. In Qiime2 this has not caused any trouble. I hope the same is true in phyloseq!

1 Like