Skip to content

Commit

Permalink
more pkgdown and palette updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkimbrel committed Oct 21, 2023
1 parent 84a83f4 commit 070e975
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 115 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
^docs$
^pkgdown$
^\.github$
^data-raw$
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: jakR
Type: Package
Title: jakR Miscellaneous Scripts
Version: 0.11.11
Version: 0.11.12
Author: Jeff Kimbrel
Date: 2018-06-12
Maintainer: Jeff Kimbrel <jakpot@gmail.com>
Expand All @@ -15,3 +15,5 @@ Imports:
ggplot2,
tidyverse
URL: https://jeffkimbrel.github.io/jakR/
Depends:
R (>= 2.10)
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ export(seqtab_stats)
export(show_color_palette)
export(sigCombine)
export(summarySE)
export(tol)
export(zeroOTU)
79 changes: 0 additions & 79 deletions R/jak_palettes.R

This file was deleted.

56 changes: 56 additions & 0 deletions R/palette_jak.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#' A full-service color palette creator
#'
#' These palettes can be used all over.
#'
#' @param n Number of colors to return
#' @param colors An optional vector of rgb or colors to use. Overwrites `p`
#' @param p A named color palette
#' @param reverse A boolean for whether the palette should be reversed or not
#'
#' @export

palette_jak = function(p = "bay",
colors = NULL,
n = 2,
reverse = FALSE) {

if (is.null(colors)) {
cols = colorRampPalette(unname(unlist(jak_palettes[p])))(n)
} else {
if (all(all_are_valid_colors(colors))) {
cols = colorRampPalette(colors)(n)
} else {
stop("ERROR: one of the colors isn't valid")
}
}

if (isTRUE(reverse)) {
return(rev(cols))
} else {
return(cols)
}
}


#' Check if a string contains valid color strings
#'
#' @param x A vector of colors in rgb or text string
#'
#' @export

all_are_valid_colors <- function(x) {
sapply(x, function(X) {
tryCatch(is.matrix(col2rgb(X)),
error = function(e) FALSE)
})
}

# palette_jak$jak = expand_named_palette(pal = c("blue" = "#037bcf",
# "red" = "#A81000",
# "yellow" = "#FFC00A",
# "green" = "#00A800",
# "darkblue" = "#002984",
# "purple" = "#4d0051",
# "black" = "#222222",
# "white" = "#EFEFEF")
# )
25 changes: 25 additions & 0 deletions R/showColorPalette.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,28 @@ show_color_palette = function(pal,
p
}

#' Show all color palettes in the jak_palettes object
#'
#' @export

show_all_color_palettes = function() {
input2 <- lapply(jak_palettes, as.data.frame, stringsAsFactors = FALSE)
df <- bind_rows(input2, .id = "Palette") |>
dplyr::select(Palette, RGB = `X[[i]]`)

df = df |>
group_by(Palette) |>
mutate(x = seq(n()))

df |>
ggplot(aes(x = x, y = Palette, fill = RGB)) +
theme_minimal() +
geom_tile() +
scale_fill_identity() +
scale_y_discrete(limits = rev)

}




17 changes: 0 additions & 17 deletions R/tolPalette.R

This file was deleted.

55 changes: 54 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
url: https://jeffkimbrel.github.io/jakR/
template:
bootstrap: 5
bootswatch: sandstone
bslib:
bg: "#202123"
fg: "#B8BCC2"
primary: "#037bcf"

reference:
- title: Color Palettes
contents:
- palette_jak
- show_color_palette
- show_all_color_palettes
- expand_named_palette
- get_phylo_palette

- title: Microbial Communities
contents:
- get_alpha_diversity
- get_phylo_diversity
- permanova
- pairwiseAdonis
- phylo_other
- plot_distances
- plotPD
- zeroOTU

- title: Genomics
contents:
- fastq_filter_summary_amplicon
- fastq_info_summary
- run_fts
- get_fts_intervals
- plot_fts_intervals
- plot_fts_points
- getSig
- sigCombine
- orthofinder_complete_clusters
- orthofinder_summary
- drep_extract
- seqtab_stats

- title: Misc
contents:
- jak_theme
- format_dt
- gt_theme

- title: internal
contents:
- all_are_valid_colors
- getAlphaDiversity
- getPhyloDiversity
- jak_theme_black
- summarySE
- plotDistances
- jak_palettes
40 changes: 40 additions & 0 deletions data-raw/jak_palettes.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## code to prepare `jak_palettes` dataset goes here

