Hello everyone,
I have a rookie question but unfortunately I am unable to find an answer myself. I would like to generate a cladrogram using ggtree package based on the taxonomy of my strains.
As I know the taxonomic classification of he strains I thought that I could use that to generate a tree in Newick format, for that I used the makeNewick
function from the Taxonomizr package.
setwd("D:/R/phylogeny/Jemime_collection")
taxofile<-"cladotest.tab"
Taxo <- read.table (taxofile, check.names = FALSE, header = TRUE, dec = ".", sep = "\t", comment.char = "")
which got me this, so far so good:
Taxo
family genus species
1 Actinomycetaceae Actinobaculum Actinobaculum_sp_oral_taxon_183
2 Actinomycetaceae Actinomyces Actinomyces_bouchesdurhonensis
3 Actinomycetaceae Actinomyces Actinomyces_dentalis
4 Actinomycetaceae Actinomyces Actinomyces_gerencseriae
5 Actinomycetaceae Actinomyces Actinomyces_graevenitzii
6 Actinomycetaceae Actinomyces Actinomyces_israelii
7 Actinomycetaceae Actinomyces Actinomyces_johnsonii
8 Actinomycetaceae Actinomyces Actinomyces_massiliensis
9 Actinomycetaceae Actinomyces Actinomyces_naeslundii
10 Actinomycetaceae Actinomyces Actinomyces_oris
11 Actinomycetaceae Actinomyces Actinomyces_SGB17154
12 Actinomycetaceae Actinomyces Actinomyces_SGB17168
13 Actinomycetaceae Actinomyces Actinomyces_sp_ICM47
After that I tried to generate a newick tree from this using the makenewick function, which seemed to work :
tree <- makeNewick(Taxo)
tree
[1] "(((Actinobaculum_sp_oral_taxon_183)Actinobaculum,(Actinomyces_bouchesdurhonensis,Actinomyces_dentalis,Actinomyces_gerencseriae,Actinomyces_graevenitzii,Actinomyces_israelii,Actinomyces_johnsonii,Actinomyces_massiliensis,Actinomyces_naeslundii,Actinomyces_oris,Actinomyces_SGB17154,Actinomyces_SGB17168,Actinomyces_sp_ICM47)Actinomyces)Actinomycetaceae);"
However, when I tried to use this newick tree to generate the tree I got an error message:
ggtree(tree)
> Error in `fortify()`:
! `data` must be a <data.frame>, or an object coercible by `fortify()`, not the string "(((Actinobaculum_sp_oral_ta...".
Run `rlang::last_trace()` to see where the error occurred.
I ran line indicated and got this:
<error/rlang_error>
Error in `fortify()`:
! `data` must be a <data.frame>, or an object coercible by `fortify()`, not the string "(((Actinobaculum_sp_oral_ta...".
---
Backtrace:
Run rlang::last_trace(drop = FALSE) to see 2 hidden frames.
Which did not help me understand how and why my tree was not data.frame and how to convert it into a data.frame.
Has anyone an idea on how to solve this problem?
Please use the formatting bar (especially the
code
option) to present your post better. You can use backticks for inline code (`text` becomestext
), or use one of (a) the option highlighted in the image below/ (b) fenced code blocks for multi-line code. Fenced code blocks are useful in syntax highlighting. If your code has long lines with a single command, break those lines into multiple lines with proper escape sequences so they're easier to read and still run when copy-pasted. I've done it for you this time.Thank you, my apologies for the improper formating.