From 58ce9644f699dcfe29a49fce877568862c7470ec Mon Sep 17 00:00:00 2001 From: Magnus Dehli Vigeland Date: Wed, 4 Sep 2024 10:27:54 +0200 Subject: [PATCH] Clean up before CRAN submission --- NEWS.md | 11 +++++------ R/utils.R | 2 ++ data-raw/FORCE.R | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/NEWS.md b/NEWS.md index 183d403..26800c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,25 +8,24 @@ - a new argument `ids`, which when given restricts the checks to those individuals - the output column `LR` is renamed to `GLR` (generalised likelihood ratio) - new output column `pedrel` describing (in words) each relationship according to the pedigree. The descriptions are obtained with the **verbalisr** package - - estimation of P-values for each pairwise relationship, by parametric bootstrap simulations. This feature is controlled through new arguments `nsim`, `pvalThreshold` and `seed`. By default `nsim = 0`, meaning that no simulations are performed. The P-values are stored in the output column `pval` + - estimation of P-values for each pairwise relationship, by parametric bootstrap simulations. This feature is controlled through new arguments `nsim`, `pvalThreshold` and `seed`. By default `nsim = 0`, meaning that no simulations are performed. The P-values are stored in the output column `pval`. * New function `quickLR()` performs the most common kinship tests (paternity and sibship) for a pair of individuals. -* New function `ibdLoglik()` computes the pairwise likelihood for given set IBD coefficients (kappa or delta). It replaces the previous (unexported) `.IBDlikelihood` and versions of this. +* New function `ibdLoglik()` computes the pairwise likelihood for given set IBD coefficients (kappa or delta). * Improved progress bars using the `pbapply` package. ## Other -* Refresh code in examples. -* Removed deprecated functions `readFam()` etc, which have been moved to the **pedFamilias** package. - * Removed (long deprecated) `IBDtriangle()`, replaced by `ribd::ibdTriangle()`. * Improved `missingPersonPlot()` appearance. -* Better removal of missing data in `ibdEstimate()`. +* In `ibdEstimate()`, more efficient data prep, and better removal of missing data. + +* Refresh code in examples. # forrel 1.6.1 diff --git a/R/utils.R b/R/utils.R index eee8795..f7fef0e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -173,6 +173,8 @@ fixAllelesAndFreqs = function(alleles = NULL, afreq = NULL, } +# TODO: Remove the following + #' Add points to the IBD triangle #' #' This function is re-exported from the `ribd` package. For documentation see diff --git a/data-raw/FORCE.R b/data-raw/FORCE.R index 29b97c9..cf0c4ac 100644 --- a/data-raw/FORCE.R +++ b/data-raw/FORCE.R @@ -6,12 +6,12 @@ xraw = readxl::read_xlsx("data-raw/FORCE-data.xlsx", n_max = 5422, # skip bad ones at the bottom col_types = "text") -x = xraw %>% - dplyr::filter(startsWith(Type, "Kinship")) %>% +x = xraw |> + dplyr::filter(startsWith(Type, "Kinship")) |> dplyr::select(CHROM = Chromosome, MARKER = SNP, POS = "GRCh38 Region", - REF = "Reference Allele", ALT = "Alternate Allele") %>% - dplyr::mutate(POS = as.integer(POS)) %>% - print + REF = "Reference Allele", ALT = "Alternate Allele") |> + dplyr::mutate(POS = as.integer(POS)) |> + print() mart = useEnsembl(biomart = "snps", dataset = "hsapiens_snp") @@ -20,19 +20,19 @@ info = getBM( filters = c("snp_filter", "chr_name"), values = list(x$MARKER, 1:22), mart = mart -) %>% as_tibble() %>% print() +) |> as_tibble() |> print() filter(info, minor_allele == "") anyDuplicated(info$refsnp_id) -y = left_join(x, info, by = c(MARKER = "refsnp_id")) %>% - dplyr::filter(minor_allele != "") %>% +y = left_join(x, info, by = c(MARKER = "refsnp_id")) |> + dplyr::filter(minor_allele != "") |> dplyr::mutate( MB = POS / 1e6, A1 = if_else(minor_allele == REF, ALT, REF), A2 = if_else(minor_allele == REF, REF, ALT), FREQ1 = 1 - minor_allele_freq - ) # %>% print + ) # |> print # Checks filter(y, POS != chrom_start) @@ -40,10 +40,10 @@ filter(y, is.na(FREQ1)) filter(y, nchar(A1) !=1 | nchar(A2) !=1) # Final table -FORCE = y %>% - dplyr::select(CHROM, MARKER, MB, A1, A2, FREQ1) %>% +FORCE = y |> + dplyr::select(CHROM, MARKER, MB, A1, A2, FREQ1) |> as.data.frame() print(head(FORCE)) -usethis::use_data(FORCE, overwrite = TRUE) +# usethis::use_data(FORCE, overwrite = TRUE)