Settings and properties
- canvas_width
- set_canvas_width
- canvas_height
- set_canvas_height
- canvas_size
- set_canvas_size
- theme
- set_theme
- set_paint_ARBG
- apply_theme
- load_theme_from_json
- save_theme_to_json
- font_size
- set_font_size
- font_name
- set_font_name
- set_image_number
- __ array_interface __
- Configuration Properties
canvas_width
canvas_width -> int
Property that returns the current canvas width in pixels.
Returns:
int
: Current canvas width
Example:
# Get current canvas width
width = gw.canvas_width
print(f"Canvas width: {width}px")
set_canvas_width
set_canvas_width(width: int) -> 'Gw'
Set the canvas width and recreate the raster surface.
Parameters:
width
(int): New canvas width in pixels
Returns:
Gw
: Self for method chaining
canvas_height
canvas_height -> int
Property that returns the current canvas height in pixels.
Returns:
int
: Current canvas height
Example:
# Get current canvas height
height = gw.canvas_height
print(f"Canvas height: {height}px")
set_canvas_height
set_canvas_height(height: int) -> 'Gw'
Set the canvas height and recreate the raster surface.
Parameters:
height
(int): New canvas height in pixels
Returns:
Gw
: Self for method chaining
canvas_size
canvas_size -> Tuple[int, int]
Property that returns the current canvas dimensions.
Returns:
tuple
: (width, height) in pixels
Example:
# Get current canvas dimensions
width, height = gw.canvas_size
print(f"Canvas dimensions: {width}x{height}px")
set_canvas_size
set_canvas_size(width: int, height: int) -> 'Gw'
Set both canvas width and height and recreate the raster surface.
Parameters:
width
(int): New canvas width in pixelsheight
(int): New canvas height in pixels
Returns:
Gw
: Self for method chaining
theme
theme -> str
Property that returns the current theme name.
Returns:
str
: Current theme name (“slate”, “dark”, or “igv”)
Example:
# Get current theme
theme = gw.theme
print(f"Current theme: {theme}")
set_theme
set_theme(theme_name: str) -> 'Gw'
Set a predefined visualisation theme.
Parameters:
theme_name
(str): Theme name, must be one of “slate”, “dark”, or “igv”
Returns:
Gw
: Self for method chaining
Raises:
ValueError
: If theme_name is not one of the supported themes
Example:
# Set the dark theme
gw.set_theme("dark")
set_paint_ARBG
set_paint_ARBG(paint_enum: int, a: int, r: int, g: int, b: int) -> 'Gw'
Set the ARGB color for a specific paint type.
Parameters:
paint_enum
(int): Paint type enumeration value from GwPalette enum or Paint class (e.g., GwPalette.NORMAL_READ, GwPalette.DELETION)a
(int): Alpha channel value (0-255)r
(int): Red channel value (0-255)g
(int): Green channel value (0-255)b
(int): Blue channel value (0-255)
Returns:
Gw
: Self for method chaining
Example:
# Set normal read color to dark blue
gw.set_paint_ARBG(GwPalette.NORMAL_READ, 255, 0, 0, 128)
apply_theme
apply_theme(theme_dict: Dict[int, Tuple[int, int, int, int]]) -> 'Gw'
Apply a custom theme using a dictionary of paint types and colors.
Parameters:
theme_dict
(dict): Dictionary mapping Paint constants to ARGB tuples (alpha, red, green, blue)
Returns:
Gw
: Self for method chaining
Example:
custom_theme = {
GwPalette.BACKGROUND: (255, 240, 240, 240),
GwPalette.NORMAL_READ: (255, 100, 100, 100),
GwPalette.DELETION: (255, 255, 0, 0)
}
gw.apply_theme(custom_theme)
load_theme_from_json
load_theme_from_json(filepath: str) -> 'Gw'
Load and apply a theme from a JSON file.
Parameters:
filepath
(str): Path to the JSON theme file
Returns:
Gw
: Self for method chaining
Raises:
ValueError
: If the color name is not recognised
Example:
gw.load_theme_from_json("custom_theme.json")
save_theme_to_json
save_theme_to_json(filepath: str) -> 'Gw'
Save the current theme settings to a JSON file.
This function exports all paint colors from the current theme to a JSON file that can later be loaded with load_theme_from_json.
Parameters:
filepath
(str): Path where the JSON theme file should be saved
Returns:
Gw
: Self for method chaining
Example:
# Save the current theme for future use
gw.save_theme_to_json("my_theme.json")
font_size
font_size -> int
Property that returns the current font size.
Returns:
int
: Current font size
Example:
# Get current font size
size = gw.font_size
print(f"Current font size: {size}")
set_font_size
set_font_size(size: int) -> 'Gw'
Set the font size.
Parameters:
size
(int): Sets the font size
Returns:
Gw
: Self for method chaining
font_name
font_name -> str
Property that returns the current font name.
Returns:
str
: Current font name
Example:
# Get current font name
font = gw.font_name
print(f"Current font: {font}")
set_font_name
set_font_name(name: str) -> 'Gw'
Set the font name.
Parameters:
name
(str): Sets the font name
Returns:
Gw
: Self for method chaining
set_image_number
set_image_number(x: int, y: int) -> 'Gw'
Set the grid dimensions for image view when using tiled display.
Parameters:
x
(int): Number of columns in the gridy
(int): Number of rows in the grid
Returns:
Gw
: Self for method chaining
Example:
# Set up a 2x3 grid layout
gw.set_image_number(2, 3)
__ array_interface __
The Gw
object implements the NumPy array interface protocol, allowing it to be directly converted to a NumPy array without copying the underlying data.
Returns:
dict
orNone
: Describes the underlying image buffer if the raster surface exists, otherwise None
Example:
import numpy as np
# Convert to numpy array with zero-copy
gw.draw() # Ensure the image is rendered
arr = np.asarray(gw) # Uses __array_interface__ automatically
Configuration Properties
gwplot
provides numerous properties that can be accessed or modified to configure the visualisation:
Thread and Memory Settings
threads
/set_threads(num: int) -> 'Gw'
: Get/set the number of processing threadslow_memory
/set_low_memory(size: int) -> 'Gw'
: Get/set low memory mode threshold in base-pairs
Visualisation Parameters
indel_length
/set_indel_length(length: int) -> 'Gw'
: Get/set indel length threshold for labelingylim
/set_ylim(limit: int) -> 'Gw'
: Get/set the y-axis limitsplit_view_size
/set_split_view_size(size: int) -> 'Gw'
: Get/set the split view sizepad
/set_pad(padding: int) -> 'Gw'
: Get/set the padding between elementsmax_coverage
/set_max_coverage(coverage: int) -> 'Gw'
: Get/set maximum coverage valuemax_tlen
/set_max_tlen(length: int) -> 'Gw'
: Get/set maximum template lengthlog2_cov
/set_log2_cov(enabled: bool) -> 'Gw'
: Get/set log2 coverage displaytlen_yscale
/set_tlen_yscale(scale: bool) -> 'Gw'
: Get/set template length y-scaleexpand_tracks
/set_expand_tracks(expand: bool) -> 'Gw'
: Get/set track expansionvcf_as_tracks
/set_vcf_as_tracks(as_tracks: bool) -> 'Gw'
: Get/set VCF display as trackssv_arcs
/set_sv_arcs(arcs: bool) -> 'Gw'
: Get/set structural variant arcs displayscroll_speed
/set_scroll_speed(speed: float) -> 'Gw'
: Get/set the scroll speedtab_track_height
/set_tab_track_height(height: float) -> 'Gw'
: Get/set track tab heightstart_index
/set_start_index(index: int) -> 'Gw'
: Get/set coordinate start index (0 or 1)soft_clip_threshold
/set_soft_clip_threshold(threshold: int) -> 'Gw'
: Get/set soft clip thresholdsmall_indel_threshold
/set_small_indel_threshold(threshold: int) -> 'Gw'
: Get/set small indel thresholdsnp_threshold
/set_snp_threshold(threshold: int) -> 'Gw'
: Get/set SNP thresholdvariant_distance
/set_variant_distance(distance: int) -> 'Gw'
: Get/set variant distance threshold