From f511bb697066f516ca52953d62156623e7c4e45c Mon Sep 17 00:00:00 2001 From: Paul Staab Date: Sun, 19 Jan 2020 13:56:23 +0100 Subject: [PATCH] Remove `as.segsites` function --- DESCRIPTION | 2 +- NAMESPACE | 3 --- NEWS.md | 5 ++-- R/model.R | 1 + R/segsites.R | 32 -------------------------- R/sumstat.R | 9 ++------ man/as.segsites.Rd | 31 ------------------------- man/calc_sumstats_from_data.Rd | 8 ++----- man/coal_model.Rd | 1 + man/segsites.Rd | 3 --- tests/testthat/test-import-popgenome.R | 15 ------------ 11 files changed, 10 insertions(+), 100 deletions(-) delete mode 100644 man/as.segsites.Rd delete mode 100644 tests/testthat/test-import-popgenome.R diff --git a/DESCRIPTION b/DESCRIPTION index b395a22..8b23749 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: coala -Version: 0.5.4 +Version: 0.6.0 License: MIT + file LICENSE Title: A Framework for Coalescent Simulation Authors@R: c( diff --git a/NAMESPACE b/NAMESPACE index 04afbd4..ce24e43 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,8 +3,6 @@ S3method("+",coalmodelpart) S3method("[",segsites) S3method(as.matrix,segsites) -S3method(as.segsites,default) -S3method(as.segsites,list) S3method(conv_to_ms_arg,default) S3method(conv_to_ms_arg,files_feat) S3method(conv_to_ms_arg,growth) @@ -74,7 +72,6 @@ export(activate_ms) export(activate_msms) export(activate_scrm) export(activate_seqgen) -export(as.segsites) export(calc_sumstats_from_data) export(check_model) export(coal_model) diff --git a/NEWS.md b/NEWS.md index 5985d3e..6100fe3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,9 @@ -coala 0.5.4 +coala 0.6.0 =========== * Removes the option to import data import via PopGenome, as PopGenome is not on - CRAN anymore. + CRAN anymore. Also removes the `as.segsites` function, as it does not do anything + anymore without the PopGenome import option (#205). diff --git a/R/model.R b/R/model.R index c040402..a5720bb 100644 --- a/R/model.R +++ b/R/model.R @@ -5,6 +5,7 @@ #' can be simulated using the \code{\link[=simulate.coalmodel]{simulate}} function. #' #' @inheritParams feat_sample +#' @aliases coalmodelpart #' @param sample_size Defines the number of populations and the number of #' individual sampled from each population. Given as an integer vector where #' each entry gives the number of individuals sampled from the corresponding diff --git a/R/segsites.R b/R/segsites.R index 7e28d1f..4c2cb4d 100644 --- a/R/segsites.R +++ b/R/segsites.R @@ -26,7 +26,6 @@ #' #' @name segsites #' @author Paul Staab -#' @seealso For converting biological data to segsites: \code{\link{as.segsites}} #' @examples #' snps <- matrix(c(1, 0, 0, #' 1, 1, 0, @@ -117,34 +116,3 @@ create_locus_trio <- function(left, middle, right) { check = FALSE) }) } - - -#' Convert genetic data to coala's internal format -#' -#' This function can be used to convert the genomic data formats used in other -#' packages to calculate coala's segregating sites object. This is useful for -#' calculating the summary statistics of biological data using the -#' \code{\link{calc_sumstats_from_data}} function. -#' -#' Currently, only the package \pkg{PopGenome} is supported, see -#' \code{\link{as.segsites.GENOME}} for details. -#' -#' @param data The data object that is converted. -#' @param ... Additional arguments specific for the used package. -#' -#' @return A list of segregating sites objects. -#' @seealso Further instructions are provided in the `coala-data-import` vignette -#' @seealso For information about segsites: \code{\link{segsites}} -#' @export -as.segsites <- function(data, ...) UseMethod("as.segsites") - -#' @export -as.segsites.default <- function(data, ...) { #nolint - stop("Unknown data format") -} - -#' @export -as.segsites.list <- function(data, ...) { #nolint - assert_that(all(vapply(data, is_segsites, logical(1)))) - data -} diff --git a/R/sumstat.R b/R/sumstat.R index cc4e5df..9c2624b 100644 --- a/R/sumstat.R +++ b/R/sumstat.R @@ -143,10 +143,7 @@ calc_sumstats_from_sim <- function(seg_sites, trees, files, model, #' @param model The coala model. The summary statistics present in this model #' will be calculated. The model should fit to the data, in particular #' regarding the number of loci and haploids. -#' @param segsites_list Either a list of \code{segsites} objects, or an object -#' that can be converted using \code{\link{as.segsites}}. It is possible -#' to specify additional argument for the conversion using the \code{...} -#' argument. +#' @param segsites_list A list of \code{segsites} objects #' @param tree_list Not yet implemented. #' @param trios If your model is using locus trios, then you #' can create these by combining individual loci. This is a list that defines @@ -155,8 +152,7 @@ calc_sumstats_from_sim <- function(seg_sites, trees, files, model, #' summary statistics is locus in the provided data that corresponds to the #' number. If three numbers are provided, the locus for calculation is created #' by combining the corresponding three loci from the given data. -#' @param ... Additional arguments that will be passed to -#' \code{\link{as.segsites}}. +#' @param ... Ignored #' @export #' @examples #' segsites <- create_segsites(matrix(c(1, 0, 0, @@ -195,7 +191,6 @@ calc_sumstats_from_data <- function(model, } if (!is.null(segsites_list)) { - segsites_list <- as.segsites(segsites_list, ...) if (!all(vapply(segsites_list, is_segsites, logical(1)))) { stop("Incorrect or missing data in list of segregating sites") } diff --git a/man/as.segsites.Rd b/man/as.segsites.Rd deleted file mode 100644 index 9d7208b..0000000 --- a/man/as.segsites.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/segsites.R -\name{as.segsites} -\alias{as.segsites} -\title{Convert genetic data to coala's internal format} -\usage{ -as.segsites(data, ...) -} -\arguments{ -\item{data}{The data object that is converted.} - -\item{...}{Additional arguments specific for the used package.} -} -\value{ -A list of segregating sites objects. -} -\description{ -This function can be used to convert the genomic data formats used in other -packages to calculate coala's segregating sites object. This is useful for -calculating the summary statistics of biological data using the -\code{\link{calc_sumstats_from_data}} function. -} -\details{ -Currently, only the package \pkg{PopGenome} is supported, see -\code{\link{as.segsites.GENOME}} for details. -} -\seealso{ -Further instructions are provided in the `coala-data-import` vignette - -For information about segsites: \code{\link{segsites}} -} diff --git a/man/calc_sumstats_from_data.Rd b/man/calc_sumstats_from_data.Rd index 913fa86..586809d 100644 --- a/man/calc_sumstats_from_data.Rd +++ b/man/calc_sumstats_from_data.Rd @@ -17,10 +17,7 @@ calc_sumstats_from_data( will be calculated. The model should fit to the data, in particular regarding the number of loci and haploids.} -\item{segsites_list}{Either a list of \code{segsites} objects, or an object -that can be converted using \code{\link{as.segsites}}. It is possible -to specify additional argument for the conversion using the \code{...} -argument.} +\item{segsites_list}{A list of \code{segsites} objects} \item{tree_list}{Not yet implemented.} @@ -32,8 +29,7 @@ summary statistics is locus in the provided data that corresponds to the number. If three numbers are provided, the locus for calculation is created by combining the corresponding three loci from the given data.} -\item{...}{Additional arguments that will be passed to -\code{\link{as.segsites}}.} +\item{...}{Ignored} } \description{ This function calculates a model's summary statistic from biological data. diff --git a/man/coal_model.Rd b/man/coal_model.Rd index 3cfb7e4..4813ad1 100644 --- a/man/coal_model.Rd +++ b/man/coal_model.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/model.R \name{coal_model} \alias{coal_model} +\alias{coalmodelpart} \title{Create a Coalescent Model} \usage{ coal_model(sample_size, loci_number = 0, loci_length = 1000, ploidy = 1) diff --git a/man/segsites.Rd b/man/segsites.Rd index af854f0..2ca5d97 100644 --- a/man/segsites.Rd +++ b/man/segsites.Rd @@ -111,9 +111,6 @@ get_positions(segsites) # segregating in these are automatically removed: segsites[1:2, 1:3] } -\seealso{ -For converting biological data to segsites: \code{\link{as.segsites}} -} \author{ Paul Staab } diff --git a/tests/testthat/test-import-popgenome.R b/tests/testthat/test-import-popgenome.R deleted file mode 100644 index a493483..0000000 --- a/tests/testthat/test-import-popgenome.R +++ /dev/null @@ -1,15 +0,0 @@ -context("Import PopGenome") - -test_that("importing PopGenome Data works", { - skip_if_not_installed("PopGenome") - data_pg <- create_popgenome_test_data() - - seg_sites <- as.segsites(data_pg) - expect_equal(length(seg_sites), 1) - expect_true(is_segsites(seg_sites[[1]])) - expect_equal(nrow(seg_sites[[1]]), 12) - - expect_false(is.null(get_positions(seg_sites[[1]]))) - expect_true(all(get_positions(seg_sites[[1]]) >= 0)) - expect_true(all(get_positions(seg_sites[[1]]) <= 1)) -})