text: user8757: I am using ggtree to draw a phylogenetic tree.
  Some taxa IDs have a 0 at the beginning.
  However, when I plot the tiplabel the leading zero is automatically dropped. How do I retain the leading zero?
  Thanks.
  The code and tree file and metadata file are attached. I would appreciate any help.
  setwd('G:\\Experiments\\Paper\\Torula\\06_iqtree')   
  dir()
  
  # Load required packages
  library(xlsx)
  library(ggtree)
  library(treeio)
  library(ggplot2)
  
  # Read tree
  tre <- read.iqtree("concatenate_iqtree2.treefile")
  tre_tbl <- fortify(tre)
  # Read associated information table
  metadf <- read.xlsx('G:\\Experiments\\Paper\\Torula\\00_data\\Torula_taxa.xlsx', sheetIndex = 1)
  
  # Plot tree
  ggtree(tre) %<+% metadf + 
      # our own taxa darkblue
      # type strain bold
      geom_tiplab(aes(subset = (New == 1 & Type == 1), 
                      label = paste0('bolditalic(', Genus, ')~bolditalic(', Epithet, ')~bold(', Collection,')~bold(', Number,')')), 
                  color = 'darkblue', parse = T) + 
      geom_tiplab(aes(subset = (New == 0 & Type == 1), 
                      label = paste0('bolditalic(', Genus, ')~bolditalic(', Epithet, ')~bold(', Collection,')~bold(', Number,')')), 
                  color = 'black', parse = T) + 
      geom_tiplab(aes(subset = (New == 0 & Type == 0), 
                      label = paste0('italic(', Genus, ')~italic(', Epithet, ')', '~', Collection,'~', Number)), 
                  color = 'black', parse = T) + 
      
      geom_text(aes(label= UFboot), vjust = 0, hjust = 1, size = 3) +
      xlim(NA,0.5)
  
  
  Some taxa in the figure 
  
  user3848: I like both the methods and the study. ggplot2 is R's standout package/library and the library ggtree looks great.
  Anyway, I would know how to solve this in Python or Perl and I'll use the same logic for R. My suspicion is R is automatically type casting your metadata and therefore has no option but to remove the zero.
  Simply convert your integer range into a string, viz.
   Number2 = as.character(Number)
  
  or simply in situ
  as.character(Number)
  
  This doesn't make any difference to your output, who cares whether its and integer or string and forces R into retaining the zero, '0'.
  
  Note below that tried and didn't work. A string should be immutable.
  The suspicion is the the '0' is being removed at an earlier point in the code, i.e. as soon as it type casts it - zero disappears.
  What I would do some print outs of the variable between its import and writing to disk. What I suspect is the conversion to string needs to occur earlier.
  
  Second idea
  The other possibility is to wrap the metadata in double/single quotes in the Excel file (or flat file). This way R cannot force it into an integer when it is imported and must retain it as a string. I'd be amazed if R could wriggle out of that.
  
original_text: 8757: <p>I am using <code>ggtree</code> to draw a phylogenetic tree.</p>
  <p>Some taxa IDs have a 0 at the beginning.</p>
  <p>However, when I plot the tiplabel the leading zero is automatically dropped. How do I retain the leading zero?</p>
  <p>Thanks.</p>
  <p>The code and tree file and metadata file are attached. I would appreciate any help.</p>
  <pre><code>setwd('G:\\Experiments\\Paper\\Torula\\06_iqtree')   
  dir()
  
  # Load required packages
  library(xlsx)
  library(ggtree)
  library(treeio)
  library(ggplot2)
  
  # Read tree
  tre &lt;- read.iqtree(&quot;concatenate_iqtree2.treefile&quot;)
  tre_tbl &lt;- fortify(tre)
  # Read associated information table
  metadf &lt;- read.xlsx('G:\\Experiments\\Paper\\Torula\\00_data\\Torula_taxa.xlsx', sheetIndex = 1)
  
  # Plot tree
  ggtree(tre) %&lt;+% metadf + 
      # our own taxa darkblue
      # type strain bold
      geom_tiplab(aes(subset = (New == 1 &amp; Type == 1), 
                      label = paste0('bolditalic(', Genus, ')~bolditalic(', Epithet, ')~bold(', Collection,')~bold(', Number,')')), 
                  color = 'darkblue', parse = T) + 
      geom_tiplab(aes(subset = (New == 0 &amp; Type == 1), 
                      label = paste0('bolditalic(', Genus, ')~bolditalic(', Epithet, ')~bold(', Collection,')~bold(', Number,')')), 
                  color = 'black', parse = T) + 
      geom_tiplab(aes(subset = (New == 0 &amp; Type == 0), 
                      label = paste0('italic(', Genus, ')~italic(', Epithet, ')', '~', Collection,'~', Number)), 
                  color = 'black', parse = T) + 
      
      geom_text(aes(label= UFboot), vjust = 0, hjust = 1, size = 3) +
      xlim(NA,0.5)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Yafxt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yafxt.png" alt="enter image description here" /></a>
  Some taxa in the figure <a href="https://i.stack.imgur.com/D0K42.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D0K42.png" alt="enter image description here" /></a></p>
   3848: <p>I like both the methods and the study. <code>ggplot2</code> is R's standout package/library and the library <code>ggtree</code> looks great.</p>
  <p>Anyway, I would know how to solve this in Python or Perl and I'll use the same logic for R. My suspicion is R is automatically type casting your metadata and therefore has no option but to remove the zero.</p>
  <p>Simply convert your integer range into a string, viz.</p>
  <pre><code> Number2 = as.character(Number)
  </code></pre>
  <p>or simply <em>in situ</em></p>
  <pre><code>as.character(Number)
  </code></pre>
  <p>This doesn't make any difference to your output, who cares whether its and integer or string and forces R into retaining the zero, '0'.</p>
  <hr />
  <p>Note below that tried and didn't work. A string should be immutable.
  The suspicion is the the '0' is being removed at an earlier point in the code, i.e. as soon as it type casts it - zero disappears.</p>
  <p>What I would do some print outs of the variable between its import and writing to disk. What I suspect is the conversion to string needs to occur earlier.</p>
  <hr />
  <p><strong>Second idea</strong>
  The other possibility is to wrap the metadata in double/single quotes in the Excel file (or flat file). This way R cannot force it into an integer when it is imported and must retain it as a string. I'd be amazed if R could wriggle out of that.</p>
  