diff --git a/NEWS.md b/NEWS.md index a007e52..4bcc577 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,9 +14,11 @@ * Added license statement GPL (>=2). -* Expand README, adding an example with conditional simulation. +* Expanded README, adding an example with conditional simulation. -* Update package documentation. +* Updated package documentation. + +* Fixed CRAN note by avoiding `ibdsim2:::`. # forrel 1.5.0 diff --git a/R/kinshipLR.R b/R/kinshipLR.R index 4ff05f9..fa491bc 100644 --- a/R/kinshipLR.R +++ b/R/kinshipLR.R @@ -102,6 +102,9 @@ #' # Requires ibdsim2 and MERLIN #' if(requireNamespace("ibdsim2", quietly = TRUE) && pedprobr::checkMerlin()) { #' +#' # Load recombination map +#' map = ibdsim2::loadMap("decode19", uniform = TRUE) # unif for speed +#' #' # Define pedigrees #' ids = c("A", "B") #' H = relabel(halfSibPed(), old = c(4,5), new = ids) @@ -112,7 +115,6 @@ #' G = setSNPs(G, FORCE[1:10, ]) # use all for better results #' #' # Simulate recombination pattern in G -#' map = ibdsim2::loadMap("decode19", uniform = TRUE) # unif for speed #' ibd = ibdsim2::ibdsim(G, N = 1, ids = ids, map = map) #' #' # Simulate genotypes conditional on pattern @@ -243,7 +245,7 @@ kinshipLR = function(..., ref = NULL, source = NULL, markers = NULL, linkageMap cat("Converting attached marker positions from MB to CM\n") physMap = getMap(x[[1]]) - linkageMap = ibdsim2:::convertMap(physMap, genomeMap = linkageMap) + linkageMap = .convertMap(physMap, linkageMap) } # Lump all peds, if not already done (a bit of a hack) @@ -335,3 +337,22 @@ print.LRresult = function(x, ...) { print(x$LRtotal) } + +# physMap = output from `getMap()` +# genMap = class `genomeMap` +.convertMap = function(physMap, genMap) { + + # Split marker map by chromosome (keep original chrom order) + chromSplit = split(physMap, factor(physMap$CHROM, levels = unique(physMap$CHROM))) + + # Convert positions in each chrom + newmap = lapply(chromSplit, function(chrmap) { + CM = ibdsim2::convertPos(chrmap$CHROM, Mb = chrmap$MB, map = genMap, sex = "average") + cbind(chrmap, CM = CM)[c("CHROM", "MARKER", "CM", "MB")] # 3 first cols as used by MERLIN + }) + + res = do.call(rbind, newmap) + rownames(res) = NULL + + res +} diff --git a/R/powerPlot.R b/R/powerPlot.R index 5e27b50..3ca0af7 100644 --- a/R/powerPlot.R +++ b/R/powerPlot.R @@ -66,8 +66,8 @@ #' #' ### Example 1: Comparing the power of 3 reference families ### #' -#' # Frequencies for 3 STR markers -#' db = NorwegianFrequencies[1:3] +#' # Frequencies for 2 STR markers +#' db = NorwegianFrequencies[1:2] # Increase! #' #' # Define pedigrees and simulate data #' PAR = nuclearPed(1, child = "MP") |> diff --git a/man/kinshipLR.Rd b/man/kinshipLR.Rd index 4a00e9e..189788c 100644 --- a/man/kinshipLR.Rd +++ b/man/kinshipLR.Rd @@ -119,6 +119,9 @@ res$likelihoodsPerMarker # Requires ibdsim2 and MERLIN if(requireNamespace("ibdsim2", quietly = TRUE) && pedprobr::checkMerlin()) { + # Load recombination map + map = ibdsim2::loadMap("decode19", uniform = TRUE) # unif for speed + # Define pedigrees ids = c("A", "B") H = relabel(halfSibPed(), old = c(4,5), new = ids) @@ -129,7 +132,6 @@ if(requireNamespace("ibdsim2", quietly = TRUE) && pedprobr::checkMerlin()) { G = setSNPs(G, FORCE[1:10, ]) # use all for better results # Simulate recombination pattern in G - map = ibdsim2::loadMap("decode19", uniform = TRUE) # unif for speed ibd = ibdsim2::ibdsim(G, N = 1, ids = ids, map = map) # Simulate genotypes conditional on pattern diff --git a/man/powerPlot.Rd b/man/powerPlot.Rd index 717b980..508a7b5 100644 --- a/man/powerPlot.Rd +++ b/man/powerPlot.Rd @@ -108,8 +108,8 @@ points are included. ### Example 1: Comparing the power of 3 reference families ### -# Frequencies for 3 STR markers -db = NorwegianFrequencies[1:3] +# Frequencies for 2 STR markers +db = NorwegianFrequencies[1:2] # Increase! # Define pedigrees and simulate data PAR = nuclearPed(1, child = "MP") |>