Skip to content

mavis/illustrate/scatter

class ScatterPlot

holds settings that will go into matplotlib after conversion using the mapping system

ScatterPlot.__init__()

def __init__(
    self,
    points,
    y_axis_label,
    ymax=None,
    ymin=None,
    xmin=None,
    xmax=None,
    hmarkers=None,
    height=100,
    point_radius=2,
    title='',
    yticks=None,
    colors=None,
    density=1,
    ymax_color='#FF0000',
):

Args

  • points
  • y_axis_label
  • ymax
  • ymin
  • xmin
  • xmax
  • hmarkers
  • height
  • point_radius
  • title
  • yticks
  • colors
  • density
  • ymax_color

bam_to_scatter()

pull data from a bam file to set up a scatter plot of the pileup

def bam_to_scatter(
    bam_file: str,
    chrom: str,
    start: int,
    end: int,
    density,
    strand: Optional[str] = None,
    axis_name: Optional[str] = None,
    ymax: Optional[int] = None,
    min_mapping_quality: int = 0,
    strand_determining_read: int = 2,
    ymax_color: str = '#FF0000',
) -> 'ScatterPlot':

Args

  • bam_file (str): path to the bam file
  • chrom (str): chromosome name
  • start (int): genomic start position for the plot
  • end (int): genomic end position for the plot
  • density
  • strand (Optional[str]): expected strand
  • axis_name (Optional[str]): axis name
  • ymax (Optional[int]): maximum value to plot the y axis
  • min_mapping_quality (int): minimum mapping quality for reads to be considered in the plot
  • strand_determining_read (int)
  • ymax_color (str)

Returns

  • ScatterPlot: the scatter plot representing the bam pileup

draw_scatter()

given a xmapping, draw the scatter plot svg group

def draw_scatter(
    ds: DiagramSettings,
    canvas: svgwrite.drawing.Drawing,
    plot: ScatterPlot,
    xmapping: IntervalMapping,
) -> svgwrite.container.Group:

Args

  • ds (DiagramSettings): the settings/constants to use for building the svg
  • canvas (svgwrite.drawing.Drawing): the svgwrite object used to create new svg elements
  • plot (ScatterPlot): the plot to be drawn
  • xmapping (IntervalMapping): dict used for conversion of coordinates in the xaxis to pixel positions

Returns

  • svgwrite.container.Group