# ghost-tree index out of range error

**URL:** https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275
**Category:** Other Bioinformatics Tools
**Tags:** ghost-tree
**Created:** [January 20, 2020, 10:02am UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275 "2020-01-20T10:02:16Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![iaia](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/2bfe46/32.png) [@iaia](https://forum.qiime2.org/u/iaia)
#### Post date: [January 20, 2020, 10:02am UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/1 "2020-01-20T10:02:16Z")

</div>

Dear all,

I am trying to use ghost-tree through conda. I have made the files to use based on [q2-ghost-tree/small\_test\_files/original-non-qiime-files at master · JTFouquier/q2-ghost-tree · GitHub](https://github.com/JTFouquier/q2-ghost-tree/tree/master/small_test_files/original-non-qiime-files).

However,  
I am getting this errors:  
Traceback (most recent call last):  
File "/Users/Irene/miniconda3/bin/ghost-tree", line 403, in   
cli()  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/click/core.py", line 764, in **call**  
return self.main(\*args, \*\*kwargs)  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/click/core.py", line 717, in main  
rv = self.invoke(ctx)  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/click/core.py", line 1137, in invoke  
return \_process\_result(sub\_ctx.command.invoke(sub\_ctx))  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/click/core.py", line 1137, in invoke  
return \_process\_result(sub\_ctx.command.invoke(sub\_ctx))  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/click/core.py", line 956, in invoke  
return ctx.invoke(self.callback, \*\*ctx.params)  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/click/core.py", line 555, in invoke  
return callback(\*args, \*\*kwargs)  
File "/Users/Irene/miniconda3/bin/ghost-tree", line 365, in hybrid\_tree  
foundation\_taxonomy\_file)  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/ghosttree/scaffold/hybridtree.py", line 104, in extensions\_onto\_foundation  
graft\_level)  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/ghosttree/scaffold/hybridtree.py", line 196, in \_extension\_genus\_accession\_dict  
graft\_level)  
File "/Users/Irene/miniconda3/lib/python3.7/site-packages/ghosttree/scaffold/hybridtree.py", line 237, in \_create\_taxonomy\_dict  
taxonomy\_line = splitline[1].strip()  
IndexError: list index out of range

Coudl anyone help understand what I am doing wrong?  
Thanks!

---

<div class="post-metadata">

### Author: ![Mehrbod\_Estaki](https://forum.qiime2.org/user_avatar/forum.qiime2.org/mehrbod_estaki/32/4001_2.png) [@Mehrbod\_Estaki](https://forum.qiime2.org/u/Mehrbod_Estaki)
#### Post date: [January 20, 2020, 9:48pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/2 "2020-01-20T21:48:41Z")

</div>



---

<div class="post-metadata">

### Author: ![Jennifer\_Fouquier](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jennifer_fouquier/32/519_2.png) [@Jennifer\_Fouquier](https://forum.qiime2.org/u/Jennifer_Fouquier)
#### Post date: [January 22, 2020, 3:07am UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/3 "2020-01-22T03:07:58Z")

</div>

Hi Irene, unfortunately, my school schedule is really packed this week. I'll have a chance to get to this later tomorrow or Thursday. If for some reason I forget, please remind me. I've had a lot going on lately. Thank you!

---

<div class="post-metadata">

### Author: ![Jennifer\_Fouquier](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jennifer_fouquier/32/519_2.png) [@Jennifer\_Fouquier](https://forum.qiime2.org/u/Jennifer_Fouquier)
#### Post date: [January 24, 2020, 2:06pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/4 "2020-01-24T14:06:46Z")

</div>

Hi Irene! Welcome to the QIIME2 forum and community. 👋 Sorry this took so long, my week has been a little crazy. 🙂 Thank you so much for always providing such clear and detailed help requests! Posting on the forum is great because other users can get help. The formatting here is better, too!

After looking at the files that I have from you in my email, It looks like you are providing a taxonomy line like this 'OTU\_207 k\_\_Fungi;p\_\_Basidiomycota;c\_\_Agaricomycetes;o\_\_Agaricales;f\_\_Amanitaceae' in your extension tree taxonomy file which does not go down to genus and species. Normally, the taxonomy file would have g\_\_unclassified;s\_\_unclassified or g\_\_unidentified;s\_\_unidentified or something along those lines as placeholders so that a lot of the microbiome bioinformatics tools see things as consistent. This is a "standard", as you can imagine consistency is easier to work with in computer programming. You will need to repair your taxonomy file to have ';g\_\_unclassified;s\_\_unclassified' on all the lines just as placeholders. You can find `concatenate` functions in Excel to add this string to each line or do this in Python. I'm not sure your computational level, so if you cannot do this or find help in your lab, let me know.

