How to control the text size for colAttributes in the annotation bar for dbaplot() or dba.plotHeatmap()
1
0
Entering edit mode
researcher • 0
@researcher-20723
Last seen 20 months ago
United States

Hi Rory, I am unable to control the text size for colAttributes in the annotation bar for dbaplot() or dba.plotHeatmap(). Can you or anyone please guide how should I do the same. Ill really appreciate your help. Thanks

diffbind dbaplot() dba.plotHeatmap() • 441 views
ADD COMMENT
0
Entering edit mode

Kindly someone help, I am really stuck with this.

ADD REPLY
0
Entering edit mode
@james-w-macdonald-5106
Last seen 42 minutes ago
United States

The short answer is that you can't. The annotation bar is added using this block of code, from heatmap.3:

 if (!missing(ColSideColors)) {
        if (!is.null(ColSideColors)) {
            if (ncol(ColSideColors) == 1) {
                par(mar = c(0.5, 0, 0, margins[2]))
                image(cbind(1:nc), col = ColSideColors[, 1][colInd], 
                  axes = FALSE)
                axis(2, 0, colnames(ColSideColors)[1], las = 2, 
                  tick = F)
            }
            else {
                par(mar = c(0.5, 0, 0, margins[2]))
                csc = ColSideColors[colInd, ]
                csc.colors = matrix()
                csc.names = names(table(csc))
                csc.i = 1
                for csc.name in csc.names) {
                  csc.colors[csc.i] = csc.name
                  csc[csc == csc.name] = csc.i
                  csc.i = csc.i + 1
                }
                csc = matrix(as.numeric(csc), nrow = dim(csc)[1])
                image(csc, col = as.vector(csc.colors), axes = FALSE)
                if (length(colnames(ColSideColors)) > 0) {
                  axis(2, 0:(dim(csc)[2] - 1)/(dim(csc)[2] - 
                    1), colnames(ColSideColors), las = 2, tick = FALSE)
                }
            }
        }
    }

In particular the call to axis (there's two axis calls, depending on the number of annotations), which you will note doesn't have an ellipsis (...) argument, so you can't pass any variables in. And there is no cex.axis argument there to control the text size.

The long answer is 'well, fix it yourself if you really want it'. The beauty and the peril of Open Source software is that the code is available to everybody to do with as they see fit. It wouldn't take that much to download the sources to DiffBind and then add an ellipsis argument to that call to axis and then add a cex.axis argument to your call to dba.plotHeatmap.

The peril being that there may be other functions within dba.plotHeatmap or pv.plotHeatmap or any number of other helper functions that might also be able to do something with a cex.axis argument, which may have unintended consequences (the ellipsis argument allows you to pass arbitrary arguments to underlying functions - the problem being that any function that recognizes cex.axis as an argument will pick it up and use it). An alternative would be to add a specific argument to the function chain (say, 'omgfixthattextalready'), from dba.plotHeatmap to pv.plotHeatmap to heatmap.3 and finally that axis call that is used to adjust the cex.axis. The axis call would then look like (using the first one as an example - you have to fix both).

axis(2, 0, colnames(ColSideColors)[1], las = 2, tick = FALSE, cex.axis = omgfixthattextalready)

Then just build and install, and voila!

ADD COMMENT

Login before adding your answer.

Traffic: 754 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6