Skip to content

DoseResponseCurve

Dose-response curve with 4-parameter logistic fitting, IC50 display, and confidence intervals.

Demo

Usage

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

<DoseResponseCurve data={doseResponseData} width={600} height={400} />

Data Type — DoseResponseData

FieldTypeRequiredDescription
curvesDoseResponseCurveData[]yesOne or more curves
xLabelstringnoX-axis label
yLabelstringnoY-axis label

DoseResponseCurveData

FieldTypeRequiredDescription
labelstringyesCurve name
points{ x, y }[]yesData points
fitDoseResponseFitnoFitted curve + params
colorstringnoCurve color

Props

PropTypeDefaultDescription
dataDoseResponseDataPrimary data prop
widthnumber500SVG width
heightnumber350SVG height

Example — Constructing Data

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

const data: DoseResponseData = {
  curves: [
    {
      label: 'Compound A',
      points: [
        { x: 0.001, y: 98 }, { x: 0.003, y: 97 }, { x: 0.01, y: 95 }, { x: 0.03, y: 88 },
        { x: 0.1, y: 72 }, { x: 0.3, y: 42 }, { x: 1, y: 18 }, { x: 3, y: 8 }, { x: 10, y: 5 },
      ],
      fit: {
        line: Array.from({ length: 100 }, (_, i) => {
          const x = 0.0001 * Math.pow(10, i * 5 / 99);
          return { x, y: 5 + (98 - 5) / (1 + Math.pow(x / 0.35, 1.2)) };
        }),
        params: { top: 98, bottom: 5, ic50: 0.35, hillSlope: -1.2 },
        r2: 0.997,
        ci95: { ic50: [0.28, 0.43] as [number, number] },
      },
    },
    {
      label: 'Compound B',
      points: [
        { x: 0.001, y: 99 }, { x: 0.01, y: 96 }, { x: 0.1, y: 90 }, { x: 0.3, y: 75 },
        { x: 1, y: 50 }, { x: 3, y: 25 }, { x: 10, y: 12 }, { x: 30, y: 8 },
      ],
      fit: {
        line: Array.from({ length: 100 }, (_, i) => {
          const x = 0.0001 * Math.pow(10, i * 5.5 / 99);
          return { x, y: 8 + (99 - 8) / (1 + Math.pow(x / 1.1, 1.0)) };
        }),
        params: { top: 99, bottom: 8, ic50: 1.1, hillSlope: -1.0 },
        r2: 0.994,
      },
    },
  ],
};

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