Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
New features:
DATASET_STYLE, DATASET_COLORSTRIP, TREE_COLORS range, DATASET_SYMBOL, DATASET_DOMAINS, DATASET_CONNECTION, DATASET_MULTIBAR, DATASET_BINARY, DATASET_TEXT, DATASET_EXTERNALSHAPE, DATASET_PIECHART support full color palette(table2itol wesanderson npg aaas nejm lancet jama jco ucscgb d3 igv locuszoom uchicago simpsons futurama rickandmorty startrek tron gsea material BrBG PiYG PRGn PuOr RdBu RdGy RdYlBu RdYlGn Spectral Accent Dark2 Paired Pastel1 Pastel2 Set1 Set2 Set3 Blues BuGn BuPu GnBu Greens Greys Oranges OrRd PuBu PuBuGn PuRd Purples RdPu Reds YlGn YlGnBu YlOrBr YlOrRd)

user level add DATASET_MULTIBAR, DATASET_LINECHART, DATASET_PIECHART, DATASET_ALIGNMENT, DATASET_IMAGE, POPUP_INFO support

create_hub supports direct input of phylo objects for the tree parameter, not just the tree file path

Fixed:
wesanderson color palette random picking function changed from `runif` to `sample`, fixed the problem of repeated color matching
  • Loading branch information
TongZhou2017 committed Feb 12, 2023
1 parent 8ee489e commit b122be0
Show file tree
Hide file tree
Showing 81 changed files with 436 additions and 101 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: itol.toolkit
Title: Helper Functions for 'Interactive Tree Of Life'
Version: 1.0.5
Version: 1.1.0
Authors@R:
person(
given = "Tong",
Expand Down Expand Up @@ -32,7 +32,9 @@ Imports:
miniUI,
shiny,
rstudioapi,
colourpicker
colourpicker,
ggsci,
RColorBrewer
Suggests:
knitr,
rmarkdown,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ exportClasses(itol.theme)
exportClasses(itol.unit)
exportMethods("+")
exportMethods(show)
import(RColorBrewer)
import(dplyr)
import(ggsci)
import(miniUI)
import(rstudioapi)
import(shiny)
Expand Down
5 changes: 4 additions & 1 deletion R/object.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ itol.hub <- setClass(
#' create_hub(tree = TREE)
#'
create_hub <- function(tree,field_tree=NULL,seq=NULL,abundance=NULL,taxonomy=NULL,node_data=NULL,tip_data=NULL) {
tree <- list(main = read.tree(tree), field = list())
if (is.character(tree)) {
tree <- read.tree(tree)
}
tree <- list(main = tree, field = list())
if (any(duplicated(tree$main$node.label)) || is.null(tree$main$node.label)) {
tree$main <- ape::makeNodeLabel(phy = tree$main, method = "number", prefix = "I")
}
Expand Down
308 changes: 292 additions & 16 deletions R/user.R

Large diffs are not rendered by default.

58 changes: 55 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ correct_get_color <- function(str) {
#' @return a vector of colors
#' @importFrom wesanderson wes_palettes
#' @importFrom stats runif
#' @import ggsci
#' @import RColorBrewer
#' @export
get_color <- function(n,set="table2itol") {
get_color <- function(n=0,set="table2itol") {
# Colour vectors collected by Jan P. Meier-Kolthoff.
#

COLOURS <- list(
# Dark2; colour-blind-safe
JMK01 = "#1b9e77",
Expand Down Expand Up @@ -328,6 +331,10 @@ get_color <- function(n,set="table2itol") {
"#ceb8d4", "#635b2d", "#c79783", "#733426", "#476682", "#98762e"
)
)
if(set == "table2itol"){
return(COLOURS[[n]])
}
set_names <- c("table2itol")
if(set == "wesanderson"){
COLOURS <- list()
colors_vector <- unique(unlist(wesanderson::wes_palettes))
Expand All @@ -344,11 +351,56 @@ get_color <- function(n,set="table2itol") {
"#35274A",
"#550307"))]
for (i in 1:length(colors_vector)) {
indexs <- round(runif(n,1,length(colors_vector)))
indexs <- sample(1:length(colors_vector),n,replace=F)
COLOURS[[i]] <- colors_vector[indexs]
}
return(COLOURS[[n]])
}
set_names <- c(set_names,"wesanderson")
set_main <- stringr::str_remove(set, "_.*$")
ggsci_db<-utils::getFromNamespace("ggsci_db", "ggsci")
if(set_main %in% names(ggsci_db)){
if(grepl("_",set)){
set_type <- unlist(strsplit(set,"_"))
colors <- ggsci_db[[set_type[1]]][[set_type[2]]]
}else{
colors <- ggsci_db[[set]][[1]]
}
if(n > length(colors)){
warning("The pattern length is shorter than n. Appending default colors to
make the pattern length same with n.")
colors <- c(colors,COLOURS[[n-length(colors)]])
}
if(n < length(colors)){
warning("The pattern length is longer than n. The length is cutting as
same as n.")
colors <- colors[1:n]
}
return(colors)
}
set_names <- c(set_names,names(ggsci_db))
if(set %in% rownames(RColorBrewer::brewer.pal.info)){
n_max <- RColorBrewer::brewer.pal.info[set,]$maxcolors
if(n > n_max){
warning("The pattern length is shorter than n. Appending default colors to
make the pattern length same with n.")
colors <- RColorBrewer::brewer.pal(n=n_max,name = set)
colors <- c(colors,COLOURS[[n-n_max]])
}
if(n < n_max){
warning("The pattern length is longer than n. The length is cutting as
same as n.")
colors <- RColorBrewer::brewer.pal(n=n,name = set)
}
if(n == n_max){
colors <- RColorBrewer::brewer.pal(n=n,name = set)
}
return(colors)
}
set_names <- c(set_names,rownames(RColorBrewer::brewer.pal.info))
if(set == "ls"){
return(set_names)
}
return(COLOURS[[n]])
}

#' Paste rows
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/Get_Start.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pkgdown: 2.0.7
pkgdown_sha: ~
articles:
Get_Start: Get_Start.html
last_built: 2023-02-05T05:28Z
last_built: 2023-02-12T12:15Z

2 changes: 1 addition & 1 deletion docs/reference/complex_html_text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/convert_01.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/convert_01_to_connect.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/convert_range_to_node.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/correct_get_color.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/count_to_tree.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/create_hub.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/create_theme.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/create_unit.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/df_merge.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/fa_read.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/fa_write.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/file_get_dir.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/file_get_name.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/file_to_unit.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/reference/get_color.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/head_line.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/hub_to_unit.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b122be0

Please sign in to comment.