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.8.00 purrr_1.0.2        dplyr_1.1.4        dada2_1.30.0      
#>  [9] Rcpp_1.0.12        ggplot2_3.5.0      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.1                rmarkdown_2.26             
#>   [7] fs_1.6.3                    zlibbioc_1.48.2            
#>   [9] ragg_1.3.0                  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] desc_1.4.3                  plyr_1.8.9                 
#>  [25] DECIPHER_2.30.0             cachem_1.0.8               
#>  [27] GenomicAlignments_1.38.2    igraph_2.0.3               
#>  [29] lifecycle_1.0.4             iterators_1.0.14           
#>  [31] pkgconfig_2.0.3             Matrix_1.6-5               
#>  [33] R6_2.5.1                    fastmap_1.1.1              
#>  [35] GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
#>  [37] digest_0.6.35               aplot_0.2.2                
#>  [39] colorspace_2.1-0            ShortRead_1.60.0           
#>  [41] patchwork_1.2.0             S4Vectors_0.40.2           
#>  [43] textshaping_0.3.7           GenomicRanges_1.54.1       
#>  [45] RSQLite_2.3.6               hwriter_1.3.2.1            
#>  [47] vegan_2.6-4                 labeling_0.4.3             
#>  [49] fansi_1.0.6                 abind_1.4-5                
#>  [51] mgcv_1.9-1                  compiler_4.3.3             
#>  [53] bit64_4.0.5                 withr_3.0.0                
#>  [55] BiocParallel_1.36.0         DBI_1.2.2                  
#>  [57] highr_0.10                  MASS_7.3-60.0.1            
#>  [59] DelayedArray_0.28.0         biomformat_1.30.0          
#>  [61] permute_0.9-7               tools_4.3.3                
#>  [63] glue_1.7.0                  quadprog_1.5-8             
#>  [65] nlme_3.1-164                rhdf5filters_1.14.1        
#>  [67] grid_4.3.3                  cluster_2.1.6              
#>  [69] reshape2_1.4.4              ade4_1.7-22                
#>  [71] generics_0.1.3              gtable_0.3.4               
#>  [73] tidyr_1.3.1                 data.table_1.15.4          
#>  [75] utf8_1.2.4                  XVector_0.42.0             
#>  [77] BiocGenerics_0.48.1         foreach_1.5.2              
#>  [79] pillar_1.9.0                stringr_1.5.1              
#>  [81] yulab.utils_0.1.4           splines_4.3.3              
#>  [83] lattice_0.22-6              survival_3.5-8             
#>  [85] bit_4.0.5                   deldir_2.0-4               
#>  [87] tidyselect_1.2.1            Biostrings_2.70.3          
#>  [89] knitr_1.46                  IRanges_2.36.0             
#>  [91] SummarizedExperiment_1.32.0 stats4_4.3.3               
#>  [93] xfun_0.43                   Biobase_2.62.0             
#>  [95] matrixStats_1.3.0           stringi_1.8.3              
#>  [97] lazyeval_0.2.2              ggfun_0.1.4                
#>  [99] yaml_2.3.8                  evaluate_0.23              
#> [101] codetools_0.2-19            interp_1.1-6               
#> [103] tibble_3.2.1                ggplotify_0.1.2            
#> [105] cli_3.6.2                   RcppParallel_5.1.7         
#> [107] systemfonts_1.0.6           munsell_0.5.1              
#> [109] jquerylib_0.1.4             GenomeInfoDb_1.38.8        
#> [111] png_0.1-8                   parallel_4.3.3             
#> [113] pkgdown_2.0.7               blob_1.2.4                 
#> [115] latticeExtra_0.6-30         jpeg_0.1-10                
#> [117] bitops_1.0-7                scales_1.3.0               
#> [119] crayon_1.5.2                rlang_1.1.3                
#> [121] fastmatch_1.1-4