addAlignments: Add PAF alignments to a SVbyEye miropeat style plot.

View source: R/addAlignments.R

addAlignmentsR Documentation

Add PAF alignments to a SVbyEye miropeat style plot.

Description

This function takes a ggplot2 object generated using plotMiro function and adds extra PAF alignments to it stored in the 'paf.table'. This function can also be used to highlight already present alignment or to add other features such as alignment gaps reported by the paf2gaps function.

Usage

addAlignments(
  ggplot.obj = NULL,
  paf.table = NULL,
  color.by = NULL,
  color.palette = NULL,
  fill.by = NULL,
  fill.palette = NULL,
  outline.alignments = FALSE,
  linetype = "solid",
  coord.strict = TRUE,
  sync.x.coordinates = TRUE
)

Arguments

ggplot.obj

A ggplot2 object generated using plotMiro function.

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.

color.by

A name of a column present in submitted 'paf.table'.to be used to define color scheme.

color.palette

A discrete color palette defined as named character vector (elements = colors, names = discrete levels).

fill.by

A name of a column present in submitted 'paf.table'.to be used to define fill scheme.

fill.palette

Same as parameter 'color.palette'.

outline.alignments

Set to TRUE if boundaries of each alignment should be highlighted by gray outline.

linetype

One of the following types ['solid', 'dashed', 'dotted', 'dotdash', 'longdash', 'twodash'].

coord.strict

If set to TRUE PAF alignments from the 'paf.table' will be subsetted in order to be within x-axis limits of the 'ggplot.obj'.

sync.x.coordinates

If set to TRUE query coordinates will be adjusted to the limits of target coordinates. (Default : 'TRUE')

Value

A ggplot2 object.

Author(s)

David Porubsky

Examples

## Get PAF to process ##
paf.file <- system.file("extdata", "test1.paf", package = "SVbyEye")
## Read in PAF
paf.table <- readPaf(paf.file = paf.file, include.paf.tags = TRUE, restrict.paf.tags = "cg")
## Make a plot
plt <- plotMiro(paf.table = paf.table)
## Report gaps between PAF alignments
paf.gaps <- paf2gaps(paf.table = paf.table)
## Add annotation field for plotting
paf.gaps$SV <- "INS"
paf.gaps$SV[grep(paf.gaps$cg, pattern = "D", ignore.case = TRUE)] <- "DEL"
## Define color palette for plotting
color.palette <- c("DEL" = "firebrick3", "INS" = "dodgerblue3")
## Add gap position to the plot as extra PAF alignmetns
addAlignments(
    ggplot.obj = plt, paf.table = paf.gaps,
    color.by = "SV", color.palette = color.palette, linetype = "dashed"
)


daewoooo/SVbyEye documentation built on March 31, 2024, 8:58 a.m.