plotSelf: Make a horizontal sequence self-alignments.

View source: R/plotSelf.R

plotSelfR Documentation

Make a horizontal sequence self-alignments.

Description

This function takes self-alignment coordinates generated by 'minimap2' aligner and visualize them either as horizontal 'dotplot' or arcs.

Usage

plotSelf(
  paf.table = NULL,
  min.deletion.size = NULL,
  min.insertion.size = NULL,
  highlight.sv = NULL,
  binsize = NULL,
  shape = "segment",
  sort.by = "position",
  color.by = "direction",
  color.palette = NULL,
  add.alignment.arrows = TRUE,
  highlight.pos = NULL,
  highlight.region = NULL
)

Arguments

paf.table

A data.frame or tibble containing a single or multiple PAF record(s) with 12 mandatory columns along with CIGAR string defined in 'cg' column.

min.deletion.size

A minimum size (in base pairs) of a deletion to be retained.

min.insertion.size

A minimum size (in base pairs) of an insertion to be retained.

highlight.sv

Visualize alignment embedded structural variation either as an outlined ('outline') or filled ('fill') miropeats.

binsize

A size of a bin in base pairs to split a PAF alignment into.

shape

A shape used to plot aligned sequences: Either 'segment', 'arc' or 'arrow'.

sort.by

Order PAF alignments by relative left-most coordinates ('position') or by the alignment length ('length').

color.by

Color alignments either by directionality ('direction'), fraction of matched base pairs ('identity'), or a custom column name present in submitted 'paf.table'.

color.palette

A discrete color palette defined as named character vector (elements = colors, names = discrete levels) to color alignment directionality, ‘[default: color.palette <- c(’-' = 'cornflowerblue', '+' = 'forestgreen')]'.

add.alignment.arrows

Set to FALSE if alignment arrows should not be added to the plot.

highlight.pos

A single or a set of positions to be highlighted as vertical solid lines.

highlight.region

A pair of positions to be highlighted as vertical range.

Value

A ggplot2 object.

Author(s)

David Porubsky

Examples

## Get PAF to plot
paf.file <- system.file("extdata", "test2.paf", package = "SVbyEye")
## Read in PAF
paf.table <- readPaf(paf.file = paf.file, include.paf.tags = TRUE, restrict.paf.tags = "cg")
## Make a plot
## Plot alignment as horizontal dotplots and color by alignment directionality
plotSelf(paf.table = paf.table, color.by = "direction", shape = "segment")
## Plot alignment as arcs and color by alignment directionality
plotSelf(paf.table = paf.table, color.by = "direction", shape = "arc")
## Plot alignment as arrows and color by alignment directionality
plotSelf(paf.table = paf.table, color.by = "direction", shape = "arrow")
## Highlight structural variants within self-alignments
plotSelf(
    paf.table = paf.table, min.deletion.size = 50, min.insertion.size = 50,
    highlight.sv = "outline"
)
## Highlight structural variants using arc shapes
plotSelf(
    paf.table = paf.table, min.deletion.size = 50, min.insertion.size = 50,
    highlight.sv = "outline", shape = "arc"
)
## Highlight structural variants within arrow shapes
plotSelf(
    paf.table = paf.table, min.deletion.size = 50, min.insertion.size = 50,
    highlight.sv = "outline", shape = "arrow"
)
## Bin PAF alignments into user defined bin and color them by sequence identity (% of matched bases)
plotSelf(paf.table = paf.table, binsize = 1000)
plotSelf(paf.table = paf.table, binsize = 1000, shape = "arc")
## Add annotation to self-alignments ##
annot.file <- system.file("extdata", "test2.sd.annot.RData", package = "SVbyEye")
annot.gr <- get(load(annot.file))
plt <- plotSelf(paf.table = paf.table, color.by = "direction", shape = "arc")
## Add annotation to a new level
addAnnotation(ggplot.obj = plt, annot.gr = annot.gr, coordinate.space = "self")
## Add annotation to the alignment level
plt <- plotSelf(
    paf.table = paf.table, color.by = "direction", shape = "arc",
    add.alignment.arrows = FALSE
)
addAnnotation(
    ggplot.obj = plt, annot.gr = annot.gr, coordinate.space = "self",
    annotation.level = 0
)


daewoooo/SVbyEye documentation built on Oct. 15, 2024, 6:12 a.m.