Skip to main content

A python package for heatmap clustering and plotting

Project description

Author: Matthias Bieg

hmap: Python Heatmap Package

This package implements a convenient heatmap plotting package in python. It offers low level functions for

  1. Plotting
    • Heatmaps
    • Dendrograms
    • Annotations
    • Legends
  2. Figure layouting

Clustered heatmap

Clustered Heatmap

Grouped clustered heatmap

Grouped Clustered Heatmap

Figure layout

The hmap package comes with a module for defining the layout of a figure using absolute length measurements. Currently the only unit supported is milimeters. The layout of a figure is defined as a grid. You have to specify

  • the number of rows,
  • the number of columns,
  • the widths of the columns,
  • the heights of the rows,
  • the vertical distance between adjacent rows,
  • the horizontal distance between adjacent columns,
  • the size of the bottom border margin,
  • the size of the top border margin,
  • the size of the left border margin, and
  • the size of theright border margin As said before, the sizes are given in milimeters.

Example

import sys
import hmap
import matplotlib.pyplot as plt

fig, gs = hmap.layout.layout.layoutGrid(4, 5, [10., 2., 40., 40., 40], [10., 2., 40., 40.], 1., 1., 20., 15., 15., 20.)
col_widths = ["10 mm", "2 mm", "40 mm", "40 mm", "40 mm"]
row_heights = ["10 mm", "2 mm", "40 mm", "40 mm"]

for row_idx in range(4):
    for col_idx in range(5):
        ax = plt.subplot(gs[row_idx, col_idx])
        plt.xticks([], [])
        plt.yticks([], [])
        if(row_idx == 0):
            ax.xaxis.set_label_position("top")
            plt.xlabel(col_widths[col_idx], 
                       fontsize=7, 
                       rotation=90)
        if(col_idx == 0):
            plt.ylabel(row_heights[row_idx], 
                       fontsize=7, 
                       rotation=0, 
                       horizontalalignment="right",
                       verticalalignment="center")

Figure layout

Installation

pip install hmap

Usage Example

Please check the jupyter notebook for an example of how to use hmap.

Acknowledgements

This package was implemented during my time at the German Cancer Research Center in the group of Theoretical Bioinformatics headed by Prof. Dr. Roland Eils, where i was part of the core bioinformatics team of the Heidelberg Institute of Personalized Oncology (HIPO). Further refinment and final upload to PyPI was done during my time at Charite, Universitaetsmedizin Berlin, Berlin Institute of Health (BIH) in the Department of Digital Health headed by Prof. Roland Eils.

License

Copyright (c) 2021, Matthias Bieg

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hmap-0.9.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hmap-0.9.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file hmap-0.9.2.tar.gz.

File metadata

  • Download URL: hmap-0.9.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for hmap-0.9.2.tar.gz
Algorithm Hash digest
SHA256 95a98e62113b5a64e3f0faeb37e7e0e397507ddcb1c551e33388ba01cfa376e8
MD5 419caef0579ac39d03e2cdbf7759dc12
BLAKE2b-256 3be0c66e2c1b032c5e3f42042a0b872d3fe2cb2c9f450e77dc5c14d1d1f8c71b

See more details on using hashes here.

File details

Details for the file hmap-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: hmap-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for hmap-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 69eddf6873e73778a98cc8be80d3907135a913ddf5297f5bce560b704a759514
MD5 0c10f39c60dfd12f5dd6bd6f356b7010
BLAKE2b-256 16ea805d7cae40a73f395b6b3a300dc0a7035a0cc8cb850add38e7d22ab10c62

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page