compile_pedigree_sex_issues: Compile the connected components of parent pairs with sex...

View source: R/compile_pedigree_sex_issues.R

compile_pedigree_sex_issuesR Documentation

Compile the connected components of parent pairs with sex conflicts or missing data

Description

After a pedigree is inferred, some of the parents might both be of the same sex. This function looks through the pedigree and first warns the user if a pair is compatible (opposite sexes) but the pa is listed as Male or the ma is listed as Female. Then it finds all parent pairs whose members have the same reported sex and it finds the connected components of all of these, and it makes a plot of those as well. It does the same thing for fish with no reported sex.

Usage

compile_pedigree_sex_issues(
  Ped,
  strip_pattern = "_Coyote-Valley$|_Warm-Springs$",
  scc_pointsize = 7,
  suc_pointsize = 7
)

Arguments

Ped

A tibble that has the inferred pedigree in it. This should already be filtered using whatever criteria you want to use (FDR, etc.) This will typically be the output from reformat_no_sex_of_date_results(). Whatever it is, it must have the columns kid, pa, ma, pa_sex, ma_sex, pa_year, and ma_year

strip_pattern

A pattern that should be removed from IDs. This is used for the case where certain samples appear in multiple hatcheries and the occurrence in one of the hatcheries was denoted by adding a suffix to the ID. The default is set up for that as an example

scc_pointsize

The number passed into ggraph for the size of node points for the sex-clashing clusters plot. For the example data, this is set as 7 so that plot works well when printed at 30 inches by 30 inches as a PDF.

suc_pointsize

The number passed into ggraph for the size of node points for the sex-unknown clusters plot. For the example data, this is set as 7 so that plot works well when printed at 30 inches by 30 inches as a PDF.

Value

Returns a list with five components:

  • parent_pairs_graph: a tidygraph object that holds the adjencies between parents and some of their meta data

  • sex_clash_clusters: the portion of the tidygraph that has all the information about the connected components that include at least one sex-clashing parent pair.

  • sex_unknown_clusters: the portion of the tidygraph that has all the information about the connected components that include at least one individual with sex unknown (i.e. not recorded in the data).

  • sex_clash_clusters_plot: a faceted ggplot object. Each panel shows one of the connected components with a sex-clashing pair.

  • sex_unknown_clusters_plot: a faceted ggplot object. Each panel shows one of the connected components with a sex-unknown member.

Examples

# the package comes with a pedigree for this example:
ped <- ped_with_sex_issues
issues <- compile_pedigree_sex_issues(ped)

# to look at the graph you would do like:
## Not run: 
# sex clashing clusters
ggsave(
    issues$sex_clash_clusters_plot,
    filename = "clash.pdf",
    width = 30,
    height = 30
)
# sex unknown clusters
ggsave(
    issues$sex_unknown_clusters_plot,
    filename = "unknown.pdf",
    width = 15,
    height = 15
)

## End(Not run)

eriqande/HatcheryPedAgree documentation built on Sept. 21, 2023, 7:24 p.m.