From dcb7a76f9cf289daf0e9290a51c6e78ca00d6792 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Fri, 9 Apr 2021 13:12:13 -0500 Subject: [PATCH] Add function cross2_do_to_genail - Converts cross2 object from crosstype "do" to crosstype "genail8" --- DESCRIPTION | 4 ++-- NAMESPACE | 1 + NEWS.md | 7 ++++++- R/cross2_do_to_genail.R | 41 +++++++++++++++++++++++++++++++++++++ man/cross2_do_to_genail8.Rd | 28 +++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 R/cross2_do_to_genail.R create mode 100644 man/cross2_do_to_genail8.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 06bdc01..004ca09 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: qtl2convert -Version: 0.23-1 -Date: 2021-03-25 +Version: 0.23-2 +Date: 2021-04-09 Title: Convert Data among QTL Mapping Packages Description: Functions to convert data structures among the 'qtl2', 'qtl', and 'DOQTL' packages for mapping quantitative trait loci (QTL). Author: Karl W Broman [aut, cre] () diff --git a/NAMESPACE b/NAMESPACE index 310f5b4..7f8370e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(cbind_smother) export(count_unique_geno) +export(cross2_do_to_genail8) export(encode_geno) export(find_consensus_geno) export(find_unique_geno) diff --git a/NEWS.md b/NEWS.md index 45fc457..ad0707e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,9 @@ -## qtl2convert 0.23-1 (2021-03-25) +## qtl2convert 0.23-2 (2021-04-09) + +### Minor changes + +- Added function `cross2_do_to_genail()` for converting a cross2 + object of type `"do"` to one of type `"genail"`. ### Bug fixes diff --git a/R/cross2_do_to_genail.R b/R/cross2_do_to_genail.R new file mode 100644 index 0000000..37a99a5 --- /dev/null +++ b/R/cross2_do_to_genail.R @@ -0,0 +1,41 @@ +# cross2_do_to_genail8() +#' Convert cross2 object from do to genail8 +#' +#' Convert a cross2 object from cross type `"do"` to cross type `"genail8"`. +#' +#' @param cross Object of class `"cross2"`, as produced by +#' [qtl2::read_cross2()]. +#' +#' @return The input object `cross` with cross type changed to +#' class `"genail8"` and the cross information revised to match. +#' +#' @export +#' +#' @examples +#' \dontrun{ +#' file <- paste0("https://raw.githubusercontent.com/rqtl/", +#' "qtl2data/master/DOex/DOex.zip") +#' DOex <- read_cross2(file) +#' +#' DOex_genail <- cross2_do_to_genail(DOex) +#' } + +cross2_do_to_genail8 <- + function(cross) +{ + + # check that it's cross2 + if(!inherits(cross, "cross2")) stop('Input cross must have class "cross2"') + + # check that it's DO + if(!cross$crosstype == "do") stop('input cross is not of type "do"') + + # crosstype -> genail8 + cross$crosstype <- "genail8" + + # revise cross_info -> + cross$cross_info <- cbind(cross$cross_info+5L, + A=1L, B=1L, C=1L, D=1L, E=1L, F=1L, G=1L, H=1L) + + cross +} diff --git a/man/cross2_do_to_genail8.Rd b/man/cross2_do_to_genail8.Rd new file mode 100644 index 0000000..f693808 --- /dev/null +++ b/man/cross2_do_to_genail8.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cross2_do_to_genail.R +\name{cross2_do_to_genail8} +\alias{cross2_do_to_genail8} +\title{Convert cross2 object from do to genail8} +\usage{ +cross2_do_to_genail8(cross) +} +\arguments{ +\item{cross}{Object of class \code{"cross2"}, as produced by +\code{\link[qtl2:read_cross2]{qtl2::read_cross2()}}.} +} +\value{ +The input object \code{cross} with cross type changed to +class \code{"genail8"} and the cross information revised to match. +} +\description{ +Convert a cross2 object from cross type \code{"do"} to cross type \code{"genail8"}. +} +\examples{ +\dontrun{ +file <- paste0("https://raw.githubusercontent.com/rqtl/", + "qtl2data/master/DOex/DOex.zip") +DOex <- read_cross2(file) + +DOex_genail <- cross2_do_to_genail(DOex) +} +}