itol.toolkit包让iTOL使用更丝滑!

简介: itol.toolkit包让iTOL使用更丝滑!

“工欲善其事,必先利其器”

itol.toolkit产品发布


Installation安装

# from CRAN
install.packages("itol.toolkit")
# from GitHub
# install.packages("devtools") # if you have not installed "devtools" package
devtools::install_github("TongZhou2017/itol.toolkit")
作者推荐使用Github版,更新速度更快!

Quickstart使用


# load package
library(itol.toolkit)
# read data
tree <- system.file("extdata",
                    "tree_of_itol_templates.tree",
                    package = "itol.toolkit")
data("template_groups")
df_group <- data.frame(id = unique(template_groups$group), 
                       data = unique(template_groups$group))
# create hub
hub <- create_hub(tree = tree)
## create unit
unit <- create_unit(data = df_group, 
                    key = "Quickstart", 
                    type = "DATASET_COLORSTRIP", 
                    tree = tree)
## add unit into hub
hub <- hub + unit
## write template file
write_hub(hub,getwd())
支持文档https://tongzhou2017.github.io/itol.toolkit/
官方地址https://cran.r-project.org/web/packages/itol.toolkit/index.html

         

以下是利用该R包制作的实例图

上述内容均来自itol.toolkit

友情推荐新款R包

如果感兴趣的话欢迎探索

以下是作者专栏

【点击进入订阅专栏】



官方使用示例:


library(itol.toolkit)
library(dplyr)
library(data.table)
library(ape)
library(stringr)
library(tidyr)


tree <- system.file("extdata","tree_of_itol_templates.tree",package = "itol.toolkit")
data("template_groups")
data("template_parameters_count")
hub <- create_hub(tree = tree)
## 1,7 data
df_group <- data.frame(id = unique(template_groups$group), 
                       data = unique(template_groups$group))
## 2 data
df_count <- cbind(template_groups,as.data.frame(rowSums(template_parameters_count)))
## 3 data
df_rename <- data.frame(id = template_groups$template, 
                        new_label = str_to_title(str_replace_all(template_groups$template,"_"," ")))
## 5 data
tab_tmp_01 <- as.data.frame(t(template_parameters_count))
tab_tmp_connect <- convert_01_to_connect(tab_tmp_01)
tab_tmp_connect <- full_join(tab_tmp_connect, template_groups, by=c("row" = "template"))
tab_tmp_connect <- tab_tmp_connect %>% filter(val > 10) %>% filter(row != col)
## 6 data
tab_tmp <- fread(system.file("extdata","parameter_groups.txt",package = "itol.toolkit"))
tab_id_group <- tab_tmp[,c(1,2)]
tab_tmp <- tab_tmp[,-c(1,2)]
tab_tmp_01 <- convert_01(object = tab_tmp)
tab_tmp_01 <- cbind(tab_id_group,tab_tmp_01)
order <- c("type","separator","profile","field","common themes","specific themes","data")
tab_tmp_01_long <- tab_tmp_01 %>% tidyr::gather(key = "variable",value = "value",c(-parameter,-group))
template_start_group <- tab_tmp_01_long %>% group_by(group,variable) %>% summarise(sublen = sum(value)) %>% tidyr::spread(key=variable,value=sublen)
template_start_group$group <- factor(template_start_group$group,levels = order)
template_start_group <- template_start_group %>% arrange(group)
start_group <- data.frame(Var1 = template_start_group$group, Freq = apply(template_start_group[,-1], 1, max))
start_group$start <- 0
for (i in 2:nrow(start_group)) {
  start_group$start[i] <- sum(start_group$Freq[1:(i-1)])
}
template_start_group[template_start_group == 0] <- NA
template_end_group <- template_start_group[,2:(ncol(template_start_group)-1)] + start_group$start
template_end_group <- data.frame(group = order,template_end_group)
template_end_group_long <- template_end_group %>% tidyr::gather(key = "variable",value = "value",-group)
names(template_end_group_long)[3] <- "end"
template_end_group_long$start <- rep(start_group$start,length(unique(template_end_group_long$variable)))
template_end_group_long <- template_end_group_long %>% na.omit()
template_end_group_long$length <- sum(start_group$Freq)
template_end_group_long <- template_end_group_long[,c(2,5,4,3,1)]
template_end_group_long$group <- factor(template_end_group_long$group,levels = order)


unit_1 <- create_unit(data = df_group, 
                      key = "E1_template_types", 
                      type = "TREE_COLORS", 
                      subtype = "clade", 
                      line_type = c(rep("normal",4),"dashed"),
                      size_factor = 5, 
                      tree = tree)
unit_2 <- create_unit(data = df_count, 
                      key = "E2_parameter_number", 
                      type = "DATASET_SYMBOL",
                      position = 1, 
                      tree = tree)
