diff --git a/src/00_base_functions.R b/src/00_base_functions.R index 2664f47c16220d8a643eee3239772332cc213803..ac81b96560d7e3907a13e1b940ebb5842076e212 100644 --- a/src/00_base_functions.R +++ b/src/00_base_functions.R @@ -7,13 +7,24 @@ labeller <- function(l, l_names = NULL, features){ } if ( length(l) == 3 ){ - label <- as.factor(ifelse(features %in% l[[1]], 'K4-only', - ifelse(features %in% l[[2]], 'Bivalent', - ifelse(features %in% l[[3]], 'K27-only', 'Unclass.')))) + label <- as.factor(ifelse(features %in% l[[1]], l_names[1], + ifelse(features %in% l[[2]], l_names[2], + ifelse(features %in% l[[3]], l_names[3], 'Unclass.')))) } else if ( length(l) == 1 ) { - label <- factor(ifelse(features %in% l[[1]], 'K27', 'Unmarked')) + label <- factor(ifelse(features %in% l[[1]], l_names, 'Unmarked')) } names(label) <- features return(label) } + +make_pal <- function(factor, pal = 'Set1'){ + if ( length(unique(factor)) < 3 ){ + cols <- brewer.pal(3, pal)[c(1,3)] + } else { + cols <- brewer.pal(length(unique(factor)), pal) + } + + names(cols) <- unique(factor) + return(cols) +} \ No newline at end of file diff --git a/src/00_root.R b/src/00_root.R index 95cb410b095bfd5883604bc8e37624fce3ffdb61..766660f270c1b3101d14828c6f19f720046d6e9d 100644 --- a/src/00_root.R +++ b/src/00_root.R @@ -50,3 +50,13 @@ root_tfs <- names(which(table(df$gene) == 3)) write.table(root_tfs, file = sprintf('%s/root_tfs.txt', output.dir), quote = FALSE, col.names = F, row.names = F) + + +# Pcg +all <- union(glist, root_genes) +df <- rbind(data.frame('gene' = K27_wr, 'set' = 'K27me3 (whole root)'), + data.frame('gene' = root_genes, 'set' = 'Root genes'), + data.frame('gene' = FIE, 'set' = 'FIE'), + data.frame('gene' = c(K27_genes, K27K4_genes), 'set' = 'K27me3 (WOX5)')) +v <- venneuler(df) +plot(v) \ No newline at end of file diff --git a/src/00_utils.R b/src/00_utils.R index a25415ad93ae4ba1985fbefedf96773b2802fb03..c06f278c54ab1c9e8ff453548e39995d6ecfe519 100644 --- a/src/00_utils.R +++ b/src/00_utils.R @@ -12,6 +12,8 @@ library(tibble) library(RColorBrewer) library(venneuler) +source('src/00_base_functions.R') + # from calculus working.dir <- "/projects/epichromdev/ahugues/scarabi_pcg_identity" rds.path <- "data/list_seuObj.rds"