Skip to content

Commit be2f51f

Browse files
committed
Added a manual override for the ssGSEA heatmap width and height
1 parent 12c4878 commit be2f51f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/panoply_ssgsea_report/rmd-ssgsea-functions.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ pw_hm <- function(output.prefix,
163163
ser.meth='ARSA', ## Seriation method used to (attempt to) arrange the matrix.
164164
cw=10, ## heatmap cellwidth
165165
ch=10, ## heatmap cellheight
166+
width_override=NULL, ## manual override for heatmap width
167+
height_override=NULL, ## manual override for heatmap height
166168

167169
remove_prefix = FALSE, ## Toggle to remove common prefixes for names (e.g. "HALLMARK_MITOTIC_SPINDLE" -> "MITOTIC_SPINDLE")
168170
normalize_names = FALSE, ## Toggle for normalizing pathway names (e.g. "MITOTIC_SPINDLE" -> "Mitotic Spindle")
@@ -389,11 +391,19 @@ pw_hm <- function(output.prefix,
389391
lgd_width = convertX(min_legend_width, 'inches', valueOnly = TRUE) + # add minimum legend width
390392
convertX(max_legend_text, 'inches', valueOnly = TRUE) # add max legend text-length
391393
width = hm_width+lgd_width + padding # calculate total width + padding
394+
if (!is.null(width_override)) {
395+
print(glue("Auto-calculated heatmap width of {width}in. will be overriden by provided width of {width_override}in."))
396+
width = width_override
397+
}
392398

393399
height = convertX(unit(nrow(mat.filt) * ch*1.5, "point"), 'inches', valueOnly = TRUE) + # heatmap height
394400
convertX(ComplexHeatmap::max_text_width(colnames(mat.filt)),'inches', valueOnly = TRUE) + padding # column-name text, + 1 for padding
395401
if (ext=='.pdf') pdf(paste0(fn.out,ext), width = width, height = height)
396402
if (ext=='.png') png(paste0(fn.out,ext), width = width, height = height, units = 'in', res=300)
403+
if (!is.null(height_override)) {
404+
print(glue("Auto-calculated heatmap height of {height}in. will be overriden by provided height of {height_override}in."))
405+
height = height_override
406+
}
397407

398408
## plot heatmap and legend side-by-side
399409
grid.arrange(ht_grob, lgd_grob, ncol=2, widths=c(hm_width,lgd_width))

0 commit comments

Comments
 (0)