-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mgaynor1
authored and
mgaynor1
committed
May 10, 2024
1 parent
e0619e0
commit 77b6b8e
Showing
214 changed files
with
2,721 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: AutoPop | ||
Title: Autopolyploid population simulations | ||
Version: 1.0.0.0000 | ||
Version: 1.0.0.1 | ||
Authors@R: | ||
c(person(given = "Michelle", family ="Gaynor", middle = "L", email = "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-3912-6079")), | ||
|
@@ -18,7 +18,7 @@ Description: R-based joint-dynamic population simulation for | |
License: GPL (>= 3) | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
RoxygenNote: 7.3.1 | ||
Suggests: | ||
testthat (>= 3.0.0) | ||
Imports: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Environmental Copula - Calculates correlation probability. | ||
#' | ||
#' @description Calculates the probability coefficient which allow cytotype and stage correlations | ||
#' | ||
#' | ||
#' @param rho Correlation coefficient. Must be a single integer between 0 and 1. | ||
#' @inheritParams gen.iter.f.choosy | ||
#' | ||
#' @returns A list of two matrix: X and U. Here, X is the matrix which was simulated from | ||
#' a multivariate normal distribution. The U matrix is simply the X matrix transformed into a uniform distribution. | ||
#' Each matrix has 3 columns, one for each cytotype. The length of the matrix matches the number of generations provided. | ||
#' | ||
#' @importFrom MASS mvrnorm | ||
#' @importFrom stats pnorm | ||
#' | ||
|
||
|
||
env.copula <- function(rho, generations){ | ||
# Create covariance matrix | ||
n <- 3 # Three cytotypes | ||
mean <- rep(0,n) | ||
# covariance matrix for the cytotypes | ||
SIGMA <- ((1-rho)*diag(n) + rho*matrix(1, nrow = n, ncol = n)) | ||
# Simulate from a multivariate normal distribution | ||
X <- MASS::mvrnorm(n = generations, mu = mean, Sigma = SIGMA) | ||
# Transform to uniform using pnorm, which is the cdf for a normal distribution | ||
U <- pnorm(X) | ||
out <- list(X, U) | ||
return(out) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' Max mean allowed | ||
#' | ||
#' Given an env.ci value, we identified allowed means between 0 and 1. | ||
#' | ||
#' @param env.ci Proportion of environmental variance used to define mature survival rate per generation | ||
#' with a beta distribution. This number must be in between 0 and 1, but cannot be equal to 0 or 1. | ||
#' | ||
#' @return All values allowed and not allowed. | ||
#' | ||
|
||
mu.options <- function(env.ci){ | ||
p.mu <- seq(0.001,1, by = 0.0001) | ||
notallowed <- c() | ||
allowed <- c() | ||
for(i in 1:length(p.mu)){ | ||
|
||
mu <- p.mu[i] | ||
var <- (env.ci*(mu*(1-mu))) | ||
less <- (mu*(mu-1)) | ||
|
||
if((var > less) == FALSE){ | ||
notallowed <- c(notallowed, mu) | ||
}else{ | ||
allowed <- c(allowed, mu) | ||
} | ||
} | ||
out <- list(not_allowed = notallowed, allowed = allowed) | ||
return(out) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#' Survival shape - Calculates the alpha and beta value for survival beta distributions | ||
#' | ||
#' @description Calculates the shape parameters needed to sample a beta distribution | ||
#' for both immature survival and mature survival | ||
#' | ||
#' | ||
#' @param raw.means Mean probability of mature survival or immature survival. Must be a list of three integer between 0 and 1. | ||
#' @param env.ci Proportion of environmental variance used to define mature survival rate per generation. | ||
#' Must be a single integer greater than or equal to 0 and less than 1. | ||
#' | ||
#' @returns Matrix of alpha and beta parameters where matrix[1,i] is the alpha value for the ith mean, and matrix[2,i] | ||
#' is the beta value for the ith mean. | ||
#' | ||
#' @importFrom stats na.omit rbeta | ||
#' | ||
|
||
|
||
surv.shape <- function(env.ci, raw.means){ | ||
var <- var.option(env.ci = env.ci, mu = raw.means) | ||
alpha.beta <- sapply(1:length(raw.means), function(item) alphabeta.calc(raw.means[item], var[item])) | ||
return(alpha.beta) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.