Skip to content

Commit

Permalink
Version 1.4.2 accepted on CRAN.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaballench committed Jun 4, 2024
1 parent 23019f7 commit 53a1e7f
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 76 deletions.
24 changes: 13 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
Package: tbea
Title: Tools for Pre- And Post-Processing in Bayesian Evolutionary Analyses
Title: Pre- And Post-Processing in Bayesian Evolutionary Analyses
Version: 1.4.2
Authors@R: c(person("Gustavo A.", "Ballen", email = "gustavo.a.ballen@gmail.com", role = c("aut", "cre")),
person("Sandra", "Reinales", email = "spreinalesl@gmail.com", role = c("aut")))
Description: Package for Bayesian inference in phylogenetics and evolution.
It provides functions for prior specification in divergence time
estimation using fossils as well as other kinds of data. The package
Description: Functions are provided for prior specification in divergence time
estimation using fossils as well as other kinds of data. It
provides tools for interacting with the input and output of Bayesian
platforms in evolutionary biology such as BEAST2, MrBayes, RevBayes,
or MCMCTree.
The package implements a way to measure similarity between probability
density functions in the context of comparisons between prior and
platforms in evolutionary biology such as 'BEAST2', 'MrBayes', 'RevBayes',
or 'MCMCTree'.
It Implements a simple measure similarity between probability
density functions for comparing prior and
posterior Bayesian densities, as well as code for calculating the
combination of distributions using conflation. Tools for estimating the
origination time in collections of distributions using x-intercept and
stratigraphic intervals are also available.
combination of distributions using conflation of Hill (2008). Functions for estimating the
origination time in collections of distributions using the x-intercept (e.g., Draper and Smith, 1998) and
stratigraphic intervals (Marshall 2010) are also available.
Hill, T. 2008. "Conflations of probability distributions". Transactions of the American Mathematical Society, 363:3351-3372. <doi:10.48550/arXiv.0808.1808>,
Draper, N. R. and Smith, H. 1998. "Applied Regression Analysis". 1--706. Wiley Interscience, New York. <DOI:10.1002/9781118625590>,
Marshall, C. R. 2010. "Using confidence intervals to quantify the uncertainty in the end-points of stratigraphic ranges". Quantitative Methods in Paleobiology, 291--316. <DOI:10.1017/S1089332600001911>.
Depends: R (>= 3.5.0)
Imports: ape, Rfit, boot, graphics, stats, utils, coda
License: file LICENSE
Expand Down
14 changes: 4 additions & 10 deletions R/conflate.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
#' conflated PDF on the sequence of x values determined by
#' a number n of equidistant points between from and to.
#' @examples
#' \dontrun{
#' conflate(c("density_fun(x, 'dnorm', mean=0, sd=1)",
#' "density_fun(x, 'dnorm', mean=3, sd=1)"),
#' from=-4, to=4, n=101, add=TRUE, plot=TRUE)
#' curve(density_fun(x, 'dnorm', mean=0, sd=1), add=TRUE, col="red")
#' curve(density_fun(x, 'dnorm', mean=3, sd=1), add=TRUE, col="blue")
#'
#' \donttest{
#' conflated_normals <- conflate(c("density_fun(x, 'dnorm', mean=0, sd=1)",
#' "density_fun(x, 'dnorm', mean=3, sd=1)"),
#' from=-4, to=4, n=101, plot=FALSE)
Expand Down Expand Up @@ -60,7 +54,7 @@ conflate <- function(pdfs, plot = TRUE, from, to, n, add = FALSE) {
#' See the documentation for each individual distribution to call their parameters
#' adequately. Argument names and values should be used.
#' @examples
#' \dontrun{
#' \donttest{
#' c("density_fun(x, 'dnorm', mean=0, sd=1)",
#' "density_fun(x, 'dnorm', mean=-1, sd=1)",
#' "density_fun(x, 'dnorm', mean=1, sd=1)")
Expand Down Expand Up @@ -93,7 +87,7 @@ density_fun <- function(x, dist, ...) {
#' with densities / int(densities) in an appropriate
#' interval from--to
#' @examples
#' \dontrun{
#' \donttest{
#' conflated <- .str_conflate("density_fun(x, 'dnorm', mean=0, sd=1)", "density_fun(x, 'dnorm', mean=3, sd=1)", from = -1, to = 1)
#' }
#'
Expand Down Expand Up @@ -122,7 +116,7 @@ density_fun <- function(x, dist, ...) {
#' conflation but it is also useful for calculating a series
#' of x values of the conflated PDF from a sequence of x values
#' @examples
#' \dontrun{
#' \donttest{
#' conflated <- .str_conflate("density_fun(x, 'dnorm', mean=0, sd=1)", "density_fun(x, 'dnorm', mean=3, sd=1)", from = -1, to = 1)
#' }
#'
Expand Down
4 changes: 0 additions & 4 deletions R/crossplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
#'
#' @examples
#' \dontrun{
#' write.table(x=data.frame(par1=rnorm(1000), par2=rnorm(1000), par3=rnorm(1000),
#' par4=rnorm(1000), par5=rnorm(1000)), file="log1.tsv", row.names=FALSE)
#' write.table(x=data.frame(par1=rnorm(1000), par2=rnorm(1000), par3=rnorm(1000),
#' par4=rnorm(1000, mean=5), par5=rnorm(1000)), file="log2.tsv", row.names=FALSE)
#' crossplot(log1Path="log1.tsv", log2Path="log2.tsv", skip.char="#",
#' pattern="par", cols=NULL, bar.lty=1, bar.lwd=1,
#' identity.lty=2, identity.lwd=1,
Expand Down
2 changes: 1 addition & 1 deletion R/measureSimil.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#' @details Similarity is measured as the overlapping portion between two densities. It has a value between 0 and 1. The values of the vector rawData determine the behavior of the function and therefore attention must be paid to their consistence with the nature of arguments d1 and d2. Despite the function was designed in order to allow to quantify similarity between the posterior and the prior, this can be used to quantify any overlap between two given densities and for any other purpose.
#' @examples
#' \dontrun{
#' \donttest{
#' # Set seed and colors to use in plots in the order: Prior, posterior, and intersection
#' set.seed(1985)
#' colors <- c("red", "blue", "lightgray")
Expand Down
2 changes: 1 addition & 1 deletion R/stratCI.R
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ stratCI <- function(times, method, nparams, C, endpoint, confidence, quantile) {
if(output >= 1) {
return(output)
} else {
print("Impossible to calculate lower bound")
message("Impossible to calculate lower bound\n")
}
}

Expand Down
6 changes: 4 additions & 2 deletions R/summaryBrlen.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
#' first enclosed in a list
#'
#' @examples
#' \dontrun{
#' \donttest{
#' set.seed(1)
#' library(ape)
#' trl <- ape::rmtree(10, 4)
#' tpf <- topoFreq(unroot(trl), output="trees")
#' sumtrees <- summaryBrlen(tpf$trees, method = "median")
#' oldpar <- par(no.readonly = TRUE)
#' par(mfrow=c(1,3))
#' plot(sumtrees[[1]], type="unrooted", show.node.label=FALSE, cex=1.5)
#' plot(sumtrees[[2]], type="unrooted", show.node.label=FALSE, cex=1.5)
#' plot(sumtrees[[3]], type="unrooted", show.node.label=FALSE, cex=1.5)
#' par(mfrow=c(1,1))
#' par(oldpar)
#' }
#'
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/table2nexus.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' @examples
#' \dontrun{
#' # this will return the matrix to the console rather than to a file
#' table2nexus(path="../prototipos/morpho.csv", datatype="standard", header=FALSE, sep=",")
#' table2nexus(path="morpho.csv", datatype="standard", header=FALSE, sep=",")
#' }
#' @export
#' @importFrom utils read.delim
Expand Down
14 changes: 2 additions & 12 deletions R/tnt2newick.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,9 @@
#' @details This function has been tested for cases where only one tree is in the original tnt tree file. Please be careful with files containing multiple trees.
#'
#' @examples
#' # create a file with multiple trees tree in TNT format to convert to newick format
#' writeLines(
#' text = c(
#' "tread 'some comment'",
#' "(Taxon_A ((Taxon_B Taxon_C)(Taxon_D Taxon_E)))*",
#' "(Taxon_A (Taxon_B (Taxon_C (Taxon_D Taxon_E))))*",
#' "(Taxon_A (Taxon_C (Taxon_B (Taxon_D Taxon_E))));",
#' "proc-;"
#' ),
#' con = "someTrees.tre"
#' )
#' \dontrun{
#' tnt2newick(file = "someTrees.tre", return = TRUE)
#' file.remove("someTrees.tre")
#' }
#' @export

tnt2newick <- function(file, output = NULL, string = NULL, return = FALSE, subsetting = FALSE, name.sep = NULL){
Expand Down
1 change: 1 addition & 0 deletions R/topoFreq.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#' @examples
#' # tests
#' set.seed(1)
#' library(ape)
#' trl <- ape::rmtree(10, 4)
#' tpf <- topoFreq(ape::unroot(trl), output="trees")
#'
Expand Down
2 changes: 1 addition & 1 deletion R/xintercept.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#' ages <- ages[complete.cases(ages)] # remove NAs
#' ages <- ages[which(ages < 10)] # remove outliers
#'
#' \dontrun{
#' \donttest{
#' # Draper-Smith, OLS
#' draperSmithNormalX0 <- xintercept(x = ages, method = "Draper-Smith", alpha = 0.05, robust = FALSE)
#' # Draper-Smith, Robust fit
Expand Down
8 changes: 1 addition & 7 deletions man/conflate.Rd

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

4 changes: 0 additions & 4 deletions man/crossplot.Rd

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

2 changes: 1 addition & 1 deletion man/density_fun.Rd

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

2 changes: 1 addition & 1 deletion man/measureSimil.Rd

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

6 changes: 4 additions & 2 deletions man/summaryBrlen.Rd

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

2 changes: 1 addition & 1 deletion man/table2nexus.Rd

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

4 changes: 2 additions & 2 deletions man/tbea-package.Rd

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

14 changes: 2 additions & 12 deletions man/tnt2newick.Rd

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

1 change: 1 addition & 0 deletions man/topoFreq.Rd

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

2 changes: 1 addition & 1 deletion man/xintercept.Rd

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

5 changes: 3 additions & 2 deletions tests/testthat/test-tnt2newick.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# create some input tree and their expected outputs
# create some input tree and their expected outputs in the tempdir()
setwd(tempdir())

# create a file with multiple trees in TNT format to convert to newick format
writeLines(
Expand Down Expand Up @@ -53,6 +54,6 @@ test_that("number of name separators got completely replaced using name.sep", {
sum(sapply(gregexpr(pattern = "--", text = tnt2newick(file = "someTrees.tre", output = NULL, string = NULL, return = TRUE, subsetting = FALSE, name.sep = c("_", "--")), fixed=TRUE), function(i) sum(i > 0))))
})

# clean tesating files
# clean testing files
file.remove(dir(pattern = ".tre$"))
file.remove(dir(pattern = ".newick$"))

0 comments on commit 53a1e7f

Please sign in to comment.