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