How can I barplot the total number of taxa identified across samples/metadata columns?

Hi everyone,

I am quite new to QIIME2 and was wondering if there is a simple tool already implemented in QIIME2 that make possible to barplot the number of taxa (different levels) either across samples or a given metadata column. Also, it would be great if the user could set a parameter telling QIIME which is the minimum abundance (%) that makes a feature sums to the total number of features identified. That way it would be possible to plot either total number or core taxa identified in each body site/host species/country/whatever.

Thank you in advance!

Hi @vheidrich,
Welcome aboard! If you haven’t already done so, I would recommend working your way through the tutorials or at least working one of the example sets, say the Moving Pictures dataset. These should cover a lot of important information for new users.

As your inquiries…You can create a barplot as you described using the taxa barplot action which lets you interactively choose between different taxonomic levels. And if I am understanding your second request correctly, you should be able to use one of the many filtering options to set minimum abundance required to retain in a sample. Check out the filtering tutorial for a bunch of different filtering methods you could use. Though at the moment the filtering options are based on frequency and not proportions, so you wouldn’t be able to set min %, but you could calculate that yourself based on your table summaries and easily get around that.

Thank you for your reply!
As far as I understood taxa barplot function has to do with taxa relative distribution, not with total number of taxa found from a chosen taxonomic level. I don’t know if I am explaining my question properly, so to make it easy here goes what I would like to do using QIIME:

If not possible, can I somehow extract this info from the OTU table to plot it outside QIIME?

Hi @vheidrich,
Thanks for clarifying and providing the link. The link opened 6 figures for me, but based on the URL I think you were referring to Figure 5, right?
If so, then that’s not something you can do in Qiime2 at the moment but you can certainly grab the information you need to do it outside with some other tool.
You should still use be able to utilize the taxa barplots, here instead of using the plots themselves, just select the taxonomic level you are interested in and click the ‘CSV’ button at the top of the page. This will give you the ASV/OTU table that you can use in other programs like R.
To get the other part of the information which is the shared ‘core’ taxa, you can use the core-feature action. However, keep in mind that if you want to match the taxonomic level you use from your barplots you’ll have to first collapse your ASV/OTU table down to the same level using the taxa collapse first.
Hope that helps!


@Mehrbod_Estaki is correct, QIIME 2 will not generate those plots for you (especially the # taxa at each level + # of core taxa). but QIIME 2 can report all of that information for you. To calculate the total number of taxa identified across all samples belonging to a metadata column:

  1. qiime feature-table group on the column of interest (use a column that contains the same value for all samples if you want to total across all samples)
  2. qiime taxa collapse at the level of interest
  3. qiime diversity alpha to count total # of taxa (use the “observed otus” metric)
  4. export and plot in R

I’m guessing it won’t be possible to just create a presence/absence table from your original frequency table, then import that into the barplot function because the program producing the plot is looking for a specific file type (frequency, rather than presence/absence).
Nevertheless, I bet you could hack it within QIIME and avoid R: why not create the presence absence file using the command above, export that file as a .biom file, then import that file into qiime as a frequency table. That’d probably plot it just fine, assuming your import specified that the table itself was a frequency table (just know that you’re lying to QIIME!).
If you want to collapse at various taxonomic levels, follow @Nicholas_Bokulich’s advice, then you would export and import as I mentioned above.
If you’re comfortable with R, however, you can save yourself from exporting of the .qza into a .biom or .tsv file with the qiime2r library - you can read that in directly with that program. Note, however, there can be a massive file size difference between the .qza table and the .tsv format - one of my tables is inflated from about 1.6 MB to 370 MB.


This solution will work for me! Thank you very much.
As I am already running QIIME 2 through a Jupyter notebook (emulating the terminal by using the %%bash flag at the beginning of the cells) with Python3 kernel, will be easier to plot inline using Python.

Even better! Export and plot in python. Since you are already using Jupyter notebooks for this and comfortable with python, you may want to try artifact API for this (sorry that is a minimal doc, but the plugin documentation provides the API for all commands) — if you are more comfortable with the CLI that is fine, but the API will make it easier if you are passing back and forth between QIIME 2 and native python.


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