Sequence Logo
A motif as stacks of letters: each position as tall as the information it carries, each letter as tall as its share. The letters take the same hues as Nucleotide and Amino Acid, so a logo reads with the sequences around it.
Install
npx shadcn@latest add @nelumbo/sequence-logoA motif
Where p53 binds DNA, from 17,412 sites in JASPAR (MA0106.3): two half-sites, each with the CATG core at full height. A position matrix of counts goes straight in; hover a stack for every base's share.
Bits or probability
"bits" sizes each stack by its information, so the positions that matter stand out. "probability" fills every stack, for reading the mix at a loose position. A background composition turns bits into relative entropy, for genomes far from a quarter of each base.
Protein
The C2H2 zinc finger, from Pfam's seed alignment of 151 sequences (PF00096). The two cysteines and two histidines that hold the zinc tower over the rest; the hydrophobic F and L that pack the core sit in between.
Strands
CTCF's motif (JASPAR MA0139.1) on either strand: reverseComplement flips the matrix and swaps each base for its partner.
Small samples
With few sequences, chance alone makes a position look conserved. The small-sample correction takes that expected information off every stack. Eight zinc fingers, with and without it.
Selection
selectable makes the logo one keyboard stop, like a chart: arrows move a position, Shift extends, Home and End jump, Escape clears. Drag with the pointer. The selected stretch reads out its consensus and total bits.
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
sequences | string[] | Aligned sequences of one length; - or . for gaps. | |
matrix | Record<string, number>[] | Or a position matrix, counts or frequencies per position (JASPAR, MEME, TRANSFAC). | |
type | "dna" | "rna" | "protein" | detected | The alphabet: 2 bits a position for DNA, 4.32 for protein. |
scheme | Nucleotide or AminoAcid scheme | "nelumbo" | The letter hues. |
mode | "bits" | "probability" | "bits" | Stacks sized by information, or all full height. |
correction | boolean | true | Small-sample correction, (s − 1) / (2 ln 2 n). Skipped for frequencies. |
background | Record<string, number> | Letter composition to measure against (relative entropy). | |
reverseComplement | boolean | false | The other strand, read 5′ to 3′. |
columnStart | number | 1 | The number of the first position. |
height / maxColumnWidth | number | 160, 40 | Plot height; the widest a stack gets. Below 12 px a stack, the logo scrolls. |
yAxis / ruler | boolean, boolean | number | true, true | The bits axis; position numbers, every one that fits or every n. |
consensus | boolean | false | A row of tiles under the stacks: IUPAC codes for DNA (Cavener's rules), X for a loose protein position. |
highlight | { start, end, label? }[] | Stretches marked behind the stacks. | |
tooltip | boolean | true | The hover card with each letter's share. |
selectable / selection | boolean, { start, end } | null | false | Keyboard and pointer selection. Controlled or not (defaultSelection). |
onActiveChange | (column | null) => void | The position under the pointer or cursor: bits, gaps, letters. | |
Helpers | logoCounts, logoColumns, logoConsensus, reverseComplementMatrix, detectLogoType | Counts from sequences; stacks from counts; a column's consensus; the other strand. |