Skip to contents
library("tidytree") # first load to disable warning about phylo class
library("MiscMetabar")
library("phangorn")

data(data_fungi)
df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 9000)
df_tree <- quiet(build_phytree_pq(df, nb_bootstrap = 5))
data_fungi_tree <- merge_phyloseq(df, phyloseq::phy_tree(df_tree$ML$tree))
library("treeio")
library("ggtree")

ggtree(data_fungi_tree@phy_tree, layout = "ellipse") + geom_tiplab()

ggtree(as.treedata(df_tree$ML), layout = "slanted")

ggdensitree(df_tree$ML_bs, alpha = .3, colour = "steelblue") +
  geom_tiplab(size = 3) + hexpand(.35)

ggtree(as.treedata(df_tree$ML)) +
  geom_text(aes(x = branch, label = AA_subs, vjust = -.5), size = 1)

tax_tab <- as.data.frame(data_fungi_tree@tax_table)
tax_tab <- data.frame("OTU" = rownames(tax_tab), tax_tab)
p <- ggtree(as.treedata(data_fungi_tree@phy_tree)) %<+%
  tax_tab
p + geom_tippoint(aes(color = Class, shape = Phylum)) +
  geom_text(aes(label = Genus), hjust = -0.2, size = 2)

ggtree(as.treedata(data_fungi_tree@phy_tree), branch.length = "none") %<+%
  tax_tab +
  geom_tippoint(aes(color = Class, shape = Phylum), size = 2)

Session information

sessionInfo()
#> R version 4.3.2 (2023-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> time zone: UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] ggtree_3.10.0     treeio_1.26.0     phangorn_2.11.1   ape_5.7-1        
#>  [5] MiscMetabar_0.7.8 dplyr_1.1.4       dada2_1.30.0      Rcpp_1.0.12      
#>  [9] ggplot2_3.4.4     phyloseq_1.46.0   tidytree_0.4.6   
#> 
#> loaded via a namespace (and not attached):
#>   [1] RColorBrewer_1.1-3          jsonlite_1.8.8             
#>   [3] magrittr_2.0.3              farver_2.1.1               
#>   [5] rmarkdown_2.25              fs_1.6.3                   
#>   [7] zlibbioc_1.48.0             ragg_1.2.7                 
#>   [9] vctrs_0.6.5                 multtest_2.58.0            
#>  [11] memoise_2.0.1               Rsamtools_2.18.0           
#>  [13] RCurl_1.98-1.14             htmltools_0.5.7            
#>  [15] S4Arrays_1.2.0              Rhdf5lib_1.24.2            
#>  [17] SparseArray_1.2.4           rhdf5_2.46.1               
#>  [19] gridGraphics_0.5-1          sass_0.4.8                 
#>  [21] bslib_0.6.1                 desc_1.4.3                 
#>  [23] plyr_1.8.9                  DECIPHER_2.30.0            
#>  [25] cachem_1.0.8                GenomicAlignments_1.38.2   
#>  [27] igraph_2.0.1.1              lifecycle_1.0.4            
#>  [29] iterators_1.0.14            pkgconfig_2.0.3            
#>  [31] Matrix_1.6-1.1              R6_2.5.1                   
#>  [33] fastmap_1.1.1               GenomeInfoDbData_1.2.11    
#>  [35] MatrixGenerics_1.14.0       digest_0.6.34              
#>  [37] aplot_0.2.2                 colorspace_2.1-0           
#>  [39] ShortRead_1.60.0            patchwork_1.2.0            
#>  [41] S4Vectors_0.40.2            textshaping_0.3.7          
#>  [43] GenomicRanges_1.54.1        RSQLite_2.3.5              
#>  [45] hwriter_1.3.2.1             vegan_2.6-4                
#>  [47] labeling_0.4.3              fansi_1.0.6                
#>  [49] abind_1.4-5                 mgcv_1.9-0                 
#>  [51] compiler_4.3.2              bit64_4.0.5                
#>  [53] withr_3.0.0                 BiocParallel_1.36.0        
#>  [55] DBI_1.2.1                   highr_0.10                 
#>  [57] MASS_7.3-60                 DelayedArray_0.28.0        
#>  [59] biomformat_1.30.0           permute_0.9-7              
#>  [61] tools_4.3.2                 glue_1.7.0                 
#>  [63] quadprog_1.5-8              nlme_3.1-163               
#>  [65] rhdf5filters_1.14.1         grid_4.3.2                 
#>  [67] cluster_2.1.4               reshape2_1.4.4             
#>  [69] ade4_1.7-22                 generics_0.1.3             
#>  [71] gtable_0.3.4                tidyr_1.3.1                
#>  [73] data.table_1.15.0           utf8_1.2.4                 
#>  [75] XVector_0.42.0              BiocGenerics_0.48.1        
#>  [77] foreach_1.5.2               pillar_1.9.0               
#>  [79] stringr_1.5.1               yulab.utils_0.1.4          
#>  [81] splines_4.3.2               lattice_0.21-9             
#>  [83] survival_3.5-7              bit_4.0.5                  
#>  [85] deldir_2.0-2                tidyselect_1.2.0           
#>  [87] Biostrings_2.70.2           knitr_1.45                 
#>  [89] IRanges_2.36.0              SummarizedExperiment_1.32.0
#>  [91] stats4_4.3.2                xfun_0.42                  
#>  [93] Biobase_2.62.0              matrixStats_1.2.0          
#>  [95] stringi_1.8.3               lazyeval_0.2.2             
#>  [97] ggfun_0.1.4                 yaml_2.3.8                 
#>  [99] evaluate_0.23               codetools_0.2-19           
#> [101] interp_1.1-6                tibble_3.2.1               
#> [103] ggplotify_0.1.2             cli_3.6.2                  
#> [105] RcppParallel_5.1.7          systemfonts_1.0.5          
#> [107] munsell_0.5.0               jquerylib_0.1.4            
#> [109] GenomeInfoDb_1.38.6         png_0.1-8                  
#> [111] parallel_4.3.2              pkgdown_2.0.7              
#> [113] blob_1.2.4                  latticeExtra_0.6-30        
#> [115] jpeg_0.1-10                 bitops_1.0-7               
#> [117] scales_1.3.0                purrr_1.0.2                
#> [119] crayon_1.5.2                rlang_1.1.3                
#> [121] fastmatch_1.1-4