From 33cfa107e98e02126d7e038ae91e7f8ae535cf46 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Tue, 28 Sep 2021 07:54:23 -0500 Subject: [PATCH] Add example for the mmconvert() function --- DESCRIPTION | 6 +++--- NEWS.md | 2 +- R/mmconvert.R | 20 ++++++++++++++++++++ man/mmconvert.Rd | 20 ++++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 325c941..ad20682 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: mmconvert -Version: 0.1-4 -Date: 2021-09-27 +Version: 0.1-5 +Date: 2021-09-28 Title: Mouse Map Converter Description: Function to convert mouse genome positions between the build 39 physical map and the Cox genetic map . Author: Karl W Broman [aut, cre] () Maintainer: Karl W Broman Authors@R: person("Karl W", "Broman", role=c("aut", "cre"), - email="broman@wisc.edu", comment=c(ORCID = "0000-0002-4914-6671")) + email="broman@wisc.edu", comment=c(ORCID = "0000-0002-4914-6671")) Depends: R (>= 3.5.0) Imports: diff --git a/NEWS.md b/NEWS.md index cd65b30..8aec94c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,3 @@ -## mmconvert 0.1-4 (2021-09-27) +## mmconvert 0.1-5 (2021-09-28) - New package diff --git a/R/mmconvert.R b/R/mmconvert.R index a721301..e2793af 100644 --- a/R/mmconvert.R +++ b/R/mmconvert.R @@ -25,6 +25,26 @@ #' @export #' #' @seealso [coxmap] +#' +#' @examples +#' # input as character strings like chr:position +#' input_char <- c(rs13482072="14:6738536", rs13482231="14:67215850", gnf14.117.278="14:121955310") +#' mmconvert(input_char) +#' +#' # input as list, as in the map object for R/qtl1 and R/qtl2 +#' input_list <- list("14"=c(rs13482072=6738536, rs13482231=67215850, gnf14.117.278=121955310)) +#' mmconvert(input_list) +#' +#' # input as data frame; *must* have chr as first column and position as second +#' # (marker names can be third column, or can be row names) +#' input_df <- data.frame(chr=c(14,14,14), +#' pos=c(6738536, 67215850, 121955310), +#' marker=c("rs13482072", "rs13482231", "gnf14.117.278")) +#' mmconvert(input_df) +#' +#' # input can also be in Mbp +#' input_df$pos <- input_df$pos / 1e6 +#' mmconvert(input_df, input_type="Mbp") mmconvert <- function(positions, input_type=c("bp", "Mbp", "ave_cM", "female_cM", "male_cM")) diff --git a/man/mmconvert.Rd b/man/mmconvert.Rd index 4e5f823..a4227ea 100644 --- a/man/mmconvert.Rd +++ b/man/mmconvert.Rd @@ -37,6 +37,26 @@ the object \link{coxmap}. For positions outside the range of the markers on the Cox map, we extrapolate using the overall recombination rate. } +\examples{ +# input as character strings like chr:position +input_char <- c(rs13482072="14:6738536", rs13482231="14:67215850", gnf14.117.278="14:121955310") +mmconvert(input_char) + +# input as list, as in the map object for R/qtl1 and R/qtl2 +input_list <- list("14"=c(rs13482072=6738536, rs13482231=67215850, gnf14.117.278=121955310)) +mmconvert(input_list) + +# input as data frame; *must* have chr as first column and position as second +# (marker names can be third column, or can be row names) +input_df <- data.frame(chr=c(14,14,14), + pos=c(6738536, 67215850, 121955310), + marker=c("rs13482072", "rs13482231", "gnf14.117.278")) +mmconvert(input_df) + +# input can also be in Mbp +input_df$pos <- input_df$pos / 1e6 +mmconvert(input_df, input_type="Mbp") +} \seealso{ \link{coxmap} }