ExtendableHeatmap should support plotting rectangular arrays

Issue #51 new
Thomas Gilgenast created an issue

No description provided.

Comments (8)

  1. Thomas Gilgenast reporter

    one step could be to make sure we pass the correct dimensions of the array as the extent kwarg passed to plt.imshow() as shown in this notebook:

    https://colab.research.google.com/drive/1XxVGBU_1Dm3ucu8TsJOKgPHWRLhhRqRQ

    the gene tracks appear squished because ExtendableFigure.add_margin_ax() appends new axes based on a percentage of the dimension of the root figure that the axis is being appended against, but this could also be changed to always refer to the y-axis of the heatmap for example

  2. Thomas Gilgenast reporter

    a temporary workaround for the genes getting squished has been added to the bottom of the colab notebook linked above - it relies on adding gene stacks separately to the left and bottom margins, and manually calculating a size kwarg that will keep the genes the same size on both axes

  3. Thomas Gilgenast reporter

    a follow up to the gene track sizing: it’s clear that we want margin tracks on the two axes (x vs y) to be proportional in size to each other, but it’s not clear what frame of reference to use when establishing their size relative to the heatmap

    this matters most when multiple heatmaps are being drawn with different aspect ratios and then rendered side-by-side

    options for the frame of reference to use include:

    • y-axis

      • if multiple heatmaps are rendered with equal total height (e.g. when being placed in one row of a figure) the gene tracks will be of comparable size, but the pixels on the heatmap will only be of comparable size if the y-axis granges are similar - the effect is similar to what would happen if you rendered a square heatmap and then extended it to the right
    • longer axis

      • inuitively this is the proportion you’d get if you plotted a square heatmap then cropped it
    • shorter axis

      • if you render two heatmaps with different total heights (i.e., you completely throw “rows“ out the window as a concept in your figure design) so that their short axes are of similar size, the margin tracks will also be of comparable size
    • pixel

      • if you render two heatmaps with different total heights so that their pixels are of similar size, the margin tracks will also be of comparable size
    • transposing the matrix to always keep a relatively similar aspect ratio (i.e., either “landscape“ or “portrait“) across the different heatmaps

      • in this case it doesn’t really matter which of the options above you choose

    it’s important to classify and discuss these use cases since in the future we may provide official support for one or several of these

    one “default“ recommendation might be to hold the y-axis grange fixed (e.g., when comparing contacts from one locus of interest to several distal loci) and use the y-axis as a frame of reference - when rendered with equal total heights side by side, both the pixels and the gene tracks will be of similar size. in this case, it sounds like the matrices should be transposed so that the y-axes refer to the same grange, regardless of what the final aspect ratios become.

    when different regions are being compared (i.e., no side of any zoom window is shared with any other), it seems reasonable to use the y-axis as a frame of reference and draw the heatmaps side by side at similar heatmap height, then the margin tracks should have the same size. one alternative is to use the pixel size as a reference, but this seems strictly worse because a) if the y-axis granges are of different length the rendered heatmaps will not stay in one “row“ and b) we are historically comfortable with different pixel sizes in different heatmaps (e.g., zoomin heatmaps have bigger pixels the more zoomed in they are). transposing the matrices to achieve a similar aspect ratio sounds like a good idea in this case for aesthetic reasons (consistency across heatmaps).

    to align chipseq tracks vertically on the x-axis when they are plotted after refgene stacks, it should be possible to add blank horizontal gene tracks to equalize the total number of gene tracks in the two heatmaps. it is possible to look up the numbers of the horizontal gene tracks in each heatmap using len([n for n in h.axes.keys() if 'horizontal_gene_track_' in n])

    in the short term, it is possible to use the logic in the notebook linked above to accomplish any of the options mentioned above

  4. Thomas Gilgenast reporter

    one detail currently missing from the notebook is that the padding added between consecutive margin axes is defined in what I believe are absolute plot units - the notebook illustrates how to adjust the sizes of margin axes but not the padding

  5. Log in to comment