Now, normally _ghost-tree_ uses genera to make smaller groups of related fungi, but since you do not have genera (they're all unclassified), you will have to do a custom tree. I added this feature: [Options for plugin inputs/arguments (ghost-tree progress)](https://forum.qiime2.org/t/options-for-plugin-inputs-arguments-ghost-tree-progress/3862) a while back but I have not tested it too much besides on smaller trees. You don't need to read the details, but you can see the cool images showing how the graft level option/flag creates trees at different taxonomic groupings. When you're in command line, type `--help` after your ghost-tree command, then you will see the option to graft at a higher level. So you will do `--graft-level f` in your case.

 ![Screen Shot 2020-01-24 at 7.09.21 AM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/b/b1785832be36e5898871a7eb9670171176272a5c.png)  
 ![Screen Shot 2018-04-19 at 9.35.51 PM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/6/697bf1977216d34d595c76e40b063aac7df1b8df.png)  
Luckily your tree will be fairly small, so make sure to open in a tree viewer and make sure the groups make sense to you after you create your custom tree. OTUs in the same family should be grouped together, of course! 😅. If they aren't let me know. I would also try to compare your diversity analysis results if you plan to do them to non-phylogenetic or taxonomic diversity analysis methods such as bray-curtis or binary-jaccard.

Let me know if you have any other questions, and feel free to email me any cool results. Would love to see them. 🤩

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [January 24, 2020, 3:01pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/5 "2020-01-24T15:01:05Z")

</div>



---

<div class="post-metadata">

### Author: ![iaia](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/2bfe46/32.png) [@iaia](https://forum.qiime2.org/u/iaia)
#### Post date: [January 24, 2020, 3:06pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/6 "2020-01-24T15:06:29Z")

</div>

Dear Jennifer,

thanks a lot for your answer! it is very clear!

Do I need to change the taxonomy also in the foundation taxonomy with genus and species space as unidentified?

Can I use --graft-level f with the ghost-tree scaffold hybrid-tree-foundation-tree, and do I use after the command or in a specific place in the command line?

I will be happy to show the final results!!

Thanks a lot again for your answer!

---

<div class="post-metadata">

### Author: ![Jennifer\_Fouquier](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jennifer_fouquier/32/519_2.png) [@Jennifer\_Fouquier](https://forum.qiime2.org/u/Jennifer_Fouquier)
#### Post date: [January 24, 2020, 3:28pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/7 "2020-01-24T15:28:03Z")

</div>

I can't remember off the top of my head. I might not have enforced that check for the foundation tree, but I should have required the taxonomy to go down to the species level. It's best to keep things consistent so I would repair both.

If you type `ghost-tree scaffold hybrid-tree-foundation-tree --help` you will see the option for other graft levels, so yes it works. _ghost-tree_ on its own (used outside of the QIIME2 environment) is picky about the order of things so just put `--graft-level f` at the end.

---

<div class="post-metadata">

### Author: ![iaia](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/2bfe46/32.png) [@iaia](https://forum.qiime2.org/u/iaia)
#### Post date: [January 24, 2020, 4:49pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/8 "2020-01-24T16:49:52Z")

</div>

Perfect!  
so I changed both the extensions and foundation with g\_\_unidentified;s\_\_unidentified for the extension taxonomy and unidentified;unidentified for the foundation taxonomy.

then I ran  
`ghost-tree scaffold hybrid-tree-foundation-tree EXTENSION_TREES_OTU_MAP.txt EXTENSION_TREES_TAXONOMY_FILE.txt EXTENSION_TREES_SEQUENCE_FILE.fasta FOUNDATION_TREE_FILE.nwk FOUNDATION_TAXONOMY_FILE.txt GHOST_TREE_OUTPUT_FOLDER --graft-level f`  
I understood this is the way I should do it , but I still get the same exact error.. I have tried to move the option --graft-level but still same error. I have checked the code in github and other than the graft level i cannot see any other error. I really would like to get the hybrid tree done since in my case this is the best method.  
thanks!!!!

[EXTENSION\_TREES\_TAXONOMY\_FILE.txt](https://forum.qiime2.org/uploads/short-url/npNNa9dFJZ0iMc2yJrAwAEpmlSS.txt) (28.9 KB) [FOUNDATION\_TAXONOMY\_FILE.txt](https://forum.qiime2.org/uploads/short-url/7KRHgD6IKVp7ljU6zVJVpYk1Dku.txt) (8.7 KB)

---

<div class="post-metadata">

### Author: ![Jennifer\_Fouquier](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jennifer_fouquier/32/519_2.png) [@Jennifer\_Fouquier](https://forum.qiime2.org/u/Jennifer_Fouquier)
#### Post date: [January 24, 2020, 5:57pm UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/9 "2020-01-24T17:57:47Z")

</div>

Hi Irene,

It looks like there is an issue with some inconsistency in the tabs in your extension file but you can verify the other files as well.

If I type `cat -t EXTENSION_TREES_TAXONOMY_FILE.txt` into the terminal, I can see some tabs and some without tabs on line to line. I'm not sure how these were introduced. So you can search for how to repair the tabs and spacing in your file.

 ![Screen Shot 2020-01-24 at 10.50.53 AM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/9/9fe98e669eb096d0798a36cf1d80296399c1cc5f.png)

The '^I' shows the inconsistency. This inconsistency will cause errors in the code because it's expecting the same organization on each line.

---

<div class="post-metadata">

### Author: ![iaia](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/2bfe46/32.png) [@iaia](https://forum.qiime2.org/u/iaia)
#### Post date: [January 27, 2020, 10:12am UTC](https://forum.qiime2.org/t/ghost-tree-index-out-of-range-error/13275/10 "2020-01-27T10:12:58Z")

</div>

Dear Jennifer,

you were totally right! now it works perfectly! I will be happy to show the results once I annotate the tree, but for now I can tell you that all the OTUs were correctly placed!

Thank you so much for all your help!!!
