Heatmaps can be created using a CUSTOM chart.

Here we describe a common use case, creating a SNP Matrix Heatmap.

Example project

For an example Microreact project showing data structure and VegaLite settings for a SNP Matrix Heatmap, please see https://microreact.org/project/snp-matrix-heatmap-demo


The data for this SNP Matrix is essentially a list of sample-ids in one column, and a column for each sample-id. The value of the datatable cell contains the number of SNPs differing between the sample-id in the row and the sample-id in the column.

Ideally, the matrix data columns would be added to your metadata table, rather than requiring a second metadata file in the Microreact project. The columns would simply need to be joined to another dataset containing the same sample-id column.

Bring the matrix file in to Microreact with all columns clearly labeled (including the top left corner, which may be unlabeled in some raw matrix files, but which should be "id" or whatever is your id column in the metadata table).

VegaLite Specs

The key to a SNP Matrix in VegaLite is the "fold" function.

  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "url": "https://microreact.org/api/files/raw?6e0532abce94bb92cf473b9b95f2d88a389a46e0",
    "format": {
      "type": "csv"
  "transform": [
      "fold": [
  "mark": "rect",
  "encoding": {
    "x": {
      "field": "sample1",
      "type": "nominal"
    "y": {
      "field": "key",
      "type": "nominal"
    "color": {
      "field": "value",
      "type": "quantitative",
      "scale": {
        "domain": [
        "scheme": "viridis",
        "type": "linear"
  "config": {
    "view": {
      "stroke": "transparent"

Last updated