<p>Two things to try,</p>
<ol>
<li>setting <code>genus=NULL</code>, The logic being it doesn't know which genus to add it to. Just as a precaution setting all blank space within a taxa id in the tree to <code>_</code> ...</li>
</ol>
<pre><code>add.species.to.genus(test_tree, &quot;t1_polytome1&quot;, genus=NULL, where=c(&quot;root&quot;))
</code></pre>
<p>Maybe replace <code>root</code> with <code>random</code> to get it working.</p>
<ol start="2">
<li>alternative using <code>tree</code> instead</li>
</ol>
<pre><code>genus.to.species.tree(test_tree, &quot;t1_polytome1&quot;)
</code></pre>

CC BY-SA 4.0
2023-08-09T08:55:12.277Z
I tried lots of different combinations of parameters but in the end the only thing that resolved the issue was using underscores instead of spaces in the tree labels i.e. `test_tree$tip.label = c("t3_sp1", "t4_sp1", "t5_sp1", "t2_sp1", "t1_sp1")`. Curiously though when the tip labels are set like this, the function works  with `species = "t1_polytome1"` and `species = "t1 polytome1"`. 

WRT (2), `phytools::genus.to.species.tree(test_tree, "t1_polytome1")` returned a tree without `t1_polytome1` added and no error given, maybe because it expects  a genus-level tree.
A. Bollans
CC BY-SA 4.0
2023-08-09T13:02:25.770Z
Thanks @A.Bollans thats good debugging. In tree files removing all blank space is standard practice, in phylip format this a bug.
M__
CC BY-SA 4.0
2023-08-08T18:11:56.470Z
2023-08-09T13:02:54.567Z
2023-08-09T13:02:54.567Z
M__
<p>I have a species tree to which I am trying to add species, which includes a tip &quot;Geissospermum laeve&quot;. When I run:
<code>with_polytomes = phytools::add.species.to.genus(tree, &quot;Geissospermum polytome1&quot;, where='root')</code>, the original tree is returned with the error message: 'could not match your species to a genus  check spelling, including case'.</p>
<p>Reproducible example:</p>
<pre class="lang-r prettyprint-override"><code>test_tree = ape::rtree(5)
test_tree$tip.label = c(&quot;t3 sp1&quot;, &quot;t4 sp1&quot;, &quot;t5 sp1&quot;, &quot;t2 sp1&quot;, &quot;t1 sp1&quot;)
with_polytomes = phytools::add.species.to.genus(test_tree, &quot;t1 polytome1&quot;, where='root')
</code></pre>
<p>I don't understand why this is happening, if anyone could shed some light on what's causing this error that would be great</p>

<phylogenetics><phylogeny>
phytools add.species.to.genus could not match your species to a genus
# phytools add.species.to.genus could not match your species to a genus

(Asked by: username_0 on 2023-08-08)

I have a species tree to which I am trying to add species, which includes a tip "Geissospermum laeve". When I run:
with_polytomes = phytools::add.species.to.genus(tree, "Geissospermum polytome1", where='root'), the original tree is returned with the error message: 'could not match your species to a genus  check spelling, including case'.
Reproducible example:
test_tree = ape::rtree(5)
test_tree$tip.label = c("t3 sp1", "t4 sp1", "t5 sp1", "t2 sp1", "t1 sp1")
with_polytomes = phytools::add.species.to.genus(test_tree, "t1 polytome1", where='root')

I don't understand why this is happening, if anyone could shed some light on what's causing this error that would be great

**Tags:** phylogenetics, phylogeny

---

## 1 answers

### Answer by username_1 on 2023-08-08. Score: 1 | Accepted answer

Two things to try,

setting genus=NULL, The logic being it doesn't know which genus to add it to. Just as a precaution setting all blank space within a taxa id in the tree to _ ...

add.species.to.genus(test_tree, "t1_polytome1", genus=NULL, where=c("root"))

Maybe replace root with random to get it working.

alternative using tree instead

genus.to.species.tree(test_tree, "t1_polytome1")

> **Comments:**
> **username_0**: I tried lots of different combinations of parameters but in the end the only thing that resolved the issue was using underscores instead of spaces in the tree labels i.e. `test_tree$tip.label = c("t3_sp1", "t4_sp1", "t5_sp1", "t2_sp1", "t1_sp1")`. Curiously though when the tip labels are set like this, the function works  with `species = "t1_polytome1"` and `species = "t1 polytome1"`.   WRT (2), `phytools::genus.to.species.tree(test_tree, "t1_polytome1")` returned a tree without `t1_polytome1` added and no error given, maybe because it expects  a genus-level tree.  
> **username_1**: Thanks @A.Bollans thats good debugging. In tree files removing all blank space is standard practice, in phylip format this a bug.  

---

