The main purpose of this page is to document the many options for pedigree
plotting. Most of the arguments shown here may be supplied directly in
plot(x, ...)
, where x
is a pedigree. See plot.ped()
for many examples.
.pedAlignment(
x = NULL,
plist = NULL,
arrows = FALSE,
twins = NULL,
miscarriage = NULL,
packed = TRUE,
width = 10,
align = c(1.5, 2),
spouseOrder = NULL,
hints = NULL,
...
).pedAnnotation(
x,
title = NULL,
marker = NULL,
sep = "/",
missing = "-",
showEmpty = FALSE,
labs = labels(x),
foldLabs = 12,
trimLabs = TRUE,
col = 1,
fill = NA,
lty = 1,
lwd = 1,
hatched = NULL,
hatchDensity = 25,
aff = NULL,
carrier = NULL,
deceased = NULL,
starred = NULL,
textAnnot = NULL,
textInside = NULL,
textAbove = NULL,
fouInb = "autosomal",
...
)
.pedScaling(
alignment,
annotation,
cex = 1,
symbolsize = 1,
margins = 1,
addSpace = 0,
xlim = NULL,
ylim = NULL,
vsep2 = FALSE,
autoScale = FALSE,
minsize = 0.15,
...
)
.drawPed(alignment, annotation, scaling)
.annotatePed(
alignment,
annotation,
scaling,
font = NULL,
fam = NULL,
col = NULL,
colUnder = 1,
colInside = 1,
colAbove = 1,
cex.main = NULL,
font.main = NULL,
col.main = NULL,
line.main = NA,
...
)
A ped()
object.
Alignment list with format similar to
kinship2::align.pedigree()
.
A logical (default = FALSE). If TRUE, the pedigree is plotted as a DAG, i.e., with arrows connecting parent-child pairs.
A data frame with columns id1
, id2
and code
, passed on to
the relation
parameter of kinship2::plot.pedigree()
.
A vector of labels indicating miscarriages, shown as triangles in the pedigree plot.
Parameters passed on to
kinship2::align.pedigree()
. Can usually be left untouched.
An optional vector (or list of vectors) indicating plot
ordering for spouses. (This is converted into a matrix and forward as
hints
; see below.)
An optional list of hints passed on to
kinship2::align.pedigree()
.
Further parameters passed between methods.
The plot title. If NULL (default) or '', no title is added to the plot.
Either a vector of names or indices referring to markers
attached to x
, a marker
object, or a list of such. The genotypes for
the chosen markers are written below each individual in the pedigree, in
the format determined by sep
and missing
. See also showEmpty
. If NULL
(the default), no genotypes are plotted.
A character of length 1 separating alleles for diploid markers.
The symbol (integer or character) for missing alleles.
A logical, indicating if empty genotypes should be included.
A vector or function controlling the individual labels in the
plot. By default, labels(x)
are used. See Details for valid formats.
A number or function controlling the folding of long labels. If a number, line breaks are inserted at roughly this width, trying to break at break-friendly characters. If a function, this is applied to each label.
A logical, by default TRUE. Removes line breaks and tabs from
both ends of the labels (after adding genotypes, if marker
is not NULL).
A vector or list specifying outline colours for the pedigree members. See Details for valid formats.
A vector or list specifying fill/hatch colours for the pedigree
members. See Details for valid formats. Note that if fill
is unnamed, and
either aff
or hatched
are given, then the fill colour is applied only
to those.
Vectors or lists specifying linetype and width of pedigree symbol outlines. See Details for valid formats.
A vector of labels identifying members whose plot symbols should be hatched.
A number specifying the hatch density in lines per inch. Default: 25.
A vector of labels identifying members whose plot symbols should be filled. (This is typically used in medical pedigrees to indicate affected members.)
A vector of labels identifying members whose plot symbols should be marked with a dot. (This is typically used in medical pedigrees to indicate unaffected carriers of the disease allele.)
A vector of labels indicating deceased pedigree members.
A vector of labels indicating pedigree members that should be marked with a star in the pedigree plot.
A list specifying further text annotation around or inside the pedigree symbols. See Details for more information.
Character vectors of text to be printed inside or
above pedigree symbols. [Soft deprecated; replaced by textAnnot
.]
Either "autosomal" (default), "x" or NULL. If "autosomal" or "x", inbreeding coefficients are added to the plot above the inbred founders. If NULL, or if no founders are inbred, nothing is added.
List of alignment details, as returned by .pedAlignment()
.
List of annotation details as returned by
.pedAnnotation()
.
Expansion factor controlling font size. This also affects symbol sizes, which by default have the width of 2.5 characters. Default: 1.
Expansion factor for pedigree symbols. Default: 1.
A numeric indicating the plot margins. If a single number is given, it is recycled to length 4.
A numeric of length 4, indicating extra padding (in inches) around the pedigree inside the plot region. Default: 0.
Numeric vectors of length 2, used to set par("usr")
explicitly. Rarely needed by end users.
A logical; for internal use.
A logical. It TRUE, an attempt is made to adjust cex
so
that the symbol dimensions are at least minsize
inches. Default: FALSE.
A positive number, by default 0.15. (See autoScale
.)
List of scaling parameters as returned by .pedScaling()
.
Arguments passed on to text()
.
Colour vectors.
Parameters passed on to
title()
.
The workflow of plot.ped(x, ...)
is approximately as follows:
# Calculate plot parameters
align = .pedAlignment(x, ...)
annot = .pedAnnotation(x, ...)
scale = .pedScaling(align, annot, ...)# Produce plot
.drawPed(align, annot, scale)
.annotatePed(align, annot, scale) # if `annot` contains text annotation etc
The labs
argument control the individual ID labels printed below the
pedigree symbols. By default the output of labels(x)
is used, but there are
several alternative forms:
If labs
is a vector with nonempty intersection with labels(x)
, only
these individuals will be labelled. If the vector is named, then the names
are used instead of the ID label. (See Examples.)
If labs
is the word "num", then all individuals are numerically
labelled following the internal ordering.
Use labs = NULL
to remove all labels.
If labs
is a function, it is replaced with labs(x)
and handled as
above. (See Examples.)
The argument textAnnot
allows customised annotation around and inside each
symbol. This takes a list of lists, whose names may include "topleft",
"topright", "left", "right", "bottomleft", "bottom", "bottomright" and
"inside". Each inner list should contain a character vector as its first
element (with the text to printed), followed by further arguments passed to
text()
. For example, textAnnot = list(left = list(c(A = "1"), cex = 2))
prints a large number "1" to the left of individual A (if such an individual
exists in the pedigree. See Examples.
The arguments col
, fill
, lty
and lwd
can all be indicated in a number
of ways:
An unnamed vector. This will be recycled and applied to all members. For
example, lty = 2
gives everyone a dashed outline.
A named vector. Only pedigree members appearing in the names are affected.
Example: fill = c("1" = "red", foo = "blue")
fills individual 1
red and
foo
blue.
A list of ID vectors, where the list names indicate the parameter values.
Example: col = list(red = 1:2, blue = 3:5)
.
List entries may also be functions, taking the pedigree x
as input and
producing a vector of ID labels. The many built-in functions in
ped_subgroups are particularly handy here, e.g.: fill = list(red = founders, blue = leaves)
.
x = nuclearPed()
align = .pedAlignment(x)
annot = .pedAnnotation(x)
scale = .pedScaling(align, annot)
drawPed(align, annot, scale)
Run the code above in your browser using DataLab