diff --git a/.gitignore b/.gitignore index c1e864c..44f010f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ # Creates binaries *.o *.so +*.dll .Rproj.user vignettes/abc_cache cran-comments.md diff --git a/DESCRIPTION b/DESCRIPTION index efc3416..985fbba 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: coala -Version: 0.5.0.9001 +Version: 0.5.1 License: MIT + file LICENSE Title: A Framework for Coalescent Simulation Authors@R: c( diff --git a/NAMESPACE b/NAMESPACE index 02f73a7..11a9f91 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -153,4 +153,4 @@ importFrom(stats,rgamma) importFrom(stats,simulate) importFrom(utils,capture.output) importFrom(utils,suppressForeignCheck) -useDynLib(coala) +useDynLib(coala, .registration = TRUE) diff --git a/NEWS.md b/NEWS.md index eef46c4..8a18c1f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +coala 0.5.1 +=========== + +* This is a small maintainence release +* Fix a number of minor issues pointed out by hadley/strict (#186) +* Register native routines to fix the new R CMD check NOTE (#187) + + + coala 0.5.0 =========== diff --git a/R/RcppExports.R b/R/RcppExports.R index 9412d6f..1b36bc5 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,99 +1,99 @@ -# Generated by using Rcpp::compileAttributes() -> do not edit by hand -# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -parse_ms_positions <- function(line) { - .Call('coala_parse_ms_positions', PACKAGE = 'coala', line) -} - -parse_ms_output <- function(file_names, sample_size, loci_number) { - .Call('coala_parse_ms_output', PACKAGE = 'coala', file_names, sample_size, loci_number) -} - -parse_seqgen_output <- function(output, individuals, locus_length, locus_number, outgroup_size, calc_segsites = TRUE) { - .Call('coala_parse_seqgen_output', PACKAGE = 'coala', output, individuals, locus_length, locus_number, outgroup_size, calc_segsites) -} - -generate_trio_trees <- function(trees, trio_dists, file_names) { - .Call('coala_generate_trio_trees', PACKAGE = 'coala', trees, trio_dists, file_names) -} - -#' @describeIn segsites Creates segregating sites -#' -#' @param snps The SNP Matrix (see Details). -#' @param positions A numeric vector indicating the relative positions of each -#' SNP on the locus (see Details). -#' @param trio_locus If the locus consists of a locus trio (see Details). -#' @param check Whether non-segregating sites are removed from the segregating -#' sites (\code{TRUE}) or not (\code{FALSE}). -#' @export -#' -create_segsites <- function(snps, positions, trio_locus = numeric(0), check = TRUE) { - .Call('coala_create_segsites', PACKAGE = 'coala', snps, positions, trio_locus, check) -} - -#' @describeIn segsites Returns the SNP matrix from a segregating sites -#' object. -#' -#' @param segsites The segregating sites object -#' @export -get_snps <- function(segsites) { - .Call('coala_get_snps', PACKAGE = 'coala', segsites) -} - -#' @describeIn segsites Returns the SNP's positions from a segregating -#' sites object. -#' @export -get_positions <- function(segsites) { - .Call('coala_get_positions', PACKAGE = 'coala', segsites) -} - -#' @describeIn segsites Sets the SNP's positions in a segregating -#' sites object. -#' @export -set_positions <- function(segsites, positions) { - .Call('coala_set_positions', PACKAGE = 'coala', segsites, positions) -} - -#' @describeIn segsites Returns the trio locus positions from a -#' segregating sites object. -#' @export -get_trio_locus <- function(segsites) { - .Call('coala_get_trio_locus', PACKAGE = 'coala', segsites) -} - -#' @describeIn segsites Sets the trio locus in a segregating sites -#' object. -#' @export -set_trio_locus <- function(segsites, trio_locus) { - .Call('coala_set_trio_locus', PACKAGE = 'coala', segsites, trio_locus) -} - -calc_four_gamete_stat <- function(seg_sites_list, individuals, locus_length, ploidy = 1L) { - .Call('coala_calc_four_gamete_stat', PACKAGE = 'coala', seg_sites_list, individuals, locus_length, ploidy) -} - -#' Calculates the Joint Site Frequency Spectrum -#' -#' @param segsites_list List of segregating sites -#' @param ind_per_pop A list of integer vector, where each entry gives the -#' index of the haploids that belong the corresponding population. -#' -#' @author Paul Staab & Dirk Metzler -#' @return The Joint Site Frequency Spectrum, as a matrix. -#' @keywords internal -calc_jsfs <- function(segsites_list, ind_per_pop) { - .Call('coala_calc_jsfs', PACKAGE = 'coala', segsites_list, ind_per_pop) -} - -calc_mcmf <- function(seg_sites, individuals, has_trios = TRUE, expand_mcmf = FALSE, type_expand = 1L, ploidy = 1L, locus_length = matrix(0)) { - .Call('coala_calc_mcmf', PACKAGE = 'coala', seg_sites, individuals, has_trios, expand_mcmf, type_expand, ploidy, locus_length) -} - -calc_nucleotide_div <- function(segsites_list, individuals) { - .Call('coala_calc_nucleotide_div', PACKAGE = 'coala', segsites_list, individuals) -} - -unphase_segsites <- function(seg_sites_list, ploidy, samples_per_ind) { - .Call('coala_unphase_segsites', PACKAGE = 'coala', seg_sites_list, ploidy, samples_per_ind) -} - +# Generated by using Rcpp::compileAttributes() -> do not edit by hand +# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +parse_ms_positions <- function(line) { + .Call(coala_parse_ms_positions, line) +} + +parse_ms_output <- function(file_names, sample_size, loci_number) { + .Call(coala_parse_ms_output, file_names, sample_size, loci_number) +} + +parse_seqgen_output <- function(output, individuals, locus_length, locus_number, outgroup_size, calc_segsites = TRUE) { + .Call(coala_parse_seqgen_output, output, individuals, locus_length, locus_number, outgroup_size, calc_segsites) +} + +generate_trio_trees <- function(trees, trio_dists, file_names) { + .Call(coala_generate_trio_trees, trees, trio_dists, file_names) +} + +#' @describeIn segsites Creates segregating sites +#' +#' @param snps The SNP Matrix (see Details). +#' @param positions A numeric vector indicating the relative positions of each +#' SNP on the locus (see Details). +#' @param trio_locus If the locus consists of a locus trio (see Details). +#' @param check Whether non-segregating sites are removed from the segregating +#' sites (\code{TRUE}) or not (\code{FALSE}). +#' @export +#' +create_segsites <- function(snps, positions, trio_locus = numeric(0), check = TRUE) { + .Call(coala_create_segsites, snps, positions, trio_locus, check) +} + +#' @describeIn segsites Returns the SNP matrix from a segregating sites +#' object. +#' +#' @param segsites The segregating sites object +#' @export +get_snps <- function(segsites) { + .Call(coala_get_snps, segsites) +} + +#' @describeIn segsites Returns the SNP's positions from a segregating +#' sites object. +#' @export +get_positions <- function(segsites) { + .Call(coala_get_positions, segsites) +} + +#' @describeIn segsites Sets the SNP's positions in a segregating +#' sites object. +#' @export +set_positions <- function(segsites, positions) { + .Call(coala_set_positions, segsites, positions) +} + +#' @describeIn segsites Returns the trio locus positions from a +#' segregating sites object. +#' @export +get_trio_locus <- function(segsites) { + .Call(coala_get_trio_locus, segsites) +} + +#' @describeIn segsites Sets the trio locus in a segregating sites +#' object. +#' @export +set_trio_locus <- function(segsites, trio_locus) { + .Call(coala_set_trio_locus, segsites, trio_locus) +} + +calc_four_gamete_stat <- function(seg_sites_list, individuals, locus_length, ploidy = 1L) { + .Call(coala_calc_four_gamete_stat, seg_sites_list, individuals, locus_length, ploidy) +} + +#' Calculates the Joint Site Frequency Spectrum +#' +#' @param segsites_list List of segregating sites +#' @param ind_per_pop A list of integer vector, where each entry gives the +#' index of the haploids that belong the corresponding population. +#' +#' @author Paul Staab & Dirk Metzler +#' @return The Joint Site Frequency Spectrum, as a matrix. +#' @keywords internal +calc_jsfs <- function(segsites_list, ind_per_pop) { + .Call(coala_calc_jsfs, segsites_list, ind_per_pop) +} + +calc_mcmf <- function(seg_sites, individuals, has_trios = TRUE, expand_mcmf = FALSE, type_expand = 1L, ploidy = 1L, locus_length = matrix(0)) { + .Call(coala_calc_mcmf, seg_sites, individuals, has_trios, expand_mcmf, type_expand, ploidy, locus_length) +} + +calc_nucleotide_div <- function(segsites_list, individuals) { + .Call(coala_calc_nucleotide_div, segsites_list, individuals) +} + +unphase_segsites <- function(seg_sites_list, ploidy, samples_per_ind) { + .Call(coala_unphase_segsites, seg_sites_list, ploidy, samples_per_ind) +} + diff --git a/R/coala.R b/R/coala.R index 6b5b58b..93b66f6 100644 --- a/R/coala.R +++ b/R/coala.R @@ -4,7 +4,7 @@ #' within R. The `introduction` vignette is a good place to start. #' #' @importFrom Rcpp evalCpp -#' @useDynLib coala +#' @useDynLib coala, .registration = TRUE #' @importFrom assertthat assert_that "_PACKAGE" diff --git a/src/R_init_pkg.c b/src/R_init_pkg.c new file mode 100644 index 0000000..1ff73de --- /dev/null +++ b/src/R_init_pkg.c @@ -0,0 +1,46 @@ +#include +#include +#include // for NULL +#include + +/* .Call calls */ +extern SEXP coala_calc_four_gamete_stat(SEXP, SEXP, SEXP, SEXP); +extern SEXP coala_calc_jsfs(SEXP, SEXP); +extern SEXP coala_calc_mcmf(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP coala_calc_nucleotide_div(SEXP, SEXP); +extern SEXP coala_create_segsites(SEXP, SEXP, SEXP, SEXP); +extern SEXP coala_generate_trio_trees(SEXP, SEXP, SEXP); +extern SEXP coala_get_positions(SEXP); +extern SEXP coala_get_snps(SEXP); +extern SEXP coala_get_trio_locus(SEXP); +extern SEXP coala_parse_ms_output(SEXP, SEXP, SEXP); +extern SEXP coala_parse_ms_positions(SEXP); +extern SEXP coala_parse_seqgen_output(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP coala_set_positions(SEXP, SEXP); +extern SEXP coala_set_trio_locus(SEXP, SEXP); +extern SEXP coala_unphase_segsites(SEXP, SEXP, SEXP); + +static const R_CallMethodDef CallEntries[] = { + {"coala_calc_four_gamete_stat", (DL_FUNC) &coala_calc_four_gamete_stat, 4}, + {"coala_calc_jsfs", (DL_FUNC) &coala_calc_jsfs, 2}, + {"coala_calc_mcmf", (DL_FUNC) &coala_calc_mcmf, 7}, + {"coala_calc_nucleotide_div", (DL_FUNC) &coala_calc_nucleotide_div, 2}, + {"coala_create_segsites", (DL_FUNC) &coala_create_segsites, 4}, + {"coala_generate_trio_trees", (DL_FUNC) &coala_generate_trio_trees, 3}, + {"coala_get_positions", (DL_FUNC) &coala_get_positions, 1}, + {"coala_get_snps", (DL_FUNC) &coala_get_snps, 1}, + {"coala_get_trio_locus", (DL_FUNC) &coala_get_trio_locus, 1}, + {"coala_parse_ms_output", (DL_FUNC) &coala_parse_ms_output, 3}, + {"coala_parse_ms_positions", (DL_FUNC) &coala_parse_ms_positions, 1}, + {"coala_parse_seqgen_output", (DL_FUNC) &coala_parse_seqgen_output, 6}, + {"coala_set_positions", (DL_FUNC) &coala_set_positions, 2}, + {"coala_set_trio_locus", (DL_FUNC) &coala_set_trio_locus, 2}, + {"coala_unphase_segsites", (DL_FUNC) &coala_unphase_segsites, 3}, + {NULL, NULL, 0} +}; + +void R_init_coala(DllInfo *dll) +{ + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 4176f85..a73bc2d 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -199,27 +199,3 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } - -static const R_CallMethodDef CallEntries[] = { - {"coala_parse_ms_positions", (DL_FUNC) &coala_parse_ms_positions, 1}, - {"coala_parse_ms_output", (DL_FUNC) &coala_parse_ms_output, 3}, - {"coala_parse_seqgen_output", (DL_FUNC) &coala_parse_seqgen_output, 6}, - {"coala_generate_trio_trees", (DL_FUNC) &coala_generate_trio_trees, 3}, - {"coala_create_segsites", (DL_FUNC) &coala_create_segsites, 4}, - {"coala_get_snps", (DL_FUNC) &coala_get_snps, 1}, - {"coala_get_positions", (DL_FUNC) &coala_get_positions, 1}, - {"coala_set_positions", (DL_FUNC) &coala_set_positions, 2}, - {"coala_get_trio_locus", (DL_FUNC) &coala_get_trio_locus, 1}, - {"coala_set_trio_locus", (DL_FUNC) &coala_set_trio_locus, 2}, - {"coala_calc_four_gamete_stat", (DL_FUNC) &coala_calc_four_gamete_stat, 4}, - {"coala_calc_jsfs", (DL_FUNC) &coala_calc_jsfs, 2}, - {"coala_calc_mcmf", (DL_FUNC) &coala_calc_mcmf, 7}, - {"coala_calc_nucleotide_div", (DL_FUNC) &coala_calc_nucleotide_div, 2}, - {"coala_unphase_segsites", (DL_FUNC) &coala_unphase_segsites, 3}, - {NULL, NULL, 0} -}; - -RcppExport void R_init_coala(DllInfo *dll) { - R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); - R_useDynamicSymbols(dll, FALSE); -}