# Python Tutorial: Data Visualization with Dokdo API

**URL:** <https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380>\
**Category:** Tutorials\
**Tags:** tutorial\
**Created:** [November 9, 2020, 5:45am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380 "2020-11-09T05:45:19Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [July 14, 2022, 11:44pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/21 "2022-07-14T23:44:21Z")

</div>

Thanks so much for your feedback! I created a GitHub [issue](https://github.com/sbslee/dokdo/issues/44) for tracking the addition of the rank abundance curve plot. I will let you know in the comment once it's added. Please let me know if you have other feature requests.

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [July 15, 2022, 1:07am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/22 "2022-07-15T01:07:54Z")

</div>

Quick question: Does the `dokdo.taxa_abundance_box_plot` [method](https://dokdo.readthedocs.io/en/latest/dokdo_api.html#taxa-abundance-box-plot) give you the plot you want?

```auto
import dokdo
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()

qzv_file = '/Users/sbslee/Desktop/dokdo/data/moving-pictures-tutorial/taxa-bar-plots.qzv'
dokdo.taxa_abundance_box_plot(
    qzv_file,
    level=2,
    figsize=(8, 7)
)
plt.tight_layout()

```

 ![taxa_abundance_box_plot-1](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/2/2c2d97bff1dc25e46e1c97646a4f57a20117c55a.png)

---

<div class="post-metadata">

**Author:** ![Alxdu](https://forum.qiime2.org/user_avatar/forum.qiime2.org/alxdu/32/20155_2.png) [@Alxdu](https://forum.qiime2.org/u/Alxdu)\
**Post date:** [July 15, 2022, 1:31am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/23 "2022-07-15T01:31:14Z")

</div>

@sbslee Kind off. It is usually a point or line plot, with relative abundance on log scale (y-axis) and the rank order on the x-axis. But the taxa\_abundance\_box\_plot is similar in a way. I actually make this boxplot type in my workflow but with horizontal orientation.

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [July 15, 2022, 1:40am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/24 "2022-07-15T01:40:28Z")

</div>

Thanks for the explanation. I will search for more papers that have such plot before devising a new plotting method. If you're a Python programmer yourself, you're more than welcome to create a PR 🙂

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [August 23, 2022, 12:12am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/25 "2022-08-23T00:12:17Z")

</div>

Dokdo 1.15.0 is available now, but the tutorial will not be updated anymore for the reasons stated in the edited post above.

---

<div class="post-metadata">

**Author:** ![Anuka](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@Anuka](https://forum.qiime2.org/u/Anuka)\
**Post date:** [October 18, 2022, 12:30pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/26 "2022-10-18T12:30:49Z")

</div>

Dear sbslee,

I'll read more about dokdo cause it seems georgous!! I'm still a begginer in the bioinformatic world... Is it possible to collapse all minority phyla in "others" just with dokdo?? I'm really interested in this scrip...

Thank you in advance!!

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [October 18, 2022, 9:58pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/27 "2022-10-18T21:58:35Z")

</div>

@Anuka,

I'm glad you find Dokdo useful! As for your question, it depends. For example, if your end goal is to create a bar plot showing relative abundance of microbiome and you want to collapse less abundant bacteria as "Others", that's really easy to do with the [dokdo.taxa\_abundance\_bar\_plot](https://dokdo.readthedocs.io/en/latest/dokdo_api.html#dokdo.api.taxa_abundance.taxa_abundance_bar_plot) method. Please take a look at the method's documentation and examples. If you have further questions, please feel free to reply here or leave an issue at the GitHub repository.

Steven

---

<div class="post-metadata">

**Author:** ![Anuka](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@Anuka](https://forum.qiime2.org/u/Anuka)\
**Post date:** [October 19, 2022, 6:45am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/28 "2022-10-19T06:45:13Z")

</div>

Thank you Steven. I installed dokdo in ubuntu, with qiime2. But I'm founding troubles to run the program, since it always says "command not found". Maybe in linux is different than in python??

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [October 19, 2022, 11:23am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/29 "2022-10-19T11:23:37Z")

</div>

@Anuka,

I will need more information to properly assist you:

1. Are you sure you installed Dokdo in the same environment as QIIME 2 (i.e. did you activate the QIIME 2 environment before installing Dokdo)? Can you show me the output of:

```auto
$ conda list

```

1. How did you install Dokdo exactly? Did you follow the installation guide on the website?

```auto
$ conda activate qiime2-2022.8
$ git clone https://github.com/sbslee/dokdo
$ cd dokdo
$ pip install .

```

---

<div class="post-metadata">

**Author:** ![Anuka](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@Anuka](https://forum.qiime2.org/u/Anuka)\
**Post date:** [October 19, 2022, 12:12pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/30 "2022-10-19T12:12:00Z")

</div>

This is the output:

[output.txt](https://forum.qiime2.org/uploads/short-url/8k3iAe6nBMig54G2fV8iqNUdwzi.txt) (4.0 KB)

Yes, That's the script I followed... and I used python -c "import dokdo" and there were no error, but it was after use python -c "%matplotlib inline"...

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [October 19, 2022, 9:46pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/31 "2022-10-19T21:46:00Z")

</div>

I think I understand what's going on.

Although it's true you can use Dokdo in the command-line interface (CLI), in your case you probably want to use it in the application programming interface (API). If you're not familiar with CLI and API, just know that the former means running a program in the terminal and the latter means using a program as library.

In order for you to use Dokdo in API, as I suggest in the [Dokdo API](https://dokdo.readthedocs.io/en/latest/dokdo_api.html) page, I strongly recommend that you learn how to use Jupyter Notebook first. Codes like `%matplotlib inline` are not meant to be run in the terminal but rather in Jupyter Notebook.

When you installed QIIME 2, you actually already installed Jupyter Notebook. If you are unsure how to open a notebook, you can use [Anaconda Navigator](https://docs.anaconda.com/anaconda/navigator/) which is the desktop graphical user interface (GUI) for Anaconda: `Anaconda Navigator` \> `Environments` \> `qiime2-2022.8` \> `Open with Jupyter Notebook`.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Anuka](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/da6949/32.png) [@Anuka](https://forum.qiime2.org/u/Anuka)\
**Post date:** [October 20, 2022, 8:30am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/32 "2022-10-20T08:30:09Z")

</div>

Oh thank you!! I create the jupyter notebook and I'm working on it. I've no problem until trying to execute this command:

dokdo.taxa\_abundance\_bar\_plot(  
qzv\_file,  
figsize=(10, 7)  
)

When I got the next error:

"module 'dokdo' has no attribute 'taxa\_abundance\_bar\_plot'

How can I fix it??

Thank you in advance, and so sorry for the inconvenience caused...

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [October 20, 2022, 10:01am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/33 "2022-10-20T10:01:16Z")

</div>

@Anuka, I will DM you so that we don't overwhelm this post with our replies.

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [December 27, 2022, 5:24am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/34 "2022-12-27T05:24:40Z")

</div>

Dokdo 1.16.0 is available now, but the tutorial will not be updated anymore for the reasons stated in the edited post above.

---

<div class="post-metadata">

**Author:** ![Jin\_PK](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jin_pk/32/15611_2.png) [@Jin\_PK](https://forum.qiime2.org/u/Jin_PK)\
**Post date:** [April 23, 2023, 6:02pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/35 "2023-04-23T18:02:43Z")

</div>

Hi @sbslee,

I have the same issues ("module 'dokdo' has no attribute 'taxa\_abundance\_bar\_plot').

How can I fix it?

Thank you

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [April 24, 2023, 6:27am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/36 "2023-04-24T06:27:13Z")

</div>

@Jin_PK,

Did you install Dokdo using `pip` or `conda`? If so, you probably installed a different `dokdo` program. Mine can only be installed locally. See the installation [page](https://dokdo.readthedocs.io/en/latest/readme.html#getting-started) for details. If you indeed installed locally, please show me the output of the command `$ conda list` in your QIIME 2 environment.

---

<div class="post-metadata">

**Author:** ![Jin\_PK](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jin_pk/32/15611_2.png) [@Jin\_PK](https://forum.qiime2.org/u/Jin_PK)\
**Post date:** [April 24, 2023, 10:33am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/37 "2023-04-24T10:33:54Z")

</div>

I install it with "import python" and run on Jupyter Notebook. I have some problems when calling "dokdo.taxa\_abundance\_bar\_plot". It shows "module 'dokdo' has no attribute 'taxa\_abundance\_bar\_plot'.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [April 24, 2023, 11:51am UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/38 "2023-04-24T11:51:10Z")

</div>

@Jin_PK,

Like I said in the reply, if you installed Dokdo via `conda` you likely installed an incorrect program that happens to have the same name, because I never uploaded Dokdo to `pip` or `conda`. Please follow the instruction I've linked in the previous reply:

```auto
$ git clone https://github.com/sbslee/dokdo
$ cd dokdo
$ pip install .

```

---

<div class="post-metadata">

**Author:** ![nadia10639](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nadia10639/32/15679_2.png) [@nadia10639](https://forum.qiime2.org/u/nadia10639)\
**Post date:** [May 2, 2023, 5:11pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/39 "2023-05-02T17:11:28Z")

</div>

Hello , Do you know how I can add a P-value to the box plots ?

---

<div class="post-metadata">

**Author:** ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)\
**Post date:** [May 2, 2023, 11:24pm UTC](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380/40 "2023-05-02T23:24:54Z")

</div>

@nadia10639,

You can use the `dokdo.addsig` method (see the [docs](https://dokdo.readthedocs.io/en/latest/dokdo_api.html#dokdo.api.addsig.addsig)):

```auto
import dokdo
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
vector_file = '/Users/sbslee/Desktop/dokdo/data/moving-pictures-tutorial/faith_pd_vector.qza'
metadata_file = '/Users/sbslee/Desktop/dokdo/data/moving-pictures-tutorial/sample-metadata.tsv'
ax = dokdo.alpha_diversity_plot(vector_file, metadata_file, 'body-site', figsize=(8, 5))
dokdo.addsig(0, 1, 20, t='***', ax=ax)
dokdo.addsig(1, 2, 26, t='ns', ax=ax)
plt.tight_layout()

```

 ![addsig](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/0/0ec48c602fc6495f70aeced0ffcf18e075c5e3b2.jpeg)

[Previous page](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380.md?page=1)

[Next page](https://forum.qiime2.org/t/python-tutorial-data-visualization-with-dokdo-api/17380.md?page=3)
