Skip to contents

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 = NULL,
  plot_indivs = NULL,
  all_fams,
  ped,
  sampledata,
  datacolumns = c("Sample", "AnimalRef", "GeneticSex", "Date", "SType", "lat", "lng",
    "FirstSeen", "LastSeen", "IsDead", "IsMortality")
)

Arguments

plot_fams

Character string or numeric vector. Defines which families to include. Use "all" (or NULL, default) to include all families, or a numeric vector of specific FamID numbers to plot a subset (see Details).

plot_indivs

Character string or vector of character strings. Individual identifiers to include. The families associated with these individuals (as father, mother, or offspring) will be included in the output (see Details).

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

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.

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 the individual is dead; logical (default = IsDead, see anim_timespan() function).

    • value identifying if this particular sample represents a mortality sample (default = IsMortality, see check_sampledata() function)

Filtering Options The plot_table function allows for flexible subsetting of families to be plotted using the plot_fams and plot_indivs arguments:

  • plot_fams: A numeric vector of specific FamIDs to include.

  • plot_indivs: A vector of individual identifiers. Families where these individuals appear as a father, mother, or offspring are automatically identified and included.

Behavior:

  • If both plot_fams and plot_indivs are NULL (default), all families are included.

  • If one or both are provided, the final set of families is the union of families identified by both filters.

Examples


# 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$IsMortality
)
# 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
# Standard usage: all families
pt <- plot_table(plot_fams = "all",
  all_fams = org_tables$fams,
  ped = org_tables$ped,
  sampledata = sampledata,
)


# Plot table for a subset of individuals
pt_subset <- plot_table(plot_indivs = "M200F",
                        all_fams = org_tables$fams,
                        ped = org_tables$ped,
                        sampledata = sampledata
                       )