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.4.1 (2024-06-14)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Debian GNU/Linux 12 (bookworm)
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.11.0 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.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.12.0     treeio_1.28.0     phangorn_2.11.1   ape_5.8          
#>  [5] MiscMetabar_0.9.4 purrr_1.0.2       dplyr_1.1.4       dada2_1.32.0     
#>  [9] Rcpp_1.0.13       ggplot2_3.5.1     phyloseq_1.48.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.9              magrittr_2.0.3             
#>   [5] farver_2.1.2                rmarkdown_2.28             
#>   [7] fs_1.6.4                    zlibbioc_1.50.0            
#>   [9] ragg_1.3.3                  vctrs_0.6.5                
#>  [11] multtest_2.60.0             Rsamtools_2.20.0           
#>  [13] htmltools_0.5.8.1           S4Arrays_1.4.1             
#>  [15] Rhdf5lib_1.26.0             SparseArray_1.4.8          
#>  [17] rhdf5_2.48.0                gridGraphics_0.5-1         
#>  [19] sass_0.4.9                  bslib_0.8.0                
#>  [21] htmlwidgets_1.6.4           desc_1.4.3                 
#>  [23] plyr_1.8.9                  DECIPHER_3.0.0             
#>  [25] cachem_1.1.0                GenomicAlignments_1.40.0   
#>  [27] igraph_2.0.3                lifecycle_1.0.4            
#>  [29] iterators_1.0.14            pkgconfig_2.0.3            
#>  [31] Matrix_1.7-0                R6_2.5.1                   
#>  [33] fastmap_1.2.0               GenomeInfoDbData_1.2.12    
#>  [35] MatrixGenerics_1.16.0       digest_0.6.37              
#>  [37] aplot_0.2.3                 colorspace_2.1-1           
#>  [39] ShortRead_1.62.0            patchwork_1.3.0            
#>  [41] S4Vectors_0.42.1            textshaping_0.4.0          
#>  [43] GenomicRanges_1.56.1        hwriter_1.3.2.1            
#>  [45] vegan_2.6-8                 labeling_0.4.3             
#>  [47] fansi_1.0.6                 httr_1.4.7                 
#>  [49] abind_1.4-5                 mgcv_1.9-1                 
#>  [51] compiler_4.4.1              withr_3.0.1                
#>  [53] BiocParallel_1.38.0         DBI_1.2.3                  
#>  [55] highr_0.11                  MASS_7.3-61                
#>  [57] DelayedArray_0.30.1         biomformat_1.32.0          
#>  [59] permute_0.9-7               tools_4.4.1                
#>  [61] glue_1.8.0                  quadprog_1.5-8             
#>  [63] nlme_3.1-165                rhdf5filters_1.16.0        
#>  [65] grid_4.4.1                  cluster_2.1.6              
#>  [67] reshape2_1.4.4              ade4_1.7-22                
#>  [69] generics_0.1.3              gtable_0.3.5               
#>  [71] tidyr_1.3.1                 data.table_1.16.0          
#>  [73] utf8_1.2.4                  XVector_0.44.0             
#>  [75] BiocGenerics_0.50.0         foreach_1.5.2              
#>  [77] pillar_1.9.0                stringr_1.5.1              
#>  [79] yulab.utils_0.1.7           splines_4.4.1              
#>  [81] lattice_0.22-6              survival_3.7-0             
#>  [83] deldir_2.0-4                tidyselect_1.2.1           
#>  [85] Biostrings_2.72.1           knitr_1.48                 
#>  [87] IRanges_2.38.1              SummarizedExperiment_1.34.0
#>  [89] stats4_4.4.1                xfun_0.47                  
#>  [91] Biobase_2.64.0              matrixStats_1.3.0          
#>  [93] stringi_1.8.4               UCSC.utils_1.0.0           
#>  [95] lazyeval_0.2.2              ggfun_0.1.6                
#>  [97] yaml_2.3.10                 evaluate_1.0.0             
#>  [99] codetools_0.2-20            interp_1.1-6               
#> [101] tibble_3.2.1                ggplotify_0.1.2            
#> [103] cli_3.6.3                   RcppParallel_5.1.9         
#> [105] systemfonts_1.1.0           munsell_0.5.1              
#> [107] jquerylib_0.1.4             GenomeInfoDb_1.40.1        
#> [109] png_0.1-8                   parallel_4.4.1             
#> [111] pkgdown_2.1.0               latticeExtra_0.6-30        
#> [113] jpeg_0.1-10                 bitops_1.0-8               
#> [115] pwalign_1.0.0               scales_1.3.0               
#> [117] crayon_1.5.3                rlang_1.1.4                
#> [119] fastmatch_1.1-4