Skip to content

Commit

Permalink
More CRAN tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusdv committed Apr 14, 2023
1 parent 84ea9a0 commit 10b96e2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 23 additions & 2 deletions R/kinshipLR.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions R/powerPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") |>
Expand Down
4 changes: 3 additions & 1 deletion man/kinshipLR.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/powerPlot.Rd

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

0 comments on commit 10b96e2

Please sign in to comment.