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
| Argument | Type | Description |
|---|---|---|
data | pandas.DataFrame or str or path-like | The 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. |
start | str | Column of start positions. Default "start". |
end | str | Column of end positions. Default "end". |
cluster | str, optional | Column of cluster names: one chart row per cluster. |
group | str, optional | Column of groups, which set the gene colours and the legend. |
strand | str, optional | Column 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. |
width | str or float | Width of the chart, e.g. "100%" or 500. Default "100%". |
height | str or float | Height of the chart, e.g. "400px" or 300. Default "400px". |
style | dict | CSS styles of the chart container, e.g. {"backgroundColor": "white"}. |
save_button | bool | Whether 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'}