Skip to content

GC() ​

A gene cluster chart.

Build a chart from a data frame of genes, one row per gene, then add components with the methods. Each method returns a new chart. to_spec() gives the chart spec that the geneviewer JavaScript library draws.

Usage ​

python
from geneviewer import GC

GC(data, start, end, cluster, group, strand, width, height, style, save_button)

An argument shown without a default is optional too: left out, the chart keeps its default.

Arguments ​

ArgumentTypeDescription
datapandas.DataFrame or str or path-likeThe genes: one row per gene, with its start and end positions. Or a GenBank file, or a folder of them: their CDS are the genes, one cluster per file, with cluster and strand set to the columns of those names.
startstrColumn of start positions. Default "start".
endstrColumn of end positions. Default "end".
clusterstr, optionalColumn of cluster names: one chart row per cluster.
groupstr, optionalColumn of groups, which set the gene colours and the legend.
strandstr, optionalColumn of strands: 1, "forward", "sense" or "+" for the forward strand, and -1, 0, "reverse", "antisense", "complement" or "-" for the reverse strand. Default: from the order of start and end.
widthstr or floatWidth of the chart, e.g. "100%" or 500. Default "100%".
heightstr or floatHeight of the chart, e.g. "400px" or 300. Default "400px".
styledictCSS styles of the chart container, e.g. {"backgroundColor": "white"}.
save_buttonboolWhether the toolbar has the button to save the chart as SVG or PNG. Default True.

Examples ​

python
>>> import pandas as pd
>>> genes = pd.DataFrame({
...     "start": [10, 90, 130], "end": [40, 120, 160],
...     "name": ["a", "b", "c"], "group": ["A", "B", "A"],
... })
>>> chart = GC(genes, group="group", height="200px").labels("name")
>>> chart.to_spec()["labels"]
{'label': 'name'}