Skip to content

Commit 2ea088d

Browse files
Simplify documentation and enhance pedigree tests
Removed detailed argument and value sections from Roxygen and Rd docs for several internal functions, keeping only concise descriptions and titles. Improved test coverage in test-simulatePedigree.R by adding a new test for sex ratio imbalance in the opposite direction, refactoring sex ratio checks for clarity, and introducing stricter and more consistent tolerance variables.
1 parent 2d9a21c commit 2ea088d

12 files changed

Lines changed: 115 additions & 240 deletions

R/helpSimulatePedigree_beta.R

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
11
#' Create Data Frame for Generation
2-
#'
3-
#' This function creates a data frame for a specific generation within the simulated pedigree.
4-
#' It initializes the data frame with default values for family ID, individual ID, generation number,
5-
#' paternal ID, maternal ID, spouse ID, and sex. All individuals are initially set with NA for paternal,
6-
#' maternal, spouse IDs, and sex, awaiting further assignment.
7-
#'
8-
#' @param sizeGens A numeric vector containing the sizes of each generation within the pedigree.
9-
#' @param genIndex An integer representing the current generation index for which the data frame is being created.
10-
#' @param idGen A numeric vector containing the ID numbers to be assigned to individuals in the current generation.
11-
#' @param family_id_prefix A character string to prefix the family ID. Default is "fam".
12-
#' @return A data frame representing the initial structure for the individuals in the specified generation
13-
#' before any relationships (parental, spousal) are defined. The columns include family ID (`fam`),
14-
#' individual ID (`id`), generation number (`gen`), father's ID (`pat`), mother's ID (`mat`),
15-
#' spouse's ID (`spID`), and sex (`sex`), with NA values for paternal, maternal, and spouse IDs, and sex.
16-
#' @examples
17-
#' sizeGens <- c(3, 5, 4) # Example sizes for 3 generations
18-
#' genIndex <- 2 # Creating data frame for the 2nd generation
19-
#' idGen <- 101:105 # Example IDs for the 2nd generation
20-
#' df_Ngen <- createGenDataFrame(sizeGens, genIndex, idGen)
21-
#' print(df_Ngen)
2+
#' @rdname createGenDataFrame
223
createGenDataFrame_beta <- function(sizeGens, genIndex, idGen,
234
family_id_prefix = "fam") {
245
n <- sizeGens[genIndex]
@@ -37,16 +18,7 @@ createGenDataFrame_beta <- function(sizeGens, genIndex, idGen,
3718

3819

3920
#' Determine Sex of Offspring
40-
#'
41-
#' This internal function assigns sexes to the offspring in a generation based on the specified sex ratio.
42-
#'
43-
#' @param idGen Vector of IDs for the generation.
44-
#' @param sexR Numeric value indicating the sex ratio (proportion of males).
45-
#' @param code_male The value to use for males. Default is "M"
46-
#' @param code_female The value to use for females. Default is "F"
47-
#' @return Vector of sexes ("M" for male, "F" for female) for the offspring.
48-
#' @importFrom stats runif
49-
21+
#' @rdname determineSex
5022
determineSex_beta <- function(idGen, sexR, code_male = "M", code_female = "F") {
5123
length_idGen <- length(idGen)
5224
if (runif(1) > .5) {
@@ -61,14 +33,7 @@ determineSex_beta <- function(idGen, sexR, code_male = "M", code_female = "F") {
6133
}
6234

6335
#' Assign Couple IDs
64-
#'
65-
#' This subfunction assigns a unique couple ID to each mated pair in the generation.
66-
#' Unmated individuals are assigned NA for their couple ID.
67-
#'
68-
#' @param df_Ngen The dataframe for the current generation, including columns for individual IDs and spouse IDs.
69-
#' @return The input dataframe augmented with a 'coupleId' column, where each mated pair has a unique identifier.
70-
#' @keywords internal
71-
#'
36+
#' @rdname assignCoupleIDs
7237
assignCoupleIDs_beta <- function(df_Ngen) {
7338
df_Ngen$coupleId <- NA_character_ # Initialize the coupleId column with NAs
7439

@@ -90,15 +55,7 @@ assignCoupleIDs_beta <- function(df_Ngen) {
9055

9156

9257
#' Generate or Adjust Number of Kids per Couple Based on Mating Rate
93-
#'
94-
#' This function generates or adjusts the number of kids per couple in a generation
95-
#' based on the specified average and whether the count should be randomly determined.
96-
#'
97-
#' @param nMates Integer, the number of mated pairs in the generation.
98-
#' @inheritParams simulatePedigree
99-
#'
100-
#' @return A numeric vector with the generated or adjusted number of kids per couple.
101-
#' @keywords internal
58+
#' @rdname adjustKidsPerCouple
10259
adjustKidsPerCouple_beta <- function(nMates, kpc, rd_kpc = TRUE) {
10360
if (rd_kpc == TRUE) {
10461
target <- nMates * kpc
@@ -135,26 +92,8 @@ adjustKidsPerCouple_beta <- function(nMates, kpc, rd_kpc = TRUE) {
13592
return(random_numbers)
13693
}
13794

138-
#' Mark and Assign children
139-
#'
140-
#' This subfunction marks individuals in a generation as potential sons, daughters,
141-
#' or parents based on their relationships and assigns unique couple IDs. It processes
142-
#' the assignment of roles and relationships within and between generations in a pedigree simulation.
143-
#' @inheritParams determineSex
144-
#' @param df_Ngen A data frame for the current generation being processed.
145-
#' It must include columns for individual IDs (`id`), spouse IDs (`spID`), sex (`sex`),
146-
#' and any previously assigned roles (`ifparent`, `ifson`, `ifdau`).
147-
#' @param i Integer, the index of the current generation being processed.
148-
#' @param Ngen Integer, the total number of generations in the simulation.
149-
#' @param sizeGens Numeric vector, containing the size (number of individuals) of each generation.
150-
#' @param CoupleF Integer, IT MIGHT BE the number of couples in the current generation.
151-
#'
152-
#'
153-
#' @return Modifies `df_Ngen` in place by updating or adding columns related to individual roles
154-
#' (`ifparent`, `ifson`, `ifdau`) and couple IDs (`coupleId`). The updated data frame is
155-
#' also returned for integration into the larger pedigree data frame (`df_Fam`).
156-
#'
157-
95+
#' Mark Potential Children in a Generation
96+
#' @rdname markPotentialChildren
15897
markPotentialChildren_beta <- function(df_Ngen, i, Ngen, sizeGens, CoupleF, code_male = "M", code_female = "F") {
15998
# Step 2.1: mark a group of potential sons and daughters in the i th generation
16099

man/adjustKidsPerCouple.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/adjustKidsPerCouple_beta.Rd

Lines changed: 0 additions & 27 deletions
This file was deleted.

man/assignCoupleIDs.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/assignCoupleIDs_beta.Rd

Lines changed: 0 additions & 19 deletions
This file was deleted.

man/createGenDataFrame.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/createGenDataFrame_beta.Rd

Lines changed: 0 additions & 36 deletions
This file was deleted.

man/determineSex.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/determineSex_beta.Rd

Lines changed: 0 additions & 23 deletions
This file was deleted.

man/markPotentialChildren.Rd

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)