plotPolarized: Plot Polarized Genotypes

View source: R/plotPolarized.r

plotPolarizedR Documentation

Plot Polarized Genotypes

Description

Plots genotypes that can be optionally polarized.

Usage

plotPolarized(
  genotypes,
  HI,
  cols = c("#FFFFFF", "#800080", "#FFE500", "#008080"),
  ...
)

Arguments

genotypes

A character matrix comprising of _012 encodings.

HI

A numeric vector of individual hybrid indices with length equal to number of rows in genotypes.

cols

A vector of four colors, representing missing data, homozygotes for genotype 0, heterozygotes and homozygotes for genotype 2.

...

Additional selected arguments passed to image and axis.

Details

To import and polarize genotypes, use the importPolarized function.

When using diem, hybrid indices, HI, can be found in the file 'HIwithOptimalPolarities.txt'. Alternatively, calculate HI from the polarized genotypes as shown in the examples.

By default, the function plots colored tick marks for individuals, changing the color at the steepest change in sorted HI. The second and fourth colors in cols are used for the tick marks.

  • To turn off this feature, use the argument tick = FALSE.

  • To use custom tick mark colors, provide a vector of colors for all individuals (equal to the number of rows in genotypes). The vector of colors must be ordered according to order(HI).

  • To include individual labels (e.g., accession numbers), provide a character vector with the names in the same order as they are in the genotypes.

Value

No return value, called for side effects. In the default plot, purple and green represent sides of the barrier to gene flow encoded as 0 and 2, respectively, yellow shows heterozygotes and white represents missing or undetermined genotypes. Individuals are ordered according to the sorted HI.

See Also

plotMarkerAxis to add chromosome information to the x axis.

Examples

gen <- importPolarized(
  file = system.file("extdata", "data7x10.txt", package = "diemr"),
  changePolarity = c(TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE),
  ChosenInds = 1:7
)

h <- apply(gen, 1, FUN = function(x) pHetErrOnStateCount(sStateCount(x)))[1, ]

plotPolarized(genotypes = gen, HI = h)

# Incorrect tick color order
plotPolarized(gen, h, col.ticks = c(rep("purple", 5), "green", "purple"), lwd = 3)

# Correct tick color order
plotPolarized(gen, h, col.ticks = c(rep("purple", 5), "green", "purple")[order(h)], lwd = 3)

# Correct individual label order 
plotPolarized(gen, h, labels = c(paste("purple", 1:5), "green 1", "purple 6"), ylab = "")

diemr documentation built on Sept. 23, 2024, 5:10 p.m.