Learn R Programming

pedtools (version 1.1.0)

plot.ped: Plot pedigrees with genotypes

Description

This is the main function for pedigree plotting, with many options for controlling the appearance of pedigree symbols and accompanying labels. It wraps the plotting functionality in the kinship2 package.

Usage

# S3 method for ped
plot(
  x,
  marker = NULL,
  sep = "/",
  missing = "-",
  showEmpty = FALSE,
  labs = labels(x),
  title = NULL,
  col = 1,
  aff = NULL,
  carrier = NULL,
  hatched = NULL,
  shaded = NULL,
  deceased = NULL,
  starred = NULL,
  twins = NULL,
  textInside = NULL,
  textAbove = NULL,
  hints = NULL,
  fouInb = "autosomal",
  margins = c(0.6, 1, 4.1, 1),
  keep.par = FALSE,
  ...
)

# S3 method for singleton plot( x, marker = NULL, sep = "/", missing = "-", showEmpty = FALSE, labs = labels(x), title = NULL, col = 1, aff = NULL, carrier = NULL, hatched = NULL, shaded = NULL, deceased = NULL, starred = NULL, textInside = NULL, textAbove = NULL, fouInb = "autosomal", margins = c(8, 0, 0, 0), yadj = 0, ... )

as_kinship2_pedigree( x, deceased = NULL, aff = NULL, twins = NULL, hints = NULL )

# S3 method for pedList plot(x, ...)

Arguments

x

A ped() object.

marker

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.

sep

A character of length 1 separating alleles for diploid markers.

missing

The symbol (integer or character) for missing alleles.

showEmpty

A logical, indicating if empty genotypes should be included.

labs

A vector or function controlling the individual labels included in the plot. Alternative forms:

  • If labs is a vector with nonempty intersection with labels(x), these individuals will be labelled. If the vector is named, then the (non-empty) names are used instead of the ID label. (See Examples.)

  • If labs is NULL, or has nonempty intersection with labels(x), then no labels are drawn.

  • If labs is the word "num", then all individuals are numerically labelled following the internal ordering.

  • If labs is a function, it will be replaced with labs(x) and handled as above. (See Examples.)

title

The plot title. If NULL (default) or '', no title is added to the plot.

col

A vector of colours for the pedigree members, recycled if necessary. Alternatively, col can be a list assigning colours to specific members. For example if col = list(red = "a", blue = c("b", "c")) then individual "a" will be red, "b" and "c" blue, and everyone else black. By default everyone is black.

aff

A vector of labels identifying members whose plot symbols should be filled. (This is typically used in medical pedigrees to indicate affected members.)

carrier

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.)

hatched

A vector of labels identifying members whose plot symbols should be hatched.

shaded

(Deprecated) synonym of hatched

deceased

A vector of labels indicating deceased pedigree members.

starred

A vector of labels indicating pedigree members that should be marked with a star in the pedigree plot.

twins

A data frame with columns id1, id2 and code, passed on to the relation parameter of kinship2::plot.pedigree().

textInside, textAbove

Character vectors of text to be printed inside or above pedigree symbols.

hints

A list with alignment hints passed on to kinship2::align.pedigree(). Rarely necessary, but see Examples.

fouInb

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.

margins

A numeric of length 4 indicating the plot margins. For singletons only the first element (the 'bottom' margin) is used.

keep.par

A logical (default = FALSE). If TRUE, the graphical parameters are not reset after plotting, which may be useful for adding additional annotation.

Arguments passed on to kinship2::plot.pedigree(). In particular symbolsize and cex can be useful.

yadj

A tiny adjustment sometimes needed to fix the appearance of singletons.

Details

This plotting function is in essence an elaborate wrapper for kinship2::plot.pedigree().

See Also

kinship2::plot.pedigree()

Examples

Run this code
# NOT RUN {
x = nuclearPed(father = "fa", mother = "mo", child = "boy")
m = marker(x, fa = "1/1", boy = "1/2", name = "SNP")

plot(x, marker = m)

# Markers attached to `x` may be called by name
x = setMarkers(x, m)
plot(x, marker = "SNP")

# Other options
plot(x, marker = "SNP", hatched = typedMembers(x),
     starred = "fa", deceased = "mo")

# Filled symbols
plot(x, aff = males(x))

# Label only some members
plot(x, labs = c("fa", "boy"))

# Label only some members; rename the father
plot(x, labs = c(FATHER = "fa", "boy"))

# Label males only
plot(x, labs = males)

# Colours
plot(x, col = list(red = "fa", green = "boy"), hatched = "boy")

# Founder inbreeding is shown by default
founderInbreeding(x, "mo") = 0.1
plot(x)

# ... but can be suppressed
plot(x, fouInb = NULL)

# Twins
x = nuclearPed(children = c("tw1", "tw2", "tw3"))
plot(x, twins = data.frame(id1 = "tw1", id2 = "tw2", code = 1)) # MZ
plot(x, twins = data.frame(id1 = "tw1", id2 = "tw2", code = 1)) # DZ

# Triplets
plot(x, twins = data.frame(id1 = c("tw1", "tw2"),
                           id2 = c("tw2", "tw3"),
                           code = 2))

#-----------------------------
# In some cases, the plotting machinery of `kinship2` needs a hint
# (see ?kinship2::align.pedigree)

# Example with 3/4-siblings
y = nuclearPed(2)
y = addChildren(y, 3, mother = 5, nch = 1)
y = addChildren(y, 4, mother = 5, nch = 1)

plot(y) # bad

hints = list(order = 1:7, spouse = rbind(c(3,5,0), c(5,4,0)))
plot(y, hints = hints) # good

# }

Run the code above in your browser using DataLab