plotMarkerAxis: Add a Marker Axis with Chromosome Names to a Plot of...

View source: R/plotMarkerAxis.r

plotMarkerAxisR Documentation

Add a Marker Axis with Chromosome Names to a Plot of Polarized Genotypes

Description

This function adds a marker axis with chromosome names to an existing plot of polarized genotypes. It requires that the plot is already created using plotPolarized.

Usage

plotMarkerAxis(
  includedSites,
  ChosenSites = "all",
  tickDist = 1e+06,
  axisInfo = NULL,
  ...
)

Arguments

includedSites

A character path to a file with columns CHROM and POS.

ChosenSites

A logical vector indicating which sites are to be included in the analysis.

tickDist

A numeric indicating the spacing of physical tick marks along a chromosome.

axisInfo

A list with user-defined tick positions and labels for marker axis. See Details.

...

additional arguments.

Details

Either axisInfo or includedSites must be provided. If axisInfo = NULL, the function extracts the necessary information from the includedSites file. The includedSites file should ideally be generated by vcf2diem to ensure congruence between the plotted genotypes and the respective metadata.

Tick mark distances within a chromosome are spaced at intervals of tickDist (in bp) and formatted to multiples of millions.

The positions in axisInfo (e.g., ticksPos, CHROMbreaks, CHROMnamesPos) are in units of marker index (i.e. column positions in the genotype matrix used in the previous plotPolarized call).

The optional axisInfo argument must be a list with five named elements:

  • CHROMbreaks: Numeric vector of positions defining ticks that separate chromosomes.

  • CHROMnamesPos: Numeric vector of label positions for chromosome names.

  • CHROMnames: Character vector of chromosome names (same length as CHROMnamesPos).

  • ticksPos: Numeric vector with tick positions within chromosomes.

  • ticksNames: Character vector of labels corresponding to ticksPos. Potentially overlapping labels are automatically replaced with "".

The ... arguments accept additional graphical parameters passed to either axis(), mtext(), or circos.*() functions, depending on plot type. The following arguments are supported:

Rectangular axis arguments: side, col.ticks, labels, las, tick, line, tcl, cex, cex.axis, pos, outer, font, lty, lwd, lwd.ticks, hadj, padj, gap.axis, xpd.

Circular axis arguments (used in iris/circular plots): major.tick.length, lwd, labels.cex, cex, niceFacing, labels.niceFacing, facing, labels.facing, track.height, adj.

In rectangular plots, chromosome names are drawn using mtext(), with size scaled by cex * 1.1. Tick labels for positions use the same cex.

In circular plots (types "iris" or "circular"), tick positions and chromosome names are drawn using circos.axis() and circos.text(), respectively. Their sizes are controlled separately:

  • labels.cex controls the size of tick position numbers,

  • cex controls the size of chromosome name labels.

Similarly, text facing is controlled independently:

  • labels.niceFacing affects the tick labels,

  • niceFacing affects chromosome names.

The default alignment for chromosome names is set by adj = c(1, 0.5), meaning right-aligned and vertically centered.

To optimize the marker axis format in iris plots, it is recommended to test with only one sample plotted to save processing time.

Value

Returns an invisible axisInfo list with the tick positions and labels for the marker axis.

See Also

plotPolarized to generate the base plot.

Examples

## Not run: 
# Run this example in a working directory with write permissions
myo <- system.file("extdata", "myotis.vcf", package = "diemr")
vcf2diem(myo, "myo")
inds <- 1:14
fit <- diem("myo-001.txt", ChosenInds = inds, ploidy = FALSE)
gen <- importPolarized("myo-001.txt", fit$markerPolarity, inds)
h <- apply(gen, 1, function(x) pHetErrOnStateCount(sStateCount(x)))[1, ]
plotPolarized(gen, h, xlab = "")
plotMarkerAxis("myo-includedSites.txt", tickDist = 100)

plotPolarized(gen, h, type = "iris")
plotMarkerAxis("myo-includedSites.txt", tickDist = 100)

## End(Not run)

diemr documentation built on Dec. 11, 2025, 5:07 p.m.