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

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

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

2 Likes

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

2 Likes

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

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

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 to your original post to keep things on topic.

2 Likes