plotPolarized {diemr}R Documentation

Plot Polarized Genotypes

Description

Plots genotypes that can be optionally polarized.

Usage

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

Arguments

genotypes

character matrix comprising of _012 encodings.

HI

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

cols

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.

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 = "")

[Package diemr version 1.4 Index]