Skip to content

Commit

Permalink
rename vars to same style
Browse files Browse the repository at this point in the history
  • Loading branch information
smasongarrison committed Sep 8, 2023
1 parent 8bce98e commit a46d03d
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 77 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(PlotPedigree)
export(SimPed)
export(allGens)
export(comp2vech)
Expand All @@ -15,8 +14,10 @@ export(ped2com)
export(ped2fam)
export(ped2graph)
export(ped2mit)
export(plotPedigree)
export(related_coef)
export(relatedness)
export(simulatePedigree)
export(vech)
import(kinship2)
importFrom(stats,runif)
6 changes: 3 additions & 3 deletions R/famSizeCal.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' allGens
#' A function to calculate the number of individuals in each generation. This is a supporting function for \code{SimPed}.
#' A function to calculate the number of individuals in each generation. This is a supporting function for \code{simulatePedigree}.
#' @param kpc Number of kids per couple (integer >= 2).
#' @param Ngen Number of generations (integer >= 1).
#' @param marR Mating rate (numeric value ranging from 0 to 1).
Expand Down Expand Up @@ -27,7 +27,7 @@ allGens <- function(kpc, Ngen, marR) {


#' sizeAllGens
#' An internal supporting function for \code{SimPed}.
#' An internal supporting function for \code{simulatePedigree}.
#' @inheritParams allGens
#' @return Returns a vector including the number of individuals in every generation.

Expand All @@ -50,7 +50,7 @@ sizeAllGens <- function(kpc, Ngen, marR) {


#' famSizeCal
#' A function to calculate the total number of individuals in a pedigree given parameters. This is a supporting function for function \code{SimPed}
#' A function to calculate the total number of individuals in a pedigree given parameters. This is a supporting function for function \code{simulatePedigree}
#' @inheritParams allGens
#' @return Returns a numeric value indicating the total pedigree size.
#' @export
Expand Down
23 changes: 23 additions & 0 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,26 @@ Null <- function(M) {
}
return(qr.Q(tmp, complete = TRUE)[, set, drop = FALSE])
}

#' SimPed (Deprecated)
#'
#' This function is a wrapper around the new `simulatePedigree` function.
#' `SimPed` has been deprecated, and it's advised to use `simulatePedigree` directly.
#'
#' @param ... Arguments to be passed to `simulatePedigree`.
#' @return The same result as calling `simulatePedigree`.
#' @seealso \code{\link{simulatePedigree}} for the updated function.
#' @description When calling this function, a warning will be issued about its deprecation.
#' @keywords deprecated
#' @examples
#' \dontrun{
#' # This is an example of the deprecated function:
#' SimPed(...)
#' # It is recommended to use:
#' simulatePedigree(...)
#' }
#' @export
SimPed <- function(...) {
warning("The 'SimPed' function is deprecated. Please use 'simulatePedigree' instead.")
simulatePedigree(...)
}
10 changes: 5 additions & 5 deletions R/PlotPedigree.R → R/plotPedigree.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#' PlotPedigree
#' A wrapped function to plot simulated pedigree from function \code{SimPed}. This function require the installation of package \code{kinship2}.
#' plotPedigree
#' A wrapped function to plot simulated pedigree from function \code{simulatePedigree}. This function require the installation of package \code{kinship2}.
#' @import kinship2
#' @param ped The simulated pedigree data.frame from function \code{SimPed}. Or a pedigree dataframe with the same colnames as the dataframe simulated from function \code{SimPed}.
#' @param ped The simulated pedigree data.frame from function \code{simulatePedigree}. Or a pedigree dataframe with the same colnames as the dataframe simulated from function \code{simulatePedigree}.
#' @param cex The font size of the IDs for each individual in the plot.
#' @inheritParams kinship2::plot.pedigree
#' @return A plot of the simulated pedigree
#' @export

PlotPedigree <- function(ped, cex = .5,
plotPedigree <- function(ped, cex = .5,
# optional inputs for the pedigree plot
col = 1,
symbolsize = 1, branch = 0.6,
Expand Down Expand Up @@ -45,4 +45,4 @@ PlotPedigree <- function(ped, cex = .5,
))
}

# PlotPedigree(SimPed(kpc = 2, Ngen = 6, marR = .8))
# plotPedigree(simulatePedigree(kpc = 2, Ngen = 6, marR = .8))
2 changes: 1 addition & 1 deletion R/SimPed.R → R/simulatePedigree.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' }
#' @export

SimPed <- function(kpc = 3,
simulatePedigree <- function(kpc = 3,
Ngen = 4,
sexR = .5,
marR = 2 / 3,
Expand Down
22 changes: 12 additions & 10 deletions man/PlotPedigree.Rd

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

58 changes: 22 additions & 36 deletions man/SimPed.Rd

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

4 changes: 2 additions & 2 deletions man/allGens.Rd

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

4 changes: 2 additions & 2 deletions man/famSizeCal.Rd

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

2 changes: 1 addition & 1 deletion man/hazard.Rd

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

47 changes: 47 additions & 0 deletions man/simulatePedigree.Rd

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

4 changes: 2 additions & 2 deletions man/sizeAllGens.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-pedigreesim.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("simulated pedigree generates expected data structure", {
set.seed(5)
results <- SimPed(kpc = 4, Ngen = 4, sexR = .5, marR = .7)
results <- simulatePedigree(kpc = 4, Ngen = 4, sexR = .5, marR = .7)

expect_equal(length(results$ID), 57)
expect_equal(length(results), 7)
Expand Down
16 changes: 8 additions & 8 deletions vignettes/vignette_pedigree.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For example, a pedigree that follows these conditions: There are a total of four

```{r}
set.seed(5)
Ped <- SimPed(kpc = 4, Ngen = 4, sexR = .5, marR = .7)
Ped <- simulatePedigree(kpc = 4, Ngen = 4, sexR = .5, marR = .7)
summary(Ped)
```
Expand All @@ -54,15 +54,15 @@ The columns represents the individual's family ID, the individual's personal ID,
## Plotting Pedigree


Pedigrees are visual diagrams that represent family relationships across generations. They are commonly used in genetics to trace the inheritance of specific traits or conditions. This vignette will guide you through visualizing simulated pedigrees using the `PlotPedigree` function. This function is a wrapper function for Kinship2's base R plotting.
Pedigrees are visual diagrams that represent family relationships across generations. They are commonly used in genetics to trace the inheritance of specific traits or conditions. This vignette will guide you through visualizing simulated pedigrees using the `plotPedigree` function. This function is a wrapper function for Kinship2's base R plotting.

### Single Pedigree Visualization

To visualize a single simulated pedigree, use the `PlotPedigree()` function.
To visualize a single simulated pedigree, use the `plotPedigree()` function.

```{r,fig.width=8,fig.height=6}
# Plot the simulated pedigree
PlotPedigree(Ped)
plotPedigree(Ped)
```


Expand All @@ -75,19 +75,19 @@ If you wish to compare different pedigrees side by side, you can plot them toget

```{r,fig.width=8, fig.height=6}
# Simulate a family with 3 generations
df_ped_3 <- SimPed(Ngen = 3)
df_ped_3 <- simulatePedigree(Ngen = 3)
# Simulate a family with 4 generations
df_ped_4 <- SimPed(Ngen = 4)
df_ped_4 <- simulatePedigree(Ngen = 4)
# Set up plotting parameters for side-by-side display
par(mfrow = c(1, 2))
# Plot the 3-generation pedigree
PlotPedigree(df_ped_3, width = 3)
plotPedigree(df_ped_3, width = 3)
# Plot the 4-generation pedigree
PlotPedigree(df_ped_4, width = 1)
plotPedigree(df_ped_4, width = 1)
```

By examining the side-by-side plots, you can contrast and analyze the structures of different families, tracing the inheritance of specific traits or conditions if needed.
Loading

0 comments on commit a46d03d

Please sign in to comment.