jak_palettes = list(
"cb" = c("#cc79a7","#0072b2","#56b4e9","#009e73","#f0e442","#e69f00","#d55e00"),

# from colorbook.io
"modernUI" = c('#09D879','#0069FF','#D6D6D6','#FF4040','#FFDD00'),
"helpcenter" = c('#E40035','#6900C5','#2F4AF9','#00BB6A','#8DC000','#FFC400','#FFAA3A','#FF662E','#FB4A4A'),
"bulma" = c('#01D1B2','#5178FA','#3273DC','#23D160','#FFDD57','#FF3860'),
"blackdiamond" = c('#6C7F50','#98C67C','#34557F','#FF635A','#D98626','#D3BF96','#685A5C','#786592','#78849C',
'#DC443A','#ACDEE6','#EFBD47','#B0583A','#E2C2C7','#0088CE','#E9BF9B','#652D86','#512B1B',
'#D1D4D3','#FE9666','#7BBBB2'),
"sachi" = c('#005eac','#E7004C','#00C36B','#6D6462','#068CD6','#FE1E36','#F57C00','#0097A7','#A35FCA'),
"inslife" = c('#80bec8','#6EB5C0','#e8e2e6','#FFCCBB','#83a0cd','#dee6f2','#DEAFB1','#AFDEDC','#DCC48E',
'#CEB28D','#56CBF9','#E9D7C3'),
"pastelrainbow" = c('#E8CACA','#FFE5A8','#F8FF97','#BCFFA4','#A6FFD3','#B9E3FF','#C1CCFF','#E4CFFF','#F1CEF4'),

# from https://github.com/karthik/wesanderson
"zissou" = c("#000000","#3B9AB2","#78B7C5","#EBCC2A","#E1AF00","#F21A00"),

# from PNW colors (https://github.com/jakelawlor/PNWColors)
"bay" = c('#00496f','#0f85a0','#edd746','#ed8b00','#dd4124'),
"winter" = c('#2d2926','#33454e','#537380','#81a9ad','#ececec'),
"lake" = c('#362904','#54450f','#45681e','#4a9152','#64a8a8','#85b6ce','#cde5f9','#eef3ff'),
"sailboat" = c('#6e7cb9','#7bbcd5','#d0e2af','#f5db99','#e89c81','#d2848d'),

# from Paul Tol (https://personal.sron.nl/~pault/data/colourschemes.pdf)
"bright" = c("#4477AA","#66CCEE","#228833","#CCBB44","#EE6677","#AA3377","#BBBBBB"),
"highContrast" = c("#FFFFFF","#DDAA33","#BB5566","#004488","#000000"),
"vibrant" = c("#007788","#33BBEE","#009988","#EE7733","#CC3311","#EE3377","#BBBBBB"),
"muted" = c("#332288","#88ccee","#44aa99","#117733","#999933","#ddcc77","#cc6677","#882255","#aa4499"),
"pale" = c("#bbccee","#cceeff","#ccddaa","#eeeebb","#ffcccc","#dddddd"),
"dark" = c("#222255","#225555","#225522","#666633","#663333","#555555"),
"light" = c("#77aadd","#99ddff","#44bb99","#bbcc33","#aaaa00","#eedd88","#ee8866","#ffaabb","#dddddd"),
"sunset" = c("#364b9a","#4a7bb7","#6ea6cd","#98cae1","#c2e4ef","#eaeccc","#feda8b","#fdb366","#f67e4b","#dd3d2d","#a50026"),
"rainbow" = c("#d1bbd7","#ae76a3","#882e72","#1965b0","#5289c7","#7bafde","#4eb265","#90c987","#cae0ab","#f7f056","#f6c141","#f1932d","#e8601c","#dc050c"),
"earth" = c("#5566aa","#117733","#44aa66","#55aa22","#668822","#99bb55","#558877","#88bbaa","#aaddcc","#44aa88","#ddcc66","#ffdd44","#ffee88","#bb0011")
)

usethis::use_data(jak_palettes, overwrite = TRUE)
Binary file added data/jak_palettes.rda
Binary file not shown.
16 changes: 0 additions & 16 deletions man/tol.Rd

This file was deleted.

0 comments on commit 070e975

Please sign in to comment.