Skip to content

mavis/illustrate/elements

This is the primary module responsible for generating svg visualizations

HEX_WHITE

HEX_WHITE = '#FFFFFF'

HEX_BLACK

HEX_BLACK = '#000000'

draw_legend()

generates an svg group object representing the legend

def draw_legend(
    config: DiagramSettings, canvas, swatches: List[Tuple[str, str]], border: bool = True
) -> svgwrite.container.Group:

Args

  • config (DiagramSettings)
  • canvas
  • swatches (List[Tuple[str, str]])
  • border (bool)

Returns

  • svgwrite.container.Group

draw_ustranscript()

builds an svg group representing the transcript. Exons are drawn in a track with the splicing information and domains are drawn in separate tracks below

if there are multiple splicing variants then multiple exon tracks are drawn

def draw_ustranscript(
    config: DiagramSettings,
    canvas: svgwrite.drawing.Drawing,
    pre_transcript,
    target_width: Optional[int] = None,
    breakpoints: List['Breakpoint'] = [],
    labels=LabelMapping(),
    colors={},
    mapping=None,
    masks=None,
    reference_genome=None,
) -> svgwrite.container.Group:

Args

  • config (DiagramSettings)
  • canvas (svgwrite.drawing.Drawing): the main svgwrite object used to create new svg elements
  • pre_transcript (Transcript): the transcript being drawn
  • target_width (Optional[int]): the target width of the diagram
  • breakpoints (List[Breakpoint]): the breakpoints to overlay
  • labels
  • colors
  • mapping
  • masks
  • reference_genome

Returns

  • svgwrite.container.Group

draw_genes()

draws the genes given in order of their start position trying to minimize the number of tracks required to avoid overlap

def draw_genes(
    config: DiagramSettings,
    canvas: svgwrite.drawing.Drawing,
    genes: List['Gene'],
    target_width: int,
    breakpoints: Optional[List[Breakpoint]] = None,
    colors: Optional[Dict[str, 'Gene']] = None,
    labels: Optional[LabelMapping] = None,
    plots: Optional[List] = None,
    masks: Optional[List[Interval]] = None,
) -> svgwrite.container.Group:

Args

  • config (DiagramSettings)
  • canvas (svgwrite.drawing.Drawing): the main svgwrite object used to create new svg elements
  • genes (List[Gene]): the list of genes to draw
  • target_width (int): the target width of the diagram
  • breakpoints (Optional[List[Breakpoint]]): the breakpoints to overlay
  • colors (Optional[Dict[str, Gene]]): dictionary of the colors assigned to each Gene as fill
  • labels (Optional[LabelMapping])
  • plots (Optional[List])
  • masks (Optional[List[Interval]])

Returns

  • svgwrite.container.Group

draw_exon()

generates the svg object representing an exon

def draw_exon(
    config: DiagramSettings,
    canvas: svgwrite.drawing.Drawing,
    exon: 'Exon',
    width: int,
    height: int,
    fill: str,
    label: str = '',
    translation=None,
) -> svgwrite.container.Group:

Args

  • config (DiagramSettings)
  • canvas (svgwrite.drawing.Drawing): the main svgwrite object used to create new svg elements
  • exon (Exon): the exon to draw
  • width (int): the pixel width
  • height (int): the pixel height
  • fill (str): the fill color to use for the exon
  • label (str)
  • translation

Returns

  • svgwrite.container.Group

Todo

add markers for exons with abrogated splice sites

draw_template()

Creates the template/chromosome illustration

Return: the group element for the diagram

def draw_template(
    config: DiagramSettings,
    canvas: svgwrite.drawing.Drawing,
    template,
    target_width,
    labels=None,
    colors=None,
    breakpoints=None,
) -> svgwrite.container.Group:

Args

  • config (DiagramSettings)
  • canvas (svgwrite.drawing.Drawing)
  • template
  • target_width
  • labels
  • colors
  • breakpoints

Returns

  • svgwrite.container.Group

draw_gene()

generates the svg object representing a gene

def draw_gene(
    config: DiagramSettings,
    canvas: svgwrite.drawing.Drawing,
    gene: 'Gene',
    width: int,
    height: int,
    fill: str,
    label: str = '',
) -> svgwrite.container.Group:

Args

  • config (DiagramSettings)
  • canvas (svgwrite.drawing.Drawing): the main svgwrite object used to create new svg elements
  • gene (Gene): the gene to draw
  • width (int): the pixel width
  • height (int): the pixel height
  • fill (str): the fill color to use for the gene
  • label (str)

Returns

  • svgwrite.container.Group