diff --git a/bin/2.2_motif_estimation/png_to_pdf.R b/bin/2.2_motif_estimation/png_to_pdf.R index 7c86920..4ea85b9 100644 --- a/bin/2.2_motif_estimation/png_to_pdf.R +++ b/bin/2.2_motif_estimation/png_to_pdf.R @@ -39,16 +39,16 @@ png_to_pdf <- function(png_top, png_list, cluster_ids, new_id, out = "cluster.pd grobs <- lapply(png_split,function(p){rasterGrob(readPNG(p),interpolate = FALSE)}) split_grobs <- split(grobs, rep(1:ceiling(length(grobs)/3), each = 3)[1:length(grobs)]) - + rows <- lapply(seq(1,length(split_grobs)), function(sg){ arrangeGrob(grobs = split_grobs[[sg]], top = textGrob(paste0("Cluster ",cluster_list[sg]),gp = gpar(fontsize = 20,font = 3)), ncol = 3) }) split_rows <- split(rows, rep(1:ceiling(length(rows)/4), each = 4)[1:length(rows)]) - + pdf(out,width = 17, height = 11) grid.arrange(grobs = top_grob, nrow = 3, top = textGrob(paste0("New Cluster ",new_id),gp = gpar(fontsize = 30,font = 3))) lapply(split_rows, function(r){ - grid.arrange(grobs = r, nrow = 4, top = textGrob("Generated from...",gp = gpar(fontsize = 30,font = 3))) + grid.arrange(grobs = r, nrow = 4, top = textGrob("Generated from...",gp = gpar(fontsize = 30,font = 3))) }) dev.off() @@ -68,20 +68,21 @@ get_index <- function(index_file){ index <- f[,c(2,8)] index$V8 <- strsplit(index$V8,",") return(index[unlist(lapply(index$V8, function(v){ifelse(length(v) > 1, TRUE, FALSE)}))]) - -} +} +@TODO png_to_pdf_set_up <- function(png_top, png_list, index_file){ - + index <- get_index(index_file) t <- lapply(seq(nrow(index)), function(i){ new_id <- index[i,1] cluster_ids <- index[i,2] out <- paste0("Summary_cluster_", new_id, ".pdf") - png_to_pdf(png_top = ,png_list = ,cluster_ids = cluster_ids, new_id = new_id, out = out ) + #regex_png <- paste0("*_cluster_", new_id , "/logo${NUM}.png") #???? + png_to_pdf(png_top = "TODO" ,png_list = "TODO" ,cluster_ids = cluster_ids, new_id = new_id, out = out ) }) - + } @@ -89,6 +90,3 @@ png_to_pdf_set_up <- function(png_top, png_list, index_file){ if (!interactive()) { png_to_pdf_set_up(opt$png_new, opt$png_old , opt$index) } - - -