diff --git a/R/RcppExports.R b/R/RcppExports.R index b42a4a4..2fd63db 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,89 +1,89 @@ -# Generated by using Rcpp::compileAttributes() -> do not edit by hand -# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#' Calculate IBD probabilities -#' -#' Calculate IBD probabilities for different types of populations. -#' -#' IBD probabilities can be calculated for many different types of populations. -#' In the following table all supported populations are listed. Note that the -#' value of x in the population types is variable, with its maximum value -#' depicted in the last column. -#' -#' | __Population type__ | __Cross__ | __Description__ | __max. x__ | -#' | ------ | ----------------- | -------------------------------------- | --- | -#' | DH | biparental | doubled haploid population | | -#' | Fx | biparental | Fx population (F1, followed by x-1 generations of selfing) | 8 | -#' | FxDH | biparental | Fx, followed by DH generation | 8 | -#' | BCx | biparental | backcross, second parent is recurrent parent | 9 | -#' | BCxDH | biparental | BCx, followed by DH generation | 9 | -#' | BC1Sx | biparental | BC1, followed by x generations of selfing | 7 | -#' | BC1SxDH | biparental | BC1, followed by x generations of selfing and DH | 6 | -#' | C3 | three-way | three way cross: (AxB) x C | | -#' | C3DH | three-way | C3, followed by DH generation | | -#' | C3Sx | three-way | C3, followed by x generations of selfing | 7 | -#' | C3SxDH | three-way | C3, followed by x generations of selfing and DH generation | 6 | -#' | C4 | four-way | four-way cross: (AxB) x (CxD) | | -#' | C4DH | four-way | C4, followed by DH generation | | -#' | C4Sx | four-way | C4, followed by x generations of selfing | 6 | -#' | C4SxDH | four-way | C4, followed by x generations of selfing and DH generation | 6 | -#' -#' @param popType A character string indicating the type of population. One of -#' DH, Fx, FxDH, BCx, BCxDH, BC1Sx, BC1SxDH, C3, C3DH, C3Sx, C3SxDH, C4, C4DH, -#' C4Sx, C4SxDH (see Details). -#' @param markerFile A character string indicating the location of the file with -#' genotypic information for the population. The file should be in -#' tab-delimited format with a header containing marker names. -#' @param mapFile A character string indicating the location of the map file -#' for the population. The file should be in tab-delimited format. It should -#' consist of exactly three columns, marker, chromosome and position. There -#' should be no header. The positions in the file should be in centimorgan. -#' @param evalPos A data.frame with evaluation positions to which the -#' calculations should be limited. -#' @param evalDist An optional numerical value indicating the maximum -#' distance for marker positions. Extra markers will be added based on the -#' value of \code{grid}. -#' @param grid Should the extra markers that are added to assure the a -#' maximum distince of \code{evalDist} be on a grid (\code{TRUE}) or in between -#' marker existing marker positions (\code{FALSE}). -#' @param verbose Should messages indicating the progress of the process be -#' printed? -#' -#' @returns An object of class \code{IBDprob}, a \code{list} with five elements, -#' \describe{ -#' \item{map}{a \code{data.frame} with chromosome and position of the markers.} -#' \item{markers}{a 3-dimensional \code{array} of IBD probabilities with -#' genotypes, markers and parents as array dimensions.} -#' \item{parents}{the parents.} -#' \item{popType}{the population type.} -#' } -#' -#' @examples -#' ## Compute IBD probabilities for Steptoe Morex. -#' SxMIBD <- calcIBD(popType = "DH", -#' markerFile = system.file("extdata/SxM", "SxM_geno.txt", -#' package = "statgenIBD"), -#' mapFile = system.file("extdata/SxM", "SxM_map.txt", -#' package = "statgenIBD")) -#' -#' ## Check summary. -#' summary(SxMIBD) -#' -#' ## Compute IBD probabilities for Steptoe Morex. -#' ## Add extra evaluation positions in between exiting marker positions -#' ## to assure evaluation positions are at most 5 cM apart. -#' SxMIBD_Ext <- calcIBD(popType = "DH", -#' markerFile = system.file("extdata/SxM", "SxM_geno.txt", -#' package = "statgenIBD"), -#' mapFile = system.file("extdata/SxM", "SxM_map.txt", -#' package = "statgenIBD"), -#' evalDist = 5) -#' -#' ## Check summary. -#' summary(SxMIBD_Ext) -#' -#' @export -calcIBD <- function(popType, markerFile, mapFile, evalPos = NULL, evalDist = NULL, grid = TRUE, verbose = FALSE) { - .Call(`_statgenIBD_calcIBD`, popType, markerFile, mapFile, evalPos, evalDist, grid, verbose) -} - +# Generated by using Rcpp::compileAttributes() -> do not edit by hand +# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#' Calculate IBD probabilities +#' +#' Calculate IBD probabilities for different types of populations. +#' +#' IBD probabilities can be calculated for many different types of populations. +#' In the following table all supported populations are listed. Note that the +#' value of x in the population types is variable, with its maximum value +#' depicted in the last column. +#' +#' | __Population type__ | __Cross__ | __Description__ | __max. x__ | +#' | ------ | ----------------- | -------------------------------------- | --- | +#' | DH | biparental | doubled haploid population | | +#' | Fx | biparental | Fx population (F1, followed by x-1 generations of selfing) | 8 | +#' | FxDH | biparental | Fx, followed by DH generation | 8 | +#' | BCx | biparental | backcross, second parent is recurrent parent | 9 | +#' | BCxDH | biparental | BCx, followed by DH generation | 9 | +#' | BC1Sx | biparental | BC1, followed by x generations of selfing | 7 | +#' | BC1SxDH | biparental | BC1, followed by x generations of selfing and DH | 6 | +#' | C3 | three-way | three way cross: (AxB) x C | | +#' | C3DH | three-way | C3, followed by DH generation | | +#' | C3Sx | three-way | C3, followed by x generations of selfing | 7 | +#' | C3SxDH | three-way | C3, followed by x generations of selfing and DH generation | 6 | +#' | C4 | four-way | four-way cross: (AxB) x (CxD) | | +#' | C4DH | four-way | C4, followed by DH generation | | +#' | C4Sx | four-way | C4, followed by x generations of selfing | 6 | +#' | C4SxDH | four-way | C4, followed by x generations of selfing and DH generation | 6 | +#' +#' @param popType A character string indicating the type of population. One of +#' DH, Fx, FxDH, BCx, BCxDH, BC1Sx, BC1SxDH, C3, C3DH, C3Sx, C3SxDH, C4, C4DH, +#' C4Sx, C4SxDH (see Details). +#' @param markerFile A character string indicating the location of the file with +#' genotypic information for the population. The file should be in +#' tab-delimited format with a header containing marker names. +#' @param mapFile A character string indicating the location of the map file +#' for the population. The file should be in tab-delimited format. It should +#' consist of exactly three columns, marker, chromosome and position. There +#' should be no header. The positions in the file should be in centimorgan. +#' @param evalPos A data.frame with evaluation positions to which the +#' calculations should be limited. +#' @param evalDist An optional numerical value indicating the maximum +#' distance for marker positions. Extra markers will be added based on the +#' value of \code{grid}. +#' @param grid Should the extra markers that are added to assure the a +#' maximum distince of \code{evalDist} be on a grid (\code{TRUE}) or in between +#' marker existing marker positions (\code{FALSE}). +#' @param verbose Should messages indicating the progress of the process be +#' printed? +#' +#' @returns An object of class \code{IBDprob}, a \code{list} with five elements, +#' \describe{ +#' \item{map}{a \code{data.frame} with chromosome and position of the markers.} +#' \item{markers}{a 3-dimensional \code{array} of IBD probabilities with +#' genotypes, markers and parents as array dimensions.} +#' \item{parents}{the parents.} +#' \item{popType}{the population type.} +#' } +#' +#' @examples +#' ## Compute IBD probabilities for Steptoe Morex. +#' SxMIBD <- calcIBD(popType = "DH", +#' markerFile = system.file("extdata/SxM", "SxM_geno.txt", +#' package = "statgenIBD"), +#' mapFile = system.file("extdata/SxM", "SxM_map.txt", +#' package = "statgenIBD")) +#' +#' ## Check summary. +#' summary(SxMIBD) +#' +#' ## Compute IBD probabilities for Steptoe Morex. +#' ## Add extra evaluation positions in between exiting marker positions +#' ## to assure evaluation positions are at most 5 cM apart. +#' SxMIBD_Ext <- calcIBD(popType = "DH", +#' markerFile = system.file("extdata/SxM", "SxM_geno.txt", +#' package = "statgenIBD"), +#' mapFile = system.file("extdata/SxM", "SxM_map.txt", +#' package = "statgenIBD"), +#' evalDist = 5) +#' +#' ## Check summary. +#' summary(SxMIBD_Ext) +#' +#' @export +calcIBD <- function(popType, markerFile, mapFile, evalPos = NULL, evalDist = NULL, grid = TRUE, verbose = FALSE) { + .Call(`_statgenIBD_calcIBD`, popType, markerFile, mapFile, evalPos, evalDist, grid, verbose) +} + diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 593714d..9c08bc0 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -1,40 +1,40 @@ -// Generated by using Rcpp::compileAttributes() -> do not edit by hand -// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#include -#include - -using namespace Rcpp; - -#ifdef RCPP_USE_GLOBAL_ROSTREAM -Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); -Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); -#endif - -// calcIBD -List calcIBD(CharacterVector& popType, CharacterVector& markerFile, CharacterVector& mapFile, Nullable evalPos, Nullable evalDist, const bool& grid, const bool& verbose); -RcppExport SEXP _statgenIBD_calcIBD(SEXP popTypeSEXP, SEXP markerFileSEXP, SEXP mapFileSEXP, SEXP evalPosSEXP, SEXP evalDistSEXP, SEXP gridSEXP, SEXP verboseSEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< CharacterVector& >::type popType(popTypeSEXP); - Rcpp::traits::input_parameter< CharacterVector& >::type markerFile(markerFileSEXP); - Rcpp::traits::input_parameter< CharacterVector& >::type mapFile(mapFileSEXP); - Rcpp::traits::input_parameter< Nullable >::type evalPos(evalPosSEXP); - Rcpp::traits::input_parameter< Nullable >::type evalDist(evalDistSEXP); - Rcpp::traits::input_parameter< const bool& >::type grid(gridSEXP); - Rcpp::traits::input_parameter< const bool& >::type verbose(verboseSEXP); - rcpp_result_gen = Rcpp::wrap(calcIBD(popType, markerFile, mapFile, evalPos, evalDist, grid, verbose)); - return rcpp_result_gen; -END_RCPP -} - -static const R_CallMethodDef CallEntries[] = { - {"_statgenIBD_calcIBD", (DL_FUNC) &_statgenIBD_calcIBD, 7}, - {NULL, NULL, 0} -}; - -RcppExport void R_init_statgenIBD(DllInfo *dll) { - R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); - R_useDynamicSymbols(dll, FALSE); -} +// Generated by using Rcpp::compileAttributes() -> do not edit by hand +// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#include +#include + +using namespace Rcpp; + +#ifdef RCPP_USE_GLOBAL_ROSTREAM +Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); +Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); +#endif + +// calcIBD +List calcIBD(CharacterVector& popType, CharacterVector& markerFile, CharacterVector& mapFile, Nullable evalPos, Nullable evalDist, const bool& grid, const bool& verbose); +RcppExport SEXP _statgenIBD_calcIBD(SEXP popTypeSEXP, SEXP markerFileSEXP, SEXP mapFileSEXP, SEXP evalPosSEXP, SEXP evalDistSEXP, SEXP gridSEXP, SEXP verboseSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< CharacterVector& >::type popType(popTypeSEXP); + Rcpp::traits::input_parameter< CharacterVector& >::type markerFile(markerFileSEXP); + Rcpp::traits::input_parameter< CharacterVector& >::type mapFile(mapFileSEXP); + Rcpp::traits::input_parameter< Nullable >::type evalPos(evalPosSEXP); + Rcpp::traits::input_parameter< Nullable >::type evalDist(evalDistSEXP); + Rcpp::traits::input_parameter< const bool& >::type grid(gridSEXP); + Rcpp::traits::input_parameter< const bool& >::type verbose(verboseSEXP); + rcpp_result_gen = Rcpp::wrap(calcIBD(popType, markerFile, mapFile, evalPos, evalDist, grid, verbose)); + return rcpp_result_gen; +END_RCPP +} + +static const R_CallMethodDef CallEntries[] = { + {"_statgenIBD_calcIBD", (DL_FUNC) &_statgenIBD_calcIBD, 7}, + {NULL, NULL, 0} +}; + +RcppExport void R_init_statgenIBD(DllInfo *dll) { + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} diff --git a/src/calcIBD.cpp b/src/calcIBD.cpp index e0e4317..de59791 100644 --- a/src/calcIBD.cpp +++ b/src/calcIBD.cpp @@ -99,8 +99,8 @@ using namespace ibd; List calcIBD(CharacterVector& popType, CharacterVector& markerFile, CharacterVector& mapFile, - Nullable evalPos = R_NilValue, - Nullable evalDist = R_NilValue, + Nullable evalPos = R_NilValue, + Nullable evalDist = R_NilValue, const bool& grid = true, const bool& verbose = false) { @@ -126,7 +126,7 @@ List calcIBD(CharacterVector& popType, _poptype, Rcpp::as(markerFile), Rcpp::as(mapFile), - evalPos, + Rcpp::DataFrame(evalPos), max_step_size, grid, verbose);