Generate taxa-stacked bar plots

Hi Christian,

Thanks a lot for your code.
I am going to generate taxa-stacked bar plots for the top 10 of my genus. I used the following code and I generated a .tsv file. Could you please help me to make it.
!qiime taxa collapse
--i-table dada/table.qza
--i-taxonomy taxa.qza
--p-level 6
--o-collapsed-table genus.qza

!qiime tools export
--input-path genus.qza
--output-path exported
!biom convert -i exported/feature-table.biom -o genus.tsv --to-tsv

abundances = pd.read_table("genus.tsv", skiprows=1, index_col=0)
abundances

Hi @smashha,
I moved your question to a new topic since it doesn't seem to be related to the google collab thread... Can you share where you are stuck? I am happy to help you get your bar plots created. Also if you search the forum there are lots of helpful questions that have already been answered regarding creating taxa barplots.

Hi Johannah,

I usually used the .csv file provided by qiime2.view and I and for making a taxa stacked bar plot for my top 10 or top 20 of my taxa, I used Excell. ( It was doable for up to 20 samples)
Currently, I am working with 54 samples, which will increase to 300 or so.
and I need to learn how I can do them through coding.
I prefer to use Google Colab and educate myself but at the same time, it will be much more helpful if someone previously did the same.

Here are the steps that I have done so far:
1)
!qiime taxa collapse
--i-table dada/table.qza
--i-taxonomy taxa.qza
--p-level 6
--o-collapsed-table genus.qza

!qiime tools export
--input-path genus.qza
--output-path exported
!biom convert -i exported/feature-table.biom -o genus.tsv --to-tsv

abundances = pd.read_table("genus.tsv", skiprows=1, index_col=0)

abundances

abundances.index = abundances.index.str.split(";").str[5] # Use only the genus name
abundances = abundances[~abundances.index.isin(["g__", "__"])] # remove unclassified genera

I used the "Google Colab" for these steps.

In my metadata, I have 5 locations in a river and 2 locations in a reservoir, and I need to have a taxa stacked bar plot " location wise" or " group of rivers location " and so on.

Could you please share a source or experience to learn through?

Thanks,
Sara

Hi @smashha,
What do you mean here regarding the .csv,

are you able to link it? which visualization did you download that from?
Also, what are your goals for this process? is your goal to filter the data and then code a visualization in python? Or is it to filter the data using python and then import into qiime and create your barplot using qiime taxa-barplot?
Something worth considering is that if you stay inside the qiime2 framework you get to keep your data provenance and keep track of what has been done with the data.
My last question is how do you want to filter your 'top 10 or 20' taxa? Is this across the whole dataset? or top 10 or 20 per sample which would yield a lot of taxa?

-Hannah