Open karissawhiting opened 1 year ago
The package colorblindcheck
will help. here is a useful blog: https://cran.r-project.org/web/packages/colorblindcheck/vignettes/intro-to-colorblindcheck.html
library(gnomeR)
library(colorblindcheck)
lapply(gnomer_palettes, palette_check)
$pancan name n tolerance ncp ndcp min_dist mean_dist max_dist 1 normal 33 6.859405 528 528 6.8594048 41.94901 100.20598 2 deuteranopia 33 6.859405 528 517 1.5168688 36.91666 99.15904 3 protanopia 33 6.859405 528 512 0.8960741 36.74768 98.08567 4 tritanopia 33 6.859405 528 513 4.1188800 38.89394 97.30859
$main name n tolerance ncp ndcp min_dist mean_dist max_dist 1 normal 33 4.022728 528 528 4.0227275 41.08202 107.15237 2 deuteranopia 33 4.022728 528 515 0.9172666 34.72063 100.67842 3 protanopia 33 4.022728 528 520 0.5558671 34.70158 100.40636 4 tritanopia 33 4.022728 528 521 1.2709556 37.74933 78.97039
$sunset name n tolerance ncp ndcp min_dist mean_dist max_dist 1 normal 7 11.14175 21 21 11.1417506 45.70942 93.97955 2 deuteranopia 7 11.14175 21 17 3.3645898 45.04556 93.88387 3 protanopia 7 11.14175 21 18 0.5558671 42.90733 87.93759 4 tritanopia 7 11.14175 21 18 7.2770908 33.43568 69.27305
@michaelcurry1123 This is great! If it tells us which are no accessible maybe we can filter these out and add a utility function?
ok so there is a way to find the colorblind pairs and we might be able to turn it into a function. here is a very rough sketch of what needs to happen.
library(gnomeR)
library(colorblindcheck)
p1 <- palette_check(gnomer_palettes$pancan)
x1 <- colorblindcheck::palette_dist(gnomer_palettes$pancan)
x2 <- colorblindcheck::palette_dist(gnomer_palettes$pancan, cvd = "pro")
x3 <- x2 < p1$tolerance[1]-.001
x4 <- which(x3, arr.ind=TRUE)
cb1pairs <- sapply(1:nrow(x4), function(x){
paste0(gnomer_palettes$pancan[x4[x,][1]],"-",gnomer_palettes$pancan[ x4[x,][2]])
})
function for this:
noncolorblindfriendlypairs <- function(pal = c("pancan","main","sunset")){
pal <- match.arg(pal)
p1 <- colorblindcheck::palette_check(gnomer_palettes[[pal]])
m1 <- unique(do.call(rbind,lapply(c("pro", "tri","deu"), function(x)
which(colorblindcheck::palette_dist(gnomer_palettes[[pal]], cvd=x) < p1$tolerance[1]-.001,
arr.ind = TRUE))))
data.frame(pair1 =gnomer_palettes$pancan[m1[,1]], pair2 = gnomer_palettes$pancan[m1[,2]])
}
colorspace package might help
@karissawhiting check this is in?
@karissawhiting I never opened a branch or pr for this just put the functions in an issue!
Fixed one error in the function & added pull request to implement this function (Hackathon 5-9-2024)