You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,48 @@ gcnvplot plot \
51
51
--output plot.svg
52
52
```
53
53
54
+
## Python API
55
+
56
+
`gcnvplot` can also be used from Python code, for example when generating reports. Use `TranscriptIndex` to keep the SQLite transcript database open while rendering multiple plots.
57
+
58
+
Use `render_plot_svg` when you want the SVG as a string, for example for embedding the plot directly into an HTML report or notebook:
59
+
60
+
```python
61
+
from pathlib import Path
62
+
63
+
import gcnvplot
64
+
65
+
with gcnvplot.TranscriptIndex(Path("annotations.sqlite")) as transcript_index:
66
+
svg = gcnvplot.render_plot_svg(
67
+
Path("sample.tsv"),
68
+
Path("background.tsv"),
69
+
transcript_id="NM_007294.4",
70
+
transcript_index=transcript_index,
71
+
sample_name="SAMPLE_01",
72
+
highlight="chr17:43070928-43076614",
73
+
)
74
+
```
75
+
76
+
77
+
Use `write_plot` when you just want the finished SVG saved to disk. It is a convenience wrapper around `render_plot_svg`.
78
+
79
+
```python
80
+
from pathlib import Path
81
+
82
+
import gcnvplot
83
+
84
+
with gcnvplot.TranscriptIndex(Path("annotations.sqlite")) as transcript_index:
85
+
gcnvplot.write_plot(
86
+
Path("sample.tsv"),
87
+
Path("background.tsv"),
88
+
Path("plot.svg"),
89
+
transcript_id="NM_007294.4",
90
+
transcript_index=transcript_index,
91
+
sample_name="SAMPLE_01",
92
+
highlight="chr17:43070928-43076614",
93
+
)
94
+
```
95
+
54
96
## Synthetic example
55
97
56
98
A tiny synthetic BRCA1 transcript example is available in [`examples/brca1_synthetic`](examples/brca1_synthetic). It demonstrates a highlighted multi-exon deletion, filled and open sample dots, and an uncovered-exon marker.
0 commit comments