0.1.0 • Published 6 years ago

higlass-scalable-insets v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Scalable Insets for HiGlass

Explore your beloved 2D annotations with Scalable Insets in HiGlass

HiGlass Scalable Insets Video Build Status

Scalable Insets is a new technique for interactively exploring and navigating large numbers of annotated patterns in multiscale visual spaces such as gigapixel images, matrices, or maps. Our technique visualizes annotated patterns too small to be identifiable at certain zoom levels using insets, i.e., magnified thumbnail views of the patterns. Find out more at http://scalable-insets.lekschas.de and watch our <5min introductory video at https://youtu.be/7Bn4mNLl3WQ.

Image of Scalable Insets

Note: This is the source code for the Scalable Insets tracks only! You might want to check out the following repositories as well if you want to know how Scalable Insets is integrated into HiGlass or use it with images or geographic maps:

Installation

npm install higlass-scalable-insets

Usage

  1. Make sure you load this track prior to hglib.js. For example:
<script src="higlass-scalable-insets.js"></script>
<script src="hglib.js"></script>
<script>
  ...
</script>
  1. Configure the track in the view config.
{
  ...,
  tracks: {
    center: [
      {
        type: 'combined',
        options: {},
        contents: [
          // This tracks loads the Hi-C matrix
          {
            server: 'http://higlass.io/api/v1/',
            tilesetUid: 'CQMd6V_cRw6iCI_-Unl3PQ',  // Rao et al. 2014 GM12878
            type: 'heatmap',
          },
          // This track loads the annotated patterns
          {
              server: '//higlass.io/api/v1',
              tilesetUid: 'HunfK2D3R9iBdIq-YNYjiw',
              uid: 'anno-loops-1',
              type: '2d-rectangle-domains',
          },
          // This track is responsible for rendering the insets.
          {
            server: '//higlass.io/api/v1/',
            tilesetUid: 'CQMd6V_cRw6iCI_-Unl3PQ',
            uid: 'insets',
            type: 'insets',
            dataType: 'matrix',
          },
        ],
      },
    ],
    // You could also display the insets on the gallery of the matrix
    // gallery: {
    //   server: '//higlass.io/api/v1/',
    //   tilesetUid: 'CQMd6V_cRw6iCI_-Unl3PQ',
    //   type: 'insets',
    //   dataType: 'matrix',
    // },
    ...
  },
  metaTracks: {
    type: 'annotations-to-insets',
    insetsTrack: 'insets',
    options: {
      annotationTracks: ['ski-areas'],
    },
  }
}

Take a look at src/index.html for an example.

Configuration

Scalable Insets requires 2 tracks. An insets track, which handles the insets, and an annotations-to-insets track, which links all drawn annotations and compute the placement and clustering of insets.

Track: annotations-to-insets

Settings

OptionTypeDescription
uidstrUnique identifier.
typestrMust be annotations-to-insets.
insetsTrackstrUID of the insets track.

Options

The following options let you adjust the trade-off between Details, Context, and Locality. Please see the paper for details.

OptionTypeDefaultDescription
annotationTracks*array of str[]Annotation tracks defining patterns.
boostContextnum1Higher boost means higher penalty for inset-context overlap (i.e., overlap of insets and other annotated regions).
boostDetailsnum1Higher boost means higher penalty for inset-inset overlap.
boostLayoutnum1Higher boost means more iteration cycles of the simulated annealing algorithm.
boostLayoutInitnum1Higher boost means more iteration cycles of the simulated annealing algorithm on start up.
boostLocalitynum1Higher boost means higher penalty for distance between insets and their origin.
clusterAmongstrNoneCluster only insets of the same type. Each type its own track.
disableClusteringboolfalseIf true disables clustering of insets.
excludeTracksarray of str[]Annotation tracks which patterns should not be displayed as insets but which should still contribute to the placement of insets.
gridSizeint48Distance threshold from inset (or cluster) to another inset (or cluster) to determine whether both should be clustered.
insetThresholdint24Minimum size (in pixels) of an annotation for which an inset should be displayed. I.e., if the annotation gets larger the inset is removed.
maxClusterDiameternum48Maximum cluster diameter in projected pixel.
maxClusterSizeintInfinityMaximum cluster size by number of clustered insets.

*) Note This is the only mandatory option, I know it doesn't make sense semantically but it was the easiest way to implement given that HiGlass by default does not pass the entire track config to a track.

Track: insets

Settings

OptionTypeDescription
serverstrURL from where the tileset should be loaded.
tilesetUidstrUID of the tileset to explore.
uidstrUID to identify this track. Needed by the annotations-to-insets track.
typestrMust be insets.
chromInfoPathstrURL to a chromosome info file.
dataTypestrEither cooler or image.
heightintHeight (or width) of the insets track if positioned as a gallery track. By default the height is 24px.

