karyoHaploid: Haploid karyogram

View source: R/karyogram.R

karyoHaploidR Documentation

Haploid karyogram

Description

Show chromosomal segments in a haploid karyogram

Usage

karyoHaploid(
  segments,
  chrom = 1:22,
  colBy = NULL,
  col = NULL,
  separate = TRUE,
  alpha = 1,
  bgcol = "gray92",
  title = NULL,
  legendTitle = NULL,
  base_size = 16
)

Arguments

segments

A data.frame (or an object coercible to data.frame) containing the segments to be shown on the karyogram. The first three columns must contain chromosome (with or without "chr" prefix), start position and stop position (in Mb). Any further columns are ignored, except possibly a column indicated by colBy.

chrom

A vector indicating which chromosomes to include.

colBy

A character vector naming the columns to be used for colouring. If NULL (default), all segments have the same colour.

col

A single fill colour for all the segments, or (if colBy is used) a named vector of colours. In the latter case, the names should include all entries in the colBy column.

separate

A logical; relevant only if the colBy column has more than one level. If FALSE, all segments are drawn in full height. This may not be optimal if segments of different colours overlap. If TRUE the levels are drawn in separate bands on the chromosomes.

alpha

A single numeric in ⁠[0,1]⁠ indicating colour transparency.

bgcol

The background colour of the chromosomes.

title

Plot title.

legendTitle

Legend title.

base_size

Font size, passed onto ggplot2::theme().

Value

The plot object is returned invisibly, so that additional ggplot layers may be added if needed.

Examples


## Not run: 
segs = data.frame(chrom = c(1,4,5,5,10,10),
                  start = c(100,50,20,80,10,50),
                  end = c(120,100,25,100,70,120),
                  IBD = c("paternal","maternal"))
cols = c(paternal = "blue", maternal = "red")

karyoHaploid(segs, col = "cyan")
karyoHaploid(segs, colBy = "IBD", col = cols)

# Note difference if `separate = FALSE`
karyoHaploid(segs, colBy = "IBD", col = cols, separate = FALSE)

# Reduce alpha to see the overlaps:
karyoHaploid(segs, colBy = "IBD", col = cols, separate = FALSE, alpha = 0.7)


## End(Not run)


ibdsim2 documentation built on Aug. 17, 2023, 5:17 p.m.