Shape & Colors by Two Factors
DOI: 10.1016/j.foodres.2022.111998
Figure 2
library(itol.toolkit) # main package
library(dplyr) # data manipulation
library(data.table) # file read
library(ape) # tree operation
library(stringr) # string operation
library(tidyr) # data manipulation
tree_1 <- "https://raw.githubusercontent.com/TongZhou2017/itol.toolkit/master/inst/extdata/dataset4/otus.contree"
hub_1 <- create_hub(tree_1)
data_file_1 <- "https://raw.githubusercontent.com/TongZhou2017/itol.toolkit/master/inst/extdata/dataset4/annotation.txt"
data_file_2 <- "https://raw.githubusercontent.com/TongZhou2017/itol.toolkit/master/inst/extdata/dataset4/otutab_high.mean"
data_1 <- data.table::fread(data_file_1)
data_2 <- data.table::fread(data_file_2)
# relabel by genus
unit_1 <- create_unit(data = data_1 %>% select(ID, Genus),
key = "rep_Zhou_1_labels",
type = "LABELS",
tree = tree_1)
write_unit(unit_1)
# tree_colors range by phylum
unit_2 <- create_unit(data = data_1 %>% select(ID, Phylum),
key = "rep_Zhou_2_range",
type = "TREE_COLORS",
subtype = "range",
tree = tree_1)
write_unit(unit_2)
# color_strip by class
set.seed(123)
unit_3 <- create_unit(data = data_1 %>% select(ID, Class),
key = "rep_Zhou_3_strip",
type = "DATASET_COLORSTRIP",
color = "wesanderson",
tree = tree_1)
unit_3@common_themes$basic_theme$margin <- 50
# simple_bar by NS
unit_4 <- create_unit(data = data_1 %>% select(ID, South_America, Asia, North_America),
key = "rep_Zhou_4_multibar",
type = "DATASET_MULTIBAR",
tree = tree_1)
unit_4@specific_themes$basic_plot$size_max <- 100
#Adding comment tag
unit_5 <- create_unit(data = data_1 %>% select(ID, Class, Family),
key = "rep_Zhou_5_binary",
type = "DATASET_DOMAINS",
color = "wesanderson",
tree = tree_1)
#Storing drawing information
hub_1 <- hub_1 +
unit_1 +
unit_2 +
unit_3 +
unit_4 +
unit_5
write_hub(hub_1,getwd())