Skip to content

Commit

Permalink
Add function cross2_do_to_genail
Browse files Browse the repository at this point in the history
- Converts cross2 object from crosstype "do" to crosstype "genail8"
  • Loading branch information
kbroman committed Apr 9, 2021
1 parent 3cad8d0 commit dcb7a76
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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] (<https://orcid.org/0000-0002-4914-6671>)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
41 changes: 41 additions & 0 deletions R/cross2_do_to_genail.R
Original file line number Diff line number Diff line change
@@ -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
}
28 changes: 28 additions & 0 deletions man/cross2_do_to_genail8.Rd

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

0 comments on commit dcb7a76

Please sign in to comment.