Sequence Alignment
Aligned sequences as rows of residue tiles. Every ungapped stretch is one connected shape and gaps are a thin line, with a ruler, an identity bar, a consensus row, and color by residue, conservation or difference.
Install
npx shadcn@latest add @nelumbo/sequence-alignmentAn alignment
p53's L3 loop and H2 helix in six species. The rows wrap into blocks of ten columns that fit the width, each row ends with the position of its last residue, and identity puts each sequence's identity to the reference beside its name. annotations draws features as bars and single columns as markers: here, the cancer hotspots.
Conservation
colorBy="conservation" keeps color only where a residue agrees with a column at least 70% identical. The identity bar and the consensus row read the same columns; the loops that touch DNA stay solid down to fish.
Differences
colorBy="difference" compares every row with a reference, the first by default. With dots, identical residues become a dot and only the substitutions keep a tile.
Gaps
Inside a sequence a gap is a thin line that splits the row into separate shapes. Before the first residue and after the last, it is left empty. Here, the transactivation domain, which has changed far more.
DNA
Rows of A, C, G and T are read as nucleotides and take a Nucleotide scheme. TP53 codons 242 to 252, where synonymous changes in the third position stand out.
Selection
selectable turns on block selection. Drag over residues for a block, along the ruler or identity bars for whole columns, over the names for whole sequences; Shift and the arrows extend it, Ctrl+A takes everything, Escape clears. Selected residues turn solid in their own color whatever the mode, the ends show on the ruler, and copying gives the block as aligned FASTA.
>P53_HUMAN/237-250 MCNSSCMGGMNRRP >P53_MOUSE/234-247 MCNSSCMGGMNRRP >P53_RAT/235-248 MCNSSCMGGMNRRP >P53_CHICK/223-236 MCNSSCMGGMNRRP >P53_XENLA/212-225 MCNSSCMGGMNRRP >P53_DANRE/205-218 MCNSSCMGGMNRRP
Scrolling
wrap={false} keeps one row that scrolls, with the names held on the left and an overview of the whole alignment's identity on top: the ring is the visible window, drag it to move. Here the DNA-binding domain, sorted by identity to human.
Sizes and windows
size="sm" fits more columns; highlight brings forward a stretch of columns and fades the rest.
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
sequences | AlignedSequence[] | name, sequence (with - for gaps), start, id, description. | |
type | "dna" | "protein" | detected | DNA when every row is A, C, G, T, U, N and gaps. |
scheme | Nucleotide or AminoAcid scheme | "nelumbo" | The tile colors. |
colorBy | "residue" | "conservation" | "difference" | "residue" | Which residues keep their color. |
threshold | number | 0.7 | How identical a column must be to count as conserved. |
reference / dots | string | number, boolean | 0, false | The row differences are against; identical residues as a dot. |
consensus / conservation | boolean | false | A consensus row; an identity bar over each column. |
identity / sort | boolean, "input" | "identity" | false, "input" | Each sequence's identity to the reference beside its name; the closest first. |
annotations | AlignmentAnnotation[] | start, end (column numbers), label, color, description: features, or markers where start is end. | |
ruler | boolean | true | Column numbers, at each block's start and every ten. |
columnStart | number | 1 | The number of the first column, for a window of a longer alignment. |
wrap | "auto" | number | false | "auto" | Blocks of ten that fit the width, a fixed count, or one row that scrolls. |
overview | boolean | true | With wrap={false}: the identity of every column, with the visible window to drag. |
highlight | { start, end }[] | Columns to bring forward. | |
size | "sm" | "default" | "default" | 16 or 24 px columns. |
selectable | boolean | false | Keyboard focus and block selection; copying gives aligned FASTA. |
selection / onSelectionChange | { start, end, sequences } | null | Columns (in column numbers) across sequence ids. Controlled or not (defaultSelection). | |
onActiveChange | (focus | null) => void | Focus has column, sequence, letter, position, consensus, identity. | |
Helpers | alignmentConsensus, percentIdentity, alignmentSlice, toFasta | Column consensus; identity of two rows; a block as its own alignment; aligned FASTA. |