Learn R Programming

wpeR (version 0.1.0)

plot_table: Prepares pedigree data for plotting and spatial representation

Description

Combines extended pedigree (obtained by org_fams() function) and sample metadata data for visual (ped_satplot()) and spatial (ped_spatial()) representation of the pedigree.

Usage

plot_table(
  plot_fams = "all",
  all_fams,
  ped,
  sampledata,
  datacolumns = c("Sample", "AnimalRef", "GeneticSex", "Date", "SType", "lat", "lng",
    "FirstSeen", "LastSeen", "IsDead"),
  deadSample = c("Tissue")
)

Value

Extended sampledata data frame that includes all columns defined in datacolumns

parameter and adds information needed for visual and spatial representation of pedigree:

  • plottingID: Numeric. Identifier number for temporal pedigree plot ped_satplot(). In case of polygamous animals same individual can be included in more than one family.

  • FamID: Numeric. Identifier number of family that individual belongs to.

  • hsGroup: Numeric. Identifier number for the half-sib group of individual.

  • rep: Logical. Is individual reproductive in current family, (current family defined with FamID for a particular entry).

  • later_rep: Logical. Is individual reproductive in any other (later) families.

  • isPolygamous: Logical. Does the individual have more than one mate.

  • dead: Logical. Is individual dead.

  • first_sample: Logical. Is this particular sample the first sample of the individual.

  • last_sample: Logical. Is this particular sample the last sample of the individual.

  • isReference: Logical. Is this particular sample reference sample of individual.

Arguments

plot_fams

Character string or numeric vector. FamID numbers from fams data generated by org_fams() function. If all families want to be plotted it is defined as character string "all". For a subset of families a numeric vector of FamIDs has to be specified. Defaults to "all".

all_fams

Data frame. Family (fams) data generated by org_fams() function.

ped

Data frame. Organized pedigree (ped) generated by org_fams() function.

sampledata

Data frame. Metadata for all genetic samples that belong to the individuals included in pedigree reconstruction analysis. For description of sampledata structure and sample information needed for plot_table() see Details.

datacolumns

Vector of column names included sampledata that are needed to produce this functions output (see Details).

deadSample

Single value or vector of different lethal sample types. Defaults to c("Tissue").

Details

  • sampledata has to include columns that contain information on:

    • unique identifier of each sample; character or numeric (default column name = Sample, see check_sampledata() function),

    • date of sample collection in Date format (default = Date),

    • assignment of sample to particular individual; character or numeric (default = AnimalRef, see check_sampledata() function),

    • sex of the animal coded as F, M or NA; character (default = GeneticSex, see check_sampledata() function),

    • longitude and latitude coordinates of sample collection location; numeric (default = lng and lat, see check_sampledata() function),

    • type of particular sample eg. scat, tissue, saliva; character (default = SType, see check_sampledata() function),

    • date of first and last sample of individual in Date format (default = FirstSeen and LastSeen, see anim_timespan() function),

    • value identifying if if the individual is dead; logical (default = IsDead, see anim_timespan() function).

Examples

Run this code

# Prepare the data for usage with plot_table() function.
# Get animal timespan data using the anim_timespan() function.
animal_ts <- anim_timespan(wolf_samples$AnimalRef,
  wolf_samples$Date,
  wolf_samples$SType,
  dead = c("Tissue")
)
# Add animal timespan to the sampledata
sampledata <- merge(wolf_samples, animal_ts, by.x = "AnimalRef", by.y = "ID", all.x = TRUE)
# Define the path to the pedigree data file.
path <- paste0(system.file("extdata", package = "wpeR"), "/wpeR_samplePed")
# Retrieve the pedigree data from the get_colony function.
ped_colony <- get_colony(path, sampledata, rm_obsolete_parents = TRUE, out = "FamAgg")
# Organize families and expand pedigree data using the org_fams function.
org_tables <- org_fams(ped_colony, sampledata, output = "both")

# Run the function
# Prepare data for plotting.
plot_table(plot_fams = "all",
  org_tables$fams,
  org_tables$ped,
  sampledata,
  deadSample = c("Tissue")
)


Run the code above in your browser using DataLab