npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

biowc-heatmap

v0.5.2

Published

An interactive, zoomable heatmap with rich annotations and selectable dendrograms for exploring biological datasets.

Downloads

29

Readme

biowc-heatmap

An interactive, zoomable heatmap with rich annotations and selectable dendrograms for exploring biological datasets.

Installation

npm i biowc-heatmap

Usage

The component is built using lit-element. It is a webcomponent so you can use it with any framework or library like Vue or React or just in vanilla js:

<biowc-heatmap id="heatmap"></biowc-heatmap>
<biowc-heatmap-legend id="legend"></biowc-heatmap-legend>

<script type="module">
  import '../dist/src/biowc-heatmap.js';
  import '../dist/src/biowc-heatmap-legend.js';

  const biowcHeatmap = document.querySelector('#heatmap');

  // Set the color of the heatmap cells
  biowcHeatmap.cellColor = '#ff0000';

  // Sets the color scale which will be used to color the heatmap cells.
  // `.color` will be ignored if `.colorScale` is set
  biowcHeatmap.cellColorScale = {
    colors: ['#0000bb', '#ffffff', '#ff0000'],
    values: [-2, 0, 1]
  };
  // `biowcHeatmap.color = '#ff0000';` is equivalent to:
  // `biowcHeatmap.colorScale = { colors: ['#ffffff', '#ff0000'], values: [0, 1] };`
  // values which are outside the range of `values` will be correspondingly colored
  // with the color for the lowest or highest value in `colors`.


  // Sets the data values which the cells will be colored based on.
  biowcHeatmap.data = [
    [-3, 0.6, -1],
    [0.1, 0.0, -0.7],
    [-0.5, 0.7, 2.0],
  ];

  // Sets the labels on the sides
  biowcHeatmap.labels = {
    top: ['T1', 'T2', 'T3'],
    left: ['L1', 'L2', 'L3'],
    right: ['R1', 'R2', 'R3'],
    bottom: ['B1', 'B2', 'B3'],
  };

  // Sets the axis labels
  biowcHeatmap.axisLabels = {
    top: 'Top',
    left: 'Left',
    right: 'Right',
    bottom: 'Bottom',
  };

  // Set the colors for the color annotation bar
  biowcHeatmap.colorAnnots =  {
    top: ['#1f77b4', '#1f77b4', '#ff7f0e'],
    left: ['#1f77b4', '#1f77b4', '#ff7f0e'],
    right: ['#1f77b4', '#1f77b4', '#ff7f0e'],
    bottom: ['#1f77b4', '#1f77b4', '#ff7f0e'],
  };

  // Set labels for the colors in the color annotation bar
  biowcHeatmap.colorAnnotLabels =  {
    top: {
      '#1f77b4': 'A',
      '#ff7f0e': 'B',
    },
    left: {
      '#1f77b4': 'C',
      '#ff7f0e': 'D',
    },
    right: {
      '#1f77b4': 'E',
      '#ff7f0e': 'F',
    },
    bottom: {
      '#1f77b4': 'H',
      '#ff7f0e': 'I',
    }
  }

  // Pass dendrograms as tree structure
  const dendrogramTree = {
    left: {
      left: 0,
      right: 1,
      height: 1,
    },
    right: 2,
    height: 2,
  };

  // Or as a self referencing array which is more performant and required for large datasets
  const dendrogramArray = [
    {
      left: 0,
      isLeftDendrogram: false,
      right: 1,
      isRightDendrogram: false,
      height: 1,
    },
    {
      left: 0,
      isLeftDendrogram: true,
      right: 2,
      isRightDendrogram: false,
      height: 2,
    }
  ];

  // Sets the dendrograms for the sides
  biowcHeatmap.dendrograms = {
    top: dendrogramTree,
    left: dendrogramArray,
    right: dendrogramTree,
    bottom: dendrogramArray,
  };

  // Set the `forHeatmap` property of the legend to the heatmap just created
  // The legend will then be created according to the properties set on the heatmap
  const biowcHeatmapLegend = document.querySelector('#legend');
  biowcHeatmapLegend.forHeatmap = biowcHeatmap;

  // Set the title for the color scale in the legend
  biowcHeatmapLegend.colorScaleTitle = 'Unit description'
</script>

Contributing

If you found a bug or think an important feature is missing, please open an issue. PRs are also welcome. There are no guidelines yet for contribution.

License

This project is licensed under the MIT license.