2020# ' `pathName`/`pathID` are mutually exclusive.
2121# ' @param manualTitle Provide your own title, and override the use of a pathway
2222# ' name the title.
23- # ' @param titleSize Font size for the title (14).
23+ # ' @param fontSizes Font sizes for the elements: column title, row title,
24+ # ' column names, row names, legend title, legend labels. Defaults to
25+ # ' `c(13.2, 13.2, 12, 12, 10, 10)`.
2426# ' @param geneFormat Type of genes given in `genesToPlot`. Default is Ensembl
2527# ' gene IDs ("ensembl"), but can also input a vector of HGNC symbols ("hgnc").
2628# ' @param pCutoff P value cutoff, default is <0.05
@@ -128,7 +130,7 @@ plotFoldChange <- function(
128130 pathId = NA ,
129131 genesToPlot = NA ,
130132 manualTitle = NA ,
131- titleSize = 14 ,
133+ fontSizes = c( 13.2 , 13.2 , 12 , 12 , 10 , 10 ) ,
132134 geneFormat = " ensembl" ,
133135 pCutoff = 0.05 ,
134136 fcCutoff = 1.5 ,
@@ -167,6 +169,17 @@ plotFoldChange <- function(
167169 geneFormat %in% c(" ensembl" , " hgnc" )}
168170 )
169171
172+ stopifnot(" Incorrect format for 'fontSizes'" = {
173+ is(fontSizes , " numeric" ) & length(fontSizes ) == 6
174+ })
175+
176+ sizeColTitle <- fontSizes [1 ]
177+ sizeRowTitle <- fontSizes [2 ]
178+ sizeColNames <- fontSizes [3 ]
179+ sizeRowNames <- fontSizes [4 ]
180+ sizeLegendTitle <- fontSizes [5 ]
181+ sizeLegendLabels <- fontSizes [6 ]
182+
170183 # # Coerce the input
171184 if (is(inputList [[1 ]], " DESeqResults" )) {
172185 inputListCleaned <- lapply(inputList , function (x ) {
@@ -330,10 +343,11 @@ plotFoldChange <- function(
330343 heatmapLegendInfo <- .plotFoldChangeLegend(
331344 .matFC = matFC ,
332345 .log2FoldChange = log2FoldChange ,
333- .cellColours = cellColours
346+ .cellColours = cellColours ,
347+ .titlegp = sizeLegendTitle ,
348+ .labelsgp = sizeLegendLabels
334349 )
335350
336-
337351 # # If columns aren't being split
338352 if (is.na(colSplit [1 ])) {
339353 colSplit <- rep(NA , length(inputListCleaned ))
@@ -406,7 +420,10 @@ plotFoldChange <- function(
406420 column_title = plotTitle ,
407421 row_title = NULL ,
408422 heatmap_legend_param = heatmapLegendInfo [[1 ]],
409- column_title_gp = gpar(fontsize = titleSize ),
423+ column_title_gp = gpar(fontsize = sizeColTitle ),
424+ row_title_gp = gpar(fontsize = sizeRowTitle ),
425+ column_names_gp = gpar(fontsize = sizeColNames ),
426+ row_names_gp = gpar(fontsize = sizeRowNames ),
410427 row_split = rowSplit ,
411428 column_split = colSplit ,
412429 cluster_columns = clusterColumns ,
@@ -425,6 +442,8 @@ plotFoldChange <- function(
425442# ' @param .matFC Matrix of fold change values
426443# ' @param .log2FoldChange Boolean denoting if values will be in log2
427444# ' @param .cellColours Colours for fold change values
445+ # ' @param .titlegp Font size for the title of the legend
446+ # ' @param .labelsgp Font size for the labels of the legend
428447# '
429448# ' @return A list containing heatmap legend parameters and colour function
430449# '
@@ -435,10 +454,12 @@ plotFoldChange <- function(
435454# '
436455# ' @seealso <https://github.com/hancockinformatics/pathlinkR>
437456# '
438- .plotFoldChangeLegend <- function (.matFC , .log2FoldChange , .cellColours ) {
457+ .plotFoldChangeLegend <- function (.matFC , .log2FoldChange , .cellColours , .titlegp , .labelsgp ) {
439458
440459 parameters <- list (
441- title = ifelse(.log2FoldChange , " Log2 fold\n change" , " Fold change" )
460+ title = ifelse(.log2FoldChange , " Log2 fold\n change" , " Fold change" ),
461+ title_gp = gpar(fontsize = .titlegp ),
462+ labels_gp = gpar(fontsize = .labelsgp )
442463 )
443464
444465 limit <- ceiling(max(abs(.matFC )))
0 commit comments