Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions R/simulatePedigree.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#' as well as assigning unique couple IDs. It does not return a value explicitly.
#'

buildBetweenGenerations <- function(df_Fam, Ngen, sizeGens, verbose = FALSE, marR, sexR, kpc,
buildBtwnGenerations <- function(df_Fam, Ngen, sizeGens, verbose = FALSE, marR, sexR, kpc,
rd_kpc, personID = "ID",

Check notice on line 26 in R/simulatePedigree.R

View check run for this annotation

codefactor.io / CodeFactor

R/simulatePedigree.R#L26

Hanging indent should be 33 spaces but is 36 spaces. (indentation_linter)
momID = "momID",
dadID = "dadID",
code_male = "M", code_female = "F", beta = FALSE) {
Expand All @@ -41,7 +41,7 @@
}

if (use_optimized) {
df_Fam <- buildBetweenGenerations_optimized(
df_Fam <- buildBtwnGenerations_opt(
df_Fam = df_Fam,
Ngen = Ngen,
sizeGens = sizeGens,
Expand All @@ -58,7 +58,7 @@
beta = TRUE
)
} else {
df_Fam <- buildBetweenGenerations_base(
df_Fam <- buildBtwnGenerations_base(
df_Fam = df_Fam,
Ngen = Ngen,
sizeGens = sizeGens,
Expand All @@ -75,11 +75,11 @@
beta = FALSE
)
}
return(df_Fam)
df_Fam
}


buildBetweenGenerations_base <- function(df_Fam,
buildBtwnGenerations_base <- function(df_Fam,
Ngen,
sizeGens,
verbose = FALSE,
Expand Down Expand Up @@ -360,15 +360,10 @@

# Align lengths between couples and random_numbers.
# If random_numbers is longer than couples, truncate random_numbers.
# If random_numbers is shorter than couples, drop extra couples.
nCouples <- length(parent_rows)

if (length(random_numbers) > nCouples) {
random_numbers <- random_numbers[seq_len(nCouples)]
} else if (length(random_numbers) < nCouples) {
keep <- seq_len(length(random_numbers))
ma_ids <- ma_ids[keep]
pa_ids <- pa_ids[keep]
}

# Expand from "one mother/father per couple" to "one mother/father per child".
Expand Down Expand Up @@ -455,16 +450,16 @@
}
}
}
return(df_Fam)
df_Fam
}

buildBetweenGenerations_optimized <- function(df_Fam,
buildBtwnGenerations_opt <- function(df_Fam,
Ngen,

Check notice on line 457 in R/simulatePedigree.R

View check run for this annotation

codefactor.io / CodeFactor

R/simulatePedigree.R#L457

Hanging indent should be 37 spaces but is 46 spaces. (indentation_linter)
sizeGens,
verbose = FALSE,
marR, sexR, kpc,
rd_kpc, personID = "ID",
momID = "momID",

Check notice on line 462 in R/simulatePedigree.R

View check run for this annotation

codefactor.io / CodeFactor

R/simulatePedigree.R#L462

Hanging indent should be 39 spaces but is 46 spaces. (indentation_linter)
dadID = "dadID",
code_male = "M",
code_female = "F",
Expand Down Expand Up @@ -743,15 +738,10 @@

# Align lengths between couples and random_numbers.
# If random_numbers is longer than couples, truncate random_numbers.
# If random_numbers is shorter than couples, drop extra couples.
nCouples <- length(parent_rows)

if (length(random_numbers) > nCouples) {
random_numbers <- random_numbers[seq_len(nCouples)]
} else if (length(random_numbers) < nCouples) {
keep <- seq_len(length(random_numbers))
ma_ids <- ma_ids[keep]
pa_ids <- pa_ids[keep]
}

# Expand from "one mother/father per couple" to "one mother/father per child".
Expand Down Expand Up @@ -838,7 +828,7 @@
}
}
}
return(df_Fam)
df_Fam
}

#' Simulate Pedigrees
Expand Down Expand Up @@ -956,7 +946,7 @@
)
}

df_Fam <- buildBetweenGenerations(
df_Fam <- buildBtwnGenerations(
df_Fam = df_Fam,
Ngen = Ngen,
sizeGens = sizeGens,
Expand All @@ -981,7 +971,7 @@
# connect the detached members
df_Fam[is.na(df_Fam[[momID]]) & is.na(df_Fam[[dadID]]) & df_Fam$gen > 1, ]

return(df_Fam)
df_Fam
}

#' @rdname simulatePedigree
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading