sbslee / dokdo

A Python package for microbiome sequencing analysis with QIIME 2
https://dokdo.readthedocs.io
MIT License
42 stars 12 forks source link

genus level average bar plot #14

Closed khemlalnirmalkar closed 3 years ago

khemlalnirmalkar commented 3 years ago

Hi @sbslee , Thanks for your codes, much easier to make bar plots, Please can you also suggest, how to make an average of all samples from each group and make a bar plot at the genus level from qzv file? Thanks

sbslee commented 3 years ago

Thanks for the idea, I will work on this.

khemlalnirmalkar commented 3 years ago

Yes, please that will be great. Thanks

sbslee commented 3 years ago

@khemlalnirmalkar,

As you can see below, I added the group option to the taxa_abundance_bar_plot method, which will create a bar for each group instead of each sample. This is implemented in dokdo-1.9.0. Please install Dokdo again in order to use this feature. If you have any questions regarding the update, please let me know. I also updated Dokdo API to reflect this change.

taxa_abundance_bar_plot-11

dokdo.taxa_abundance_bar_plot(qzv_file,
                              level=6,
                              count=8,
                              group='body-site',
                              figsize=(10, 7),
                              legend_short=True,
                              artist_kwargs=dict(show_legend=True))
plt.tight_layout()
khemlalnirmalkar commented 3 years ago

Thank you so much, for the quick action, I could replicate the plot. I was thinking if it is possible to play with font size and order of group name (now it is alphabetical)?

sbslee commented 3 years ago

@khemlalnirmalkar,

First off, you can easily change the font size of group labels right now:

qzv_file = '/Users/sbslee/Desktop/dokdo/data/moving-pictures-tutorial/taxa-bar-plots.qzv'
dokdo.taxa_abundance_bar_plot(qzv_file,
                              level=6,
                              count=8,
                              group='body-site',
                              figsize=(10, 7),
                              legend_short=True,
                              artist_kwargs=dict(show_legend=True, xticklabels_fontsize=20))
plt.tight_layout()

example1

For more details, please see the Title, Axis, Legend, Font Size section in Dokdo API.

As for the order of group names, I agree it'd be nice to be able to manually provide an order (or subset the groups). That's why I created a development branch 1.10.0-dev which implements the group_order option to the taxa_abundance_bar_plot method:

qzv_file = '/Users/sbslee/Desktop/dokdo/data/moving-pictures-tutorial/taxa-bar-plots.qzv'
dokdo.taxa_abundance_bar_plot(qzv_file,
                              level=6,
                              count=8,
                              group='body-site',
                              group_order=['right palm', 'left palm', 'gut'],
                              figsize=(10, 7),
                              legend_short=True,
                              artist_kwargs=dict(show_legend=True, xticklabels_fontsize=20))
plt.tight_layout()

example2

In order to use this new feature, you have to install the development version of Dokdo:

$ git clone https://github.com/sbslee/dokdo
$ cd dokdo
$ git checkout 1.10.0-dev
$ pip uninstall dokdo
$ pip install .

Let me know if you have any further questions/requests.

khemlalnirmalkar commented 3 years ago

awesome, thank you so much!! i will use development version.