Options

OptionTypeDefaultDescription
aggregationstrgalleryAggregation mode. Options are gallery and pile.
borderColorstrwhiteColor of the insets border and background. Color names and HEX are supported.
borderRadiusint2Border radius of the inset.
borderWidthint2Border width of the inset.
colorRangearray of strfall color mapColor map for rendering matrix insets.
dropBlurnum3Degree of blurring the drop shadow of insets.
dropDistancenum1Distance of the drop shadow of insets.
dropOpacitynum0.8Opacity of the drop shadow of insets.
focusColorstrorange"Focus color of insets, i.e., when mousing over an inset."
indicatorColorstrblackColor of icons attached to the inset.
insetOriginPaddingint6Minimum distance between insets and their origin. Smaller distances will be penalized.
isFocusBorderOnScalebooltrueIf true change border color to focusColor upon scale up of an inset.
isIgnoreDiagint0Number of diagonals to be ignored. Only applied to matrix insets.
isLogTransformarray of str[]List of annotation types which should be log transformed. Only applied to matrix insets.
leaderLineColorstrwhiteColor of the leader line.
leaderLineDynamicboolfalseIf true leader line will update dynamically based on the cursor's distance to insets.
leaderLineDynamicMaxDistnum256Maximum distance from which onwards the leader line is most faded out.
leaderLineDynamicMinDistnum12Minimum distance from which onwards the leader line is most faded in.
leaderLineFadingboolobjfalse"If true fading is defined as { 0: 1, 0.35: 0.33, 0.65: 0.33, 1: 1 }. This key-value object defines cursor-origin distance to leader line opacities and can customized if needed."
leaderLineOpacitynum1Leader line opacity.
leaderLineStubLengthboolnumfalse (if true then 12)Can either be boolean (defaults to the 12px) or a specific length in pixel for the leader line stub length.
leaderLineStubWidthint2Base width of the leader line stubs.
leaderLineStubWidthMaxint2Minimum width of leader line stubs.
leaderLineStubWidthMinint4Maximum width of leader line stubs.
leaderLineWidthint2Base leader line width in pixel.
loadHiResOnScaleUpboolfalseIf true load a higher resolution insets upon clicking on the inset.
maxPreviewsint8Maximum number of pile previews.
maxSizeint16Maximum inset size in pixels (not including the base scaling)
minSizeint8Minimum inset size in pixels (not including the base scaling)
onClickScalenum2Scale factor when clicking on an inset.
paddingint0"Relative padding for determining the zoom level when cutting out insets. E.g., 0.2 refers to 20% padding. Only regarded for matrix insets from cooler."
paddingCustomobj{}"Key-value pairs for resolution-based padding for determining the zoom level. E.g., { 5000: 8, 10000: 4 } refers to 800% padding for resolutions of 5000 or lower. Only regarded for matrix insets from cooler."
paddingLocinum0Location based padding for cutting out more than just the annotated pattern.
paddingLociCustomobj{}"Key-value pairs defining resolution-based location padding. E.g., { 5000: 0.5, 10000: 0.25 } refers to 50% padding for resolutions of 5000 or lower."
pileOrientationstrbottomWhere to display pile previews.
previewSizeint4Height of the previews in pixel. Only needed when matrix piles.
resolutionint0Default resolution. Only needed for matrix insets from cooler.
resolutionCustomobj{}
scaleint3Default scale factor of insets. Optimized for matrix insets from cooler.
scaleBorderBystrNoneCan be any kind of inset property like 'clusterSize'.
scaleSizeBystrNoneCan be any kind of inset property like 'clusterSize'.
selectColorstrfuchsia"Color name or HEX value for coloring the insets upon selection, i.e., when being scaled up."
sizeStepSizeint2Steps in pixel to increment the size of insets.

Development

Installation

$ git clone https://github.com/flekschas/higlass-scalable-insets && higlass-scalable-insets
$ npm install

Commands

Developmental server: npm start

Production build: npm run build

Co-Development with HiGlass

If you need to work on HiGlass and Scalable Insets in parallel I recommend the following setup:

  1. Link a local HiGlass instance:
git clone https://github.com/hms-dbmi/higlass && cd higlass && npm install
npm link
npm run build
  1. Open another terminal, link the HiGlass instance and start the web server
cd higlass-scalable-insets
npm link higlass
npm start

Now, whenever you make changes to your local HiGlass instance it will be re-build and also trigger a re-build of the Scalable Insets track.