sample ids found in the table are missing in the metadata error - creating a taxonomic bar plot

im going through the FMT tutorial and trying to create a taxonomic bar plot of swab samples and stool samples (separately)

i'll include one example in which im trying to generate a bar plot for swab samples

ive already filtered the FeatureTable to include only swab samples

qiime feature-table filter-samples
--i-table table.qza
--m-metadata-file sample-metadata.tsv
--p-where "[sample-type]='swab'"
--o-filtered-table swab-filtered-table.qza

Output
Swab-filtered-table.qza

then filtered the FeatureSequences

qiime feature-table filter-seqs
--i-data rep-seqs.qza
--i-table swab-filtered-table.qza
--o-filtered-data swab-filtered-seqs.qza

Output
Swab-filtered-seqs.qza

i also filtered the original FMT metadata file so it includes only swab samples

i trained a feature classifier to obtain a swab-taxonomy.qza

when i try to generate a taxa bar plot of the swab-filtered samples i get the following error message

qiime taxa barplot
--i-table swab-filtered-table.qza
--i-taxonomy swab-taxonomy.qza
--m-metadata-file swab-metadata.tsv
--o-visualization taxa-bar-plots.qzv

Plugin error from taxa:

Sample IDs found in the table are missing in the metadata: {'11f3f37a.3698.4031.8183.75f6f2c6c04c', 'eb4ece61.6afe.4c88.8a06.d616dab1dd34', 'bd64992d.87cc.464f.9e1b.9c0156ed65d8', '683047f6.fe17.477f.9950.a6190ca34054', 'fe826a14.1ed8.4d19.b14d.2233b960e1bc', '1fe19636.3708.4a87.8e5a.cf10d8530d4e', '595e93ed.e4b3.42b5.91b1.1ad4f31e7134', '90120dc2.ad2e.4916.a660.633ba4b6a7b8', '04ea008a.d444.4833.988c.a2a3f5d4ad23', '59d06f37.995b.40a5.91a8.c825d1a7ca6f', 'cfe0d2d7.c78b.4092.b923.3322b4312c6d', '873473f6.eef2.4718.b5f4.e88757055760', '98c66ce0.1f4c.422c.86e9.3561ea63b612', '40112074.09e5.42b1.b332.17c9b89686e5', '558a13e5.f4a8.47bc.a63e.47d6dffe528b', 'd623471b.5a0c.4291.a780.2ae6532752a9', '98d36350.175c.439b.a534.27de6e5783ad', '593b1c57.09b3.43f2.97b1.7051761e13c9', '7e1f1b3f.4575.458c.9f42.287d03499e25', 'ea89c98c.42eb.484a.aed3.33711e20a6fe', '8cbe736d.b553.450d.af3c.d5ad08863390', 'c1a66804.c565.448a.8371.0c8e386f4969', 'c287751e.0263.4fda.8aa2.3b717855e2ee', 'c61b44a5.ae92.4202.9d0c.b4507197e456', 'e7a2370c.f80c.4703.b2ee.10c65967e05f', 'cfc37a70.9ba6.4d25.b541.4c0ff9d1bfeb', '124dc1db.9029.41c6.afff.b73a692e19b1'}.

i dont understand this because the table.qza has been filtered to include only swab samples and the metadata file itself has also been filtered to include only the swab samples - so why is qiime expecting additional feature IDs to be present in the table which are absent from the metadata? (these feature IDs refers to those features which are not swab related - they are stool samples)

included all files which have been mentioned and needed to generate the taxa bar plot
swab-metadata.tsv (8.2 KB) swab-taxonomy.qza (94.6 KB) swab-filtered-seqs.qza (77.2 KB) swab-filtered-table.qza (46.6 KB)

1 Like

Hi
Could you repeat barplot command with filtered tables but original metadata file?

Hi - i tried this and again got a similar error - except now it says that feature IDs found in the table are missing from taxonomy - i dont understand this because both the table and taxonomy are filtered to include only swab samples - from the error message qiime seems to be expecting that all sample IDs present in the original metadata file to be present in the table?

Could you repeat it again, with all original files, except of feature table? Feature table usually the only thing you need to filter. In most cases there is no need to filter anything else.