unit_3 <- create_unit(data = df_rename, 
                      key = "E3_template_rename", 
                      type = "LABELS",
                      tree = tree)
unit_4 <- create_unit(data = template_groups, 
                      key = "E4_template_name_color", 
                      type = "DATASET_STYLE", 
                      subtype = "label",
                      position = "node",
                      size_factor = 1.5,
                      tree = tree)
unit_5 <- create_unit(data = tab_tmp_connect[,1:4], 
                      key = "E5_template_similarity", 
                      type = "DATASET_CONNECTION", 
                      tree = tree)
unit_6 <- create_unit(data = template_end_group_long, 
                      key = "E6_template_parameters_structure", 
                      type = "DATASET_DOMAINS", 
                      tree = tree)


unit_2@specific_themes$basic_plot$size_max <- 40
unit_5@specific_themes$basic_plot$size_max <- 100
unit_8@specific_themes$heatmap$color$min <- "#ffd966"
unit_8@specific_themes$heatmap$color$max <- "#cc0000"
unit_8@specific_themes$heatmap$use_mid <- 0
unit_9@specific_themes$basic_plot$size_max <- 100


hub <- hub + unit_1 + unit_2 + unit_3 + unit_4 + unit_5 + unit_6 + unit_7 + unit_8 + unit_9
write_hub(hub,tempdir())



相关文章
|
弹性计算 人工智能 Cloud Native
阿里云无门槛和有门槛优惠券解析:学生券,满减券,补贴券等优惠券领取与使用介绍
为了回馈用户与助力更多用户节省上云成本,阿里云会经常推出各种优惠券相关的活动,包括无门槛优惠券和有门槛优惠券。本文将详细介绍阿里云无门槛优惠券的领取与使用方式,同时也会概述几种常见的有门槛优惠券,帮助用户更好地利用这些优惠,降低云服务的成本。
1824 133
|
8月前
|
算法 数据挖掘 Windows
Mplus 8.11统计建模安装教程:结构方程模型(SEM)分析工具(64位)
Mplus是专业统计建模软件,专精结构方程模型(SEM)分析。界面简洁,支持图形化数据展示,提供丰富模型、估计方法与算法。本指南详解Mplus 8.11(64位)在Windows系统的下载、安装及验证全流程。
2131 1
|
项目管理 开发工具 git
git push 报错 pre-receive hook declined
git push 报错 pre-receive hook declined
6106 0
git push 报错 pre-receive hook declined
|
9月前
|
存储 Ubuntu Linux
Windows WSL
Ubuntu 24.04(WSL2)默认安装在C盘隐藏目录,核心为`ext4.vhdx`虚拟硬盘。可通过`\\wsl$\Ubuntu-24.04\`快速访问Linux文件;Windows磁盘自动挂载至`/mnt/c/`等路径。支持PowerShell命令查看或迁移安装位置至其他盘符。
2807 6
|
数据可视化 Ubuntu 数据挖掘
linux中使用R语言
R语言是一种专用于统计计算和数据分析的编程语言,以其强大的数据处理能力和丰富的可视化功能著称。在Linux中安装R非常简单,通过`sudo apt install r-base`即可完成。R支持基本数据分析和复杂的数据可视化,如使用ggplot2包绘制精美图形。此外,R还能生成甘特图等项目管理工具,帮助清晰展示项目进度。无论是数据处理还是可视化,R都表现出色,适合各种数据分析任务。
989 3
|
机器学习/深度学习 存储 PyTorch
Neural ODE原理与PyTorch实现:深度学习模型的自适应深度调节
Neural ODE将神经网络与微分方程结合,用连续思维建模数据演化,突破传统离散层的限制,实现自适应深度与高效连续学习。
1321 3
Neural ODE原理与PyTorch实现:深度学习模型的自适应深度调节
|
存储 SQL 机器学习/深度学习
sentieon | 泛基因组分析流程详解
泛基因组:指的是一个物种所有个体中全部基因的集合。它不再依赖于单个参考基因组,而是承认没有任何一个个体能够拥有其物种的全部基因。
1112 1
|
数据安全/隐私保护
使用校园账号登录WOS(Web of Science)并检索文献
使用校园账号登录WOS(Web of Science)并检索文献
2892 0
|
存储 关系型数据库 Linux
在CentOS 7上安装和使用Docker的方法
在CentOS 7上安装和使用Docker的方法
1878 1
|
Web App开发 数据可视化 搜索推荐
博士科研最好用的科研绘图工具有哪些?
该博客介绍了几种博士科研中最好用的科研绘图工具,包括ChiPlot、Veusz、Echarts、MeedPeer和Python可视化库,并提供了它们的优缺点分析。
3043 2
博士科研最好用的科研绘图工具有哪些?

热门文章

最新文章