Learn R Programming

HilbertCurve

Hilbert curve is a type of space-filling curves that fold one dimensional axis into a two dimensional space, but with still keeping the locality. It has advantages to visualize data with long axis in following two aspects:

  1. greatly improve resolution for the visualization;
  2. easy to visualize clusters because generally data points in the cluster will also be close in the Hilbert curve.

This package aims to provide an easy and flexible way to visualize data through Hilbert curve. The implementation and example figures are based on following sources:

Citation

Zuguang Gu, Roland Eils, and Matthias Schlesner, HilbertCurve: an R/Bioconductor package for high-resolution visualization of genomic data. Bioinformatics 2016

Install

The package is at Bioconductor now and you can install the newest version by:

library(devtools)
install_github("jokergoo/ComplexHeatmap")  # in order to get the newest version of ComplexHeatmap
install_github("jokergoo/HilbertCurve")

Usage

Basically, there are two steps to make a Hilbert curve.

  1. Initialize the curve and also map the one-dimensional axis to the curve.
  2. add low-level graphics by hc_points(), hc_segments(), ... by giving the positions of the graphics.
hc = HilbertCurve(1, 100, level = 4)
hc_points(hc, ...)
hc_segments(hc, ...)
hc_rect(hc, ...)
hc_text(hc, ...)

There is another 'pixel' mode which provides a high resolution for visualizing genomic data by the Hilbert curve.

hc = HilbertCurve(1, 100000000000, level = 10)
hc_layer(hc, ...) # this can be repeated several times to add multiple layers on the curve
hc_png(hc, ...)

Examples

Rainbow color spectrum:

Chinese dynasty:

GC percent and genes on chromosome 1:

Association between H3K36me3 histone modification and gene bodies:

Methylation on chromosome 1:

Copy number alterations in 22 chromosomes:

License

GPL (>= 2)

Copy Link

Version

Version

1.2.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Zuguang Gu

Last Published

April 25th, 2016

Functions in HilbertCurve (1.2.2)

hc_layer-dispatch

Method dispatch page for hc_layer
hc_rect-GenomicHilbertCurve-method

Add rectangles on Hilbert curve
hc_polygon-dispatch

Method dispatch page for hc_polygon
HilbertCurve

Initialize a Hilbert curve
hc_segments-GenomicHilbertCurve-method

Add line segments to Hilbert curve
GenomicHilbertCurve-class

The GenomicHilbertCurve class
hc_rect-dispatch

Method dispatch page for hc_rect
hc_map-GenomicHilbertCurve-method

Draw a map which represents positions of different chromosomes on the curve
show-HilbertCurve-method

Print the HilbertCurve object
unzoom-HilbertCurve-method

Transform zoomed positions to their original values
hc_text-dispatch

Method dispatch page for hc_text
zoom-HilbertCurve-method

Zoom original positions
hc_level-HilbertCurve-method

Level of the Hilbert curve
hc_rect-HilbertCurve-method

Add rectangles on Hilbert curve
hc_centered_text-HilbertCurve-method

Add text to the center of the block
hc_points-dispatch

Method dispatch page for hc_points
hc_text-HilbertCurve-method

Add text to Hilbert curve
hc_normal_points-HilbertCurve-method

Add points to the Hilbert curve
HilbertCurve-class

The HilbertCurve class
hc_polygon-HilbertCurve-method

Add polygons to Hilbert curve
hc_png-HilbertCurve-method

Save Hilbert curve as a PNG figure
hc_points-HilbertCurve-method

Add points to the Hilbert curve
hc_segmented_points-HilbertCurve-method

Add points to the Hilbert curve
hc_text-GenomicHilbertCurve-method

Add text to Hilbert curve
GenomicHilbertCurve

Initialize a Hilbert curve specifically for genomic data
default_overlay

Default color overlay for adding new layers
hc_points-GenomicHilbertCurve-method

Add points to the Hilbert curve
hc_layer-GenomicHilbertCurve-method

Add a new layer to the Hilbert curve
hc_polygon-GenomicHilbertCurve-method

Add text to Hilbert curve
hc_segments-dispatch

Method dispatch page for hc_segments
hc_offset-HilbertCurve-method

Adjust positions
hc_layer-HilbertCurve-method

Add a new layer to the Hilbert curve
hc_segments-HilbertCurve-method

Add line segments to Hilbert curve