Thanks for the advice - this has let me generate a bar plot

However all samples on the bar plot are ONLY stool samples, despite using the swab-filtered table - i tried using the stool-filtered table and samples on this bar plot are also only stool samples - really unsure why!

how do i get the bar plot to show only swab samples and the other only stool? i thought the filtered tables would do this

(qiime2-2020.2) qiime2@qiime2core2020-2:~/qiime2-fmt-tutorial$ qiime taxa barplot \

--i-table swab-filtered-table.qza
--i-taxonomy full-taxonomy.qza
--m-metadata-file sample-metadata.tsv
--o-visualization taxa-bar-plots.qzv

Saved Visualization to: taxa-bar-plots.qzv

command for stool-filtered samples

(qiime2-2020.2) qiime2@qiime2core2020-2:~/qiime2-fmt-tutorial$ qiime taxa barplot \

--i-table stool-filtered-table.qza
--i-taxonomy full-taxonomy.qza
--m-metadata-file sample-metadata.tsv
--o-visualization stool-taxa-bar-plots.qzv

Saved Visualization to: stool-taxa-bar-plots.qzv

both plots are identical and correspond only to stool samples (this is the only category which shows up selecting by sample-type

also im sure the tables have been correctly filtered because when i view them the no. of samples in each of the times are different and correspond to their respective numbers in the metadata file

That’s very strange. Or I am missing something.
Could you please attach original metadata, taxonomy and original table? I will try to filter and recreate taxabarplot

i dont understand this at all either - ive attached the original files
sample-metadata.tsv (11.3 KB)
full-taxonomy.qza (67.9 KB) table.qza (88.4 KB)
Thanks for your help

Hi!
Check it out.
swab_barplot.qzv (526.7 KB)
stool_barplot.qzv (401.1 KB)

Code I used in jupyter lab, last qiime2 vesion:

#Filtering by type
for sampletype in ['stool','swab']:
    tabout = '%s_table.qza' % sampletype
    column = "[sample-type]='%s'" % sampletype  

    !qiime feature-table filter-samples \
        --i-table table.qza \
        --m-metadata-file sample-metadata.tsv \
        --p-where "$column" \
        --o-filtered-table $tabout 

# barplot recreation    
    barplot = '%s_barplot.qzv' % sampletype

    !qiime taxa barplot \
        --i-table $tabout \
        --i-taxonomy full-taxonomy.qza \
        --m-metadata-file sample-metadata.tsv \
        --o-visualization $barplot

ahh thanks for this - im still not quite sure what i was doing wrong ill have another crack at it

unfortunately i’m not that familiar with python so using jupyter notebook to run the commands is a little over my head

are there are any good resources you can recommend to learn how to use python specifically for qiime2?

really appreciate your help - thanks

The code above will be identical to this

qiime feature-table filter-samples \
    --i-table table.qza \
    --m-metadata-file sample-metadata.tsv \
    --p-where "[sample-type]='swab'" \
    --o-filtered-table swab_table.qza

qiime feature-table filter-samples \
    --i-table table.qza \
    --m-metadata-file sample-metadata.tsv \
    --p-where "[sample-type]='stool'" \
    --o-filtered-table stool_table.qza

qiime taxa barplot \
    --i-table stool_table.qza \
    --i-taxonomy full-taxonomy.qza \
    --m-metadata-file sample-metadata.tsv \
    --o-visualization stool_barplot.qzv

qiime taxa barplot \
    --i-table swab_table.qza \
    --i-taxonomy full-taxonomy.qza \
    --m-metadata-file sample-metadata.tsv \
    --o-visualization swab_barplot.qzv

I learned some python with free course on codeacademy, really nice website. After it i was just googling and digging stackoverflow whenever I got stacked (for centuries :grinning:)

There is a nice book I bought but still don’t have time to read:
Bioinformatics with Python Cookbook, second edition, by Tiago Antao

2 Likes

ah thanks so much - still not entirely sure where i went wrong but i understand the commands you put here

i’ll check out that book thanks!
i’m trying to learn some bioinformatics but i’m struggling a little with about where to get started with the coding - ill check out that book though

Thank you!

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