genotypst is a bioinformatics package for Typst that enables analysis and visualization of biological data. It provides functionality for parsing FASTA and Newick files and generating publication-ready visualizations, including multiple sequence alignments, sequence logos, and phylogenetic trees.
Documentation
Refer to the manual for a comprehensive guide containing examples illustrating how to use genotypst.
Quickstart
A minimal example illustrating the use of genotypst is shown below. To reproduce it, download the example multiple sequence alignment file msa.afa.
In a Typst document, import the package and read the alignment data:
#import "@preview/genotypst:0.1.0": *
// Load sequences
#let sequences = parse-fasta(read("msa.afa"))
// Display the `sequences` variable
#repr(sequences)
(
"gi|503891280": "MIQRSLRDKQIIKVLTGVRRCGKSTILQMFINFEDLAYEKYDYYELYQYL…",
"gi|502172365": "TRPRVLRRVMGAVLIDGPKAVGKTQTTTRVLRLDVDVARAALVPEQLFE-…",
"gi|504805136": "IYPRMDILPNFALVVSGIRRSGKSTLLTQFLNFDTPQLFNFEDFALLDEI…",
"gi|502700462": "----MLETDLPALLIVGPRASGKTTTAARTVRLDVPAQAAAFDPDAALRN…",
…
)
A region of the multiple sequence alignment can be rendered with render-msa:
// Render a multiple sequence alignment between positions 100 and 145
#render-msa(sequences, start: 100, end: 145, colors: true, conservation: true)
The same region of the alignment can also be visualized as a sequence logo using render-sequence-logo:
// Render a sequence logo between positions 100 and 145
#render-sequence-logo(sequences, start: 100, end: 145)
You can also use genotypst to parse Newick data and visualize phylogenetic trees:
// Parse Newick data
#let tree = parse-newick(
"(('Leaf A':0.2,'Leaf B':0.1)'Internal node':0.3,'Leaf C':0.6)Root;"
)
// Render the phylogenetic tree
#render-tree(tree)