Skip to content

VolcanoPlot

Volcano plot for differential expression analysis with significance thresholds and gene labels.

Demo

Usage

svelte
<script>
  import { VolcanoPlot } from '@molbiohive/hatchlings';
</script>

<VolcanoPlot data={volcanoData} width={500} height={400} />

Data Type — VolcanoData

FieldTypeRequiredDescription
pointsDataPoint[]yesGene data points
thresholdsThresholdsnoSignificance cutoffs

DataPoint

FieldTypeDescription
xnumberlog2(fold change)
ynumber-log10(p-value)
labelstringGene name (shown for significant)
significantbooleanWhether it passes thresholds

Props

PropTypeDefaultDescription
dataVolcanoDataPrimary data prop
widthnumber500SVG width
heightnumber400SVG height
highlightSignificantbooleantrueHighlight significant points

Example — Constructing Data

ts
import type { VolcanoData } from '@molbiohive/hatchlings';

const data: VolcanoData = {
  points: Array.from({ length: 200 }, (_, i) => {
    // Deterministic pseudo-random
    const seed1 = Math.sin(i * 127.1) * 43758.5453;
    const r1 = seed1 - Math.floor(seed1);
    const seed2 = Math.sin(i * 269.5) * 43758.5453;
    const r2 = seed2 - Math.floor(seed2);
    const x = (r1 - 0.5) * 8;
    const y = r2 * 6;
    return {
      x, y,
      label: Math.abs(x) > 1 && y > 1.3 ? `Gene${i}` : undefined,
      significant: Math.abs(x) > 1 && y > 1.3,
    };
  }),
  thresholds: { x: 1, y: 1.3, xNeg: -1 },
};

This is the data powering the demo above. See docs/data/charts.ts for the full source.