# IndexError: index 0 is out of bounds for axis 0 with size 0

**URL:** https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465
**Category:** Other Bioinformatics Tools
**Tags:** micom
**Created:** [June 11, 2024, 1:22pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465 "2024-06-11T13:22:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![herrynguyen1706](https://forum.qiime2.org/user_avatar/forum.qiime2.org/herrynguyen1706/32/18739_2.png) [@herrynguyen1706](https://forum.qiime2.org/u/herrynguyen1706)
#### Post date: [June 11, 2024, 1:22pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/1 "2024-06-11T13:22:48Z")

</div>

Dear All,  
I am trying to run model microbiota-wide metabolism with MICOM. I upload my tax data and then I build community models. However, they solve the problem below. Could you please help me with this issue?  
Thank you very much.  
""""""""""""""""""""""

1. upload data  
import pandas as pd

metadata = pd.read\_table("/content/data/MyDrive/hiv/dinh/metadatadinh.tsv").rename(columns={"sample-id": "sample\_id"})

tax = pd.merge(tax, metadata, on="sample\_id")

tax

Unnamed: 0 sample\_id abundance relative genus id disease Alcohol\_s BMI\_s Bingeing\_s ... host\_s isolation\_source\_s source\_s tissue\_s dataset sequencer region total\_reads study DiseaseState  
0 157 027OB 2156 0.000464 g\_\_Acidaminococcus g\_\_Acidaminococcus H Drinker 24.78 Not\_binge\_drinker ... Human Stool Intestine hiv\_dinh 454 V3-V5 1765 hiv\_dinh H  
1 7 027OB 2156 0.000464 g\_\_Alistipes g\_\_Alistipes H Drinker 24.78 Not\_binge\_drinker ... Human Stool Intestine hiv\_dinh 454 V3-V5 1765 hiv\_dinh H  
2 1 027OB 2156 0.001391 g\_\_Alloprevotella g\_\_Alloprevotella H Drinker 24.78 Not\_binge\_drinker ... Human Stool Intestine hiv\_dinh 454 V3-V5 1765 hiv\_dinh H  
3 20 027OB 2156 0.001391 g\_\_Anaeroplasma g\_\_Anaeroplasma H Drinker 24.78 Not\_binge\_drinker ... Human

1. build model  
from micom.workflows import build  
from micom import Community  
import pandas as pd

# Convert sample\_id column to string type

tax['sample\_id'] = tax['sample\_id'].astype('str')

# Call the build function

manifest = build(tax, "agora103\_genus.qza", "models", solver="osqp",  
cutoff=2.5e-2, threads=2)

## Running ━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6% -:--:--

RemoteTraceback Traceback (most recent call last)  
RemoteTraceback:  
"""  
Traceback (most recent call last):  
File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker  
result = (True, func(\*args, \*\*kwds))  
File "/usr/local/lib/python3.10/dist-packages/micom/workflows/build.py", line 29, in build\_and\_save  
com = Community(  
File "/usr/local/lib/python3.10/dist-packages/micom/community.py", line 213, in **init**  
taxonomy = unify\_rank\_prefixes(taxonomy, manifest)  
File "/usr/local/lib/python3.10/dist-packages/micom/taxonomy.py", line 128, in unify\_rank\_prefixes  
tax\_prefixes = rank\_prefixes(taxonomy)  
File "/usr/local/lib/python3.10/dist-packages/micom/taxonomy.py", line 107, in rank\_prefixes  
{r: manifest[r].str.extract(r"^([a-z]**)").iloc[0, 0] for r in ranks}  
File "/usr/local/lib/python3.10/dist-packages/micom/taxonomy.py", line 107, in   
{r: manifest[r].str.extract(r"^([a-z]**)").iloc[0, 0] for r in ranks}  
File "/usr/local/lib/python3.10/dist-packages/pandas/core/indexing.py", line 1096, in **getitem**  
return self.obj.\_get\_value(\*key, takeable=self.\_takeable)  
File "/usr/local/lib/python3.10/dist-packages/pandas/core/frame.py", line 3868, in \_get\_value  
return series.\_values[index]  
IndexError: index 0 is out of bounds for axis 0 with size 0. """

The above exception was the direct cause of the following exception:

IndexError Traceback (most recent call last)  
 in \<cell line: 9\>()  
7  
8 # Call the build function  
----\> 9 manifest = build(tax, "agora103\_genus.qza", "models", solver="osqp",  
10 cutoff=2.5e-2, threads=2)

4 frames  
/usr/lib/python3.10/multiprocessing/pool.py in next(self, timeout)  
871 if success:  
872 return value  
--\> 873 raise value  
874  
875 **next** = next # XXX

IndexError: index 0 is out of bounds for axis 0 with size 0

---

<div class="post-metadata">

### Author: ![jwdebelius](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwdebelius/32/9655_2.png) [@jwdebelius](https://forum.qiime2.org/u/jwdebelius)
#### Post date: [June 11, 2024, 1:23pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/2 "2024-06-11T13:23:36Z")

</div>

Hi @herrynguyen1706,

Welcome to the :qiime2: forum! I just wanted to let you know that I re-categorized this as "other bioinformatic tools" since it's a question about MICOM and not QIIME 2 (or q2-micom).

Best,  
Justine

---

<div class="post-metadata">

### Author: ![cherman2](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cherman2/32/17129_2.png) [@cherman2](https://forum.qiime2.org/u/cherman2)
#### Post date: [June 11, 2024, 2:47pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/3 "2024-06-11T14:47:10Z")

</div>

Hi @herrynguyen1706,  
I am going to ping the dev of MICOM, @cdiener, to see if he has any suggestions.

---

<div class="post-metadata">

### Author: ![herrynguyen1706](https://forum.qiime2.org/user_avatar/forum.qiime2.org/herrynguyen1706/32/18739_2.png) [@herrynguyen1706](https://forum.qiime2.org/u/herrynguyen1706)
#### Post date: [June 11, 2024, 3:08pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/4 "2024-06-11T15:08:07Z")

</div>

Many thanks for your update. I hope someone can help me with that. Thank again.

---

<div class="post-metadata">

### Author: ![herrynguyen1706](https://forum.qiime2.org/user_avatar/forum.qiime2.org/herrynguyen1706/32/18739_2.png) [@herrynguyen1706](https://forum.qiime2.org/u/herrynguyen1706)
#### Post date: [June 11, 2024, 6:24pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/5 "2024-06-11T18:24:18Z")

</div>

Dear Diener,  
I am trying to run model microbiota-wide metabolism with MICOM. I upload my tax data and then I build community models. However, it shows the problem below. Could you please help me with this issue?  
Thank you very much.  
""""""""""""""""""""""

1. upload data  
import pandas as pd

metadata = pd.read\_table("/content/data/MyDrive/hiv/dinh/metadatadinh.tsv").rename(columns={"sample-id": "sample\_id"})

tax = pd.merge(tax, metadata, on="sample\_id")

tax

Unnamed: 0 sample\_id abundance relative genus id disease Alcohol\_s BMI\_s Bingeing\_s ... host\_s isolation\_source\_s source\_s tissue\_s dataset sequencer region total\_reads study DiseaseState  
0 157 027OB 2156 0.000464 g\_\_Acidaminococcus g\_\_Acidaminococcus H Drinker 24.78 Not\_binge\_drinker ... Human Stool Intestine hiv\_dinh 454 V3-V5 1765 hiv\_dinh H  
1 7 027OB 2156 0.000464 g\_\_Alistipes g\_\_Alistipes H Drinker 24.78 Not\_binge\_drinker ... Human Stool Intestine hiv\_dinh 454 V3-V5 1765 hiv\_dinh H  
2 1 027OB 2156 0.001391 g\_\_Alloprevotella g\_\_Alloprevotella H Drinker 24.78 Not\_binge\_drinker ... Human Stool Intestine hiv\_dinh 454 V3-V5 1765 hiv\_dinh H  
3 20 027OB 2156 0.001391 g\_\_Anaeroplasma g\_\_Anaeroplasma H Drinker 24.78 Not\_binge\_drinker ... Human

1. build model  
from micom.workflows import build  
from micom import Community  
import pandas as pd

# Convert sample\_id column to string type

tax['sample\_id'] = tax['sample\_id'].astype('str')

# Call the build function

manifest = build(tax, "agora103\_genus.qza", "models", solver="osqp",  
cutoff=2.5e-2, threads=2)

## Running ━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6% -:--:--

RemoteTraceback Traceback (most recent call last)  
RemoteTraceback:  
"""  
Traceback (most recent call last):  
File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker  
result = (True, func(\*args, \*\*kwds))  
File "/usr/local/lib/python3.10/dist-packages/micom/workflows/build.py", line 29, in build\_and\_save  
com = Community(  
File "/usr/local/lib/python3.10/dist-packages/micom/community.py", line 213, in **init**  
taxonomy = unify\_rank\_prefixes(taxonomy, manifest)  
File "/usr/local/lib/python3.10/dist-packages/micom/taxonomy.py", line 128, in unify\_rank\_prefixes  
tax\_prefixes = rank\_prefixes(taxonomy)  
File "/usr/local/lib/python3.10/dist-packages/micom/taxonomy.py", line 107, in rank\_prefixes  
{r: manifest[r].str.extract(r"^([a-z]**)").iloc[0, 0] for r in ranks}  
File "/usr/local/lib/python3.10/dist-packages/micom/taxonomy.py", line 107, in  
{r: manifest[r].str.extract(r"^([a-z]**)").iloc[0, 0] for r in ranks}  
File "/usr/local/lib/python3.10/dist-packages/pandas/core/indexing.py", line 1096, in **getitem**  
return self.obj.\_get\_value(\*key, takeable=self.\_takeable)  
File "/usr/local/lib/python3.10/dist-packages/pandas/core/frame.py", line 3868, in \_get\_value  
return series.\_values[index]  
IndexError: index 0 is out of bounds for axis 0 with size 0. """

The above exception was the direct cause of the following exception:

IndexError Traceback (most recent call last)  
in \<cell line: 9\>()  
7  
8 # Call the build function  
----\> 9 manifest = build(tax, "agora103\_genus.qza", "models", solver="osqp",  
10 cutoff=2.5e-2, threads=2)

4 frames  
/usr/lib/python3.10/multiprocessing/pool.py in next(self, timeout)  
871 if success:  
872 return value  
--\> 873 raise value  
874  
875 **next** = next # XXX

IndexError: index 0 is out of bounds for axis 0 with size 0

---

<div class="post-metadata">

### Author: ![cherman2](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cherman2/32/17129_2.png) [@cherman2](https://forum.qiime2.org/u/cherman2)
#### Post date: [June 13, 2024, 4:44pm UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/6 "2024-06-13T16:44:00Z")

</div>

Hi @herrynguyen1706,  
Please refrain from posting duplicate posts in the future. I moved this post from [Preparing and importing custom diets and taxonomy files for q2-MICOM - #3 by Mehrbod\_Estaki](https://forum.qiime2.org/t/preparing-and-importing-custom-diets-and-taxonomy-files-for-q2-micom/19857/3) to your original post to keep things on topic.

---

<div class="post-metadata">

### Author: ![cdiener](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cdiener/32/7026_2.png) [@cdiener](https://forum.qiime2.org/u/cdiener)
#### Post date: [August 2, 2024, 8:18am UTC](https://forum.qiime2.org/t/indexerror-index-0-is-out-of-bounds-for-axis-0-with-size-0/30465/7 "2024-08-02T08:18:01Z")

</div>

Hi sorry for the late reply. For some reason I did not see the post. Basically it's complaining that you have no ranks in your taxonomy table. I do see the "genus" one in your post but it's not bein picked up. Could you check that your table was read correcly? What does `tax.columns` give you?
