From b760efb013afda97eaafe2f612a904557b3e0f4c Mon Sep 17 00:00:00 2001 From: Andrea Manica Date: Fri, 18 Oct 2024 21:46:37 +0100 Subject: [PATCH] clean up --- R/gt_helper_functions.R | 20 -------------------- R/gt_roh_window.R | 4 ++-- man/gt_roh_window.Rd | 4 ++-- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/R/gt_helper_functions.R b/R/gt_helper_functions.R index bc58f58c..aa0bc217 100644 --- a/R/gt_helper_functions.R +++ b/R/gt_helper_functions.R @@ -10,23 +10,3 @@ .gt_get_bigsnp<-function(.x){ attr(.x$genotypes,"bigsnp") } - - -# a developer function to create various count summaries of a population, used to -# compute more complex statistics (e.g. pairwise fst, etc.). -.gt_pop_freqs <- function(.x){ - counts <- bigstatsr::big_counts( .gt_get_bigsnp(.x)$genotypes, - ind.row =.gt_bigsnp_rows(.x), - ind.col = .gt_bigsnp_cols(.x)) - sums_alt <- apply(counts,2,function(x) x[2]+2*x[3]) - n <- apply(counts,2,function(x) sum(x[1:3])*2) - sums_ref <- n - sums_alt - freq_alt <- sums_alt/n - freq_ref <- 1- freq_alt - het_obs <- apply(counts,2,function(x) x[2]/sum(x[1:3])) - return (list( - freq_alt = freq_alt, - freq_ref = freq_ref, - n = n, - het_obs = het_obs)) -} diff --git a/R/gt_roh_window.R b/R/gt_roh_window.R index fc4d3d12..ae38bbb1 100644 --- a/R/gt_roh_window.R +++ b/R/gt_roh_window.R @@ -42,8 +42,8 @@ #' @export #' #' @examples -#' # don't run the example -#' if (FALSE) { +#' # run the example only if we have the package installed +#' if (requireNamespace("detectRUNS", quietly = TRUE)) { #' sheep_ped <- system.file("extdata", "Kijas2016_Sheep_subset.ped", #' package="detectRUNS") #' sheep_gt <- tidypopgen::gen_tibble(sheep_ped, backingfile = tempfile(), diff --git a/man/gt_roh_window.Rd b/man/gt_roh_window.Rd index a569ba0b..441d8801 100644 --- a/man/gt_roh_window.Rd +++ b/man/gt_roh_window.Rd @@ -74,8 +74,8 @@ group table. Otherwise, the group 'column' is filled with the same values as the column } \examples{ -# don't run the example -if (FALSE) { +# run the example only if we have the package installed +if (requireNamespace("detectRUNS", quietly = TRUE)) { sheep_ped <- system.file("extdata", "Kijas2016_Sheep_subset.ped", package="detectRUNS") sheep_gt <- tidypopgen::gen_tibble(sheep_ped, backingfile = tempfile(),