diff --git a/NEWS.md b/NEWS.md index bec328b..8deffe6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,9 +2,10 @@ # phyloraster 2.1.0 -- added functions to compute full and tip branch lengths: 'species.tip.length()' and 'species.branch.length()' -- added new function to compute ED for each species +- added functions to compute full and tip branch lengths: 'species.tip.length()' and 'species.branch.length()' +- added new function to compute ED for each species: 'species.ed()' - fixed ED calculation for raster data +- added new tests for the new functions # phyloraster 2.0.1 diff --git a/R/delta.grid.R b/R/delta.grid.R index ca141e6..e5723c2 100644 --- a/R/delta.grid.R +++ b/R/delta.grid.R @@ -1,18 +1,16 @@ .delta.vec <- function(x) { - diff <- x[2] - x[1] # diference between metric in time 2 and 1 + diff <- x[2] - x[1] # difference between metric in time 2 and 1 } -#' Calculates the delta of spatialized diversity metrics (richness, -#' phylogenetic endemism, phylogenetic diversity, weighted endemism, -#' evolutionary distinctiveness) between different time periods +#' Delta of Diversity Metrics #' -#' @description Calculates the delta of spatialized diversity metrics +#' @description Calculates the difference of rasterized diversity metrics #' (richness, phylogenetic endemism, phylogenetic diversity, weighted endemism, -#' evolutionary distinctiveness) between different time periods. -#' @param r1 SpatRaster Spatialized diversity metrics for time 1 (e.g +#' evolutionary distinctiveness) between time periods. +#' @param r1 SpatRaster Rasterized diversity metrics for time 1 (e.g #' phylogenetic diversity in present). To calculate some diversity metrics for #' rasters see phyloraster::geo.phylo function. -#' @param r2 SpatRaster Spatialized diversity metrics for time 2 (e.g +#' @param r2 SpatRaster Rasterized diversity metrics for time 2 (e.g #' phylogenetic diversity in future). #' @param filename character. Output filename. #' @param ... additional arguments to be passed passed down from a calling diff --git a/R/df2rast.R b/R/df2rast.R index 254947b..ce4d977 100644 --- a/R/df2rast.R +++ b/R/df2rast.R @@ -8,9 +8,7 @@ #' @param ... additional arguments to be passed passed down from a calling #' function. #' @param CRS character. Description of the Coordinate Reference System -#' (map projection) in PROJ.4, WKT or authority:code notation. See crs. If -#' this argument is missing, and the x coordinates are within -360 .. 360 and -#' the y coordinates are within -90 .. 90, longitude/latitude is assigned +#' (map projection) in PROJ.4. #' @return SpatRaster #' @export #' @examples diff --git a/R/geo.phylo.R b/R/geo.phylo.R index 4567e88..7e97dcd 100644 --- a/R/geo.phylo.R +++ b/R/geo.phylo.R @@ -95,9 +95,9 @@ rast.sr <- function(x, filename = "", ...){ #' @references Williams, P.H., Humphries, C.J., Forey, P.L., Humphries, C.J. and #' VaneWright, R.I. (1994). Biodiversity, taxonomic relatedness, and endemism in #' conservation. In: Systematics and Conservation Evaluation (eds Forey PL, -#' Humphries CJ, Vane-Wright RI), p. 438. Oxford University Press, Oxford. +#' Humphries C.J., Vane-Wright RI), p. 438. Oxford University Press, Oxford. #' @references Crisp, M., Laffan, S., Linder, H. and Monro, A. (2001). Endemism -#' in theAustralian flora. Journal of Biogeography, 28, 183–198. +#' in the Australian flora. Journal of Biogeography, 28, 183–198. #' @references Isaac, N. J., Turvey, S. T., Collen, B., Waterman, C. and #' Baillie, J. E. (2007). Mammals on the EDGE: conservation priorities based on #' threat and phylogeny. PLoS ONE 2, e296. @@ -196,10 +196,10 @@ rast.sr <- function(x, filename = "", ...){ #' @references Williams, P.H., Humphries, C.J., Forey, P.L., Humphries, C.J. #' and VaneWright, R.I. (1994). Biodiversity, taxonomic relatedness, and #' endemism in conservation. In: Systematics and Conservation Evaluation -#' (eds Forey PL, Humphries CJ, Vane-Wright RI), p. 438. Oxford University +#' (eds Forey PL, Humphries C.J., Vane-Wright RI), p. 438. Oxford University #' Press, Oxford. #' @references Crisp, M., Laffan, S., Linder, H. and Monro, A. (2001). -#' Endemism in theAustralian flora. Journal of Biogeography, 28, 183–198. +#' Endemism in the Australian flora. Journal of Biogeography, 28, 183–198. #' @references Isaac, N. J., Turvey, S. T., Collen, B., Waterman, C. and #' Baillie, J. E. (2007). Mammals on the EDGE: conservation priorities based on #' threat and phylogeny. PLoS ONE 2, e296. @@ -323,7 +323,7 @@ geo.phylo <- function(x, tree, #' @references Williams, P.H., Humphries, C.J., Forey, P.L., Humphries, C.J., #' VaneWright, R.I. (1994). Biodiversity, taxonomic relatedness, and endemism #' in conservation. In: Systematics and Conservation Evaluation (eds Forey PL, -#' Humphries CJ, Vane-Wright RI), p. 438. Oxford University Press, Oxford. +#' Humphries C.J., Vane-Wright RI), p. 438. Oxford University Press, Oxford. #' @references Crisp, M., Laffan, S., Linder, H., Monro, A. (2001). Endemism #' in the Australian flora. Journal of Biogeography, 28, 183–198. #' diff --git a/cran-comments.md b/cran-comments.md index dcfbd3f..4fac98b 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -4,7 +4,11 @@ * This is a new release. -* \dontrun{} has been replaced with \donttest{}. +* added functions to compute full and tip branch lengths: 'species.tip.length()' and 'species.branch.length()' -* Comments in the example code lines have been removed. +* added new function to compute ED for each species: 'species.ed()' + +* fixed ED calculation for raster data + +* added new tests for the new functions diff --git a/man/delta.grid.Rd b/man/delta.grid.Rd index 5c55721..25c554f 100644 --- a/man/delta.grid.Rd +++ b/man/delta.grid.Rd @@ -2,18 +2,16 @@ % Please edit documentation in R/delta.grid.R \name{delta.grid} \alias{delta.grid} -\title{Calculates the delta of spatialized diversity metrics (richness, -phylogenetic endemism, phylogenetic diversity, weighted endemism, -evolutionary distinctiveness) between different time periods} +\title{Delta of Diversity Metrics} \usage{ delta.grid(r1, r2, filename = NULL, cores = 1, ...) } \arguments{ -\item{r1}{SpatRaster Spatialized diversity metrics for time 1 (e.g +\item{r1}{SpatRaster Rasterized diversity metrics for time 1 (e.g phylogenetic diversity in present). To calculate some diversity metrics for rasters see phyloraster::geo.phylo function.} -\item{r2}{SpatRaster Spatialized diversity metrics for time 2 (e.g +\item{r2}{SpatRaster Rasterized diversity metrics for time 2 (e.g phylogenetic diversity in future).} \item{filename}{character. Output filename.} @@ -28,9 +26,9 @@ function.} SpatRaster } \description{ -Calculates the delta of spatialized diversity metrics +Calculates the difference of rasterized diversity metrics (richness, phylogenetic endemism, phylogenetic diversity, weighted endemism, -evolutionary distinctiveness) between different time periods. +evolutionary distinctiveness) between time periods. } \details{ The two input rasters (r1 and r2) must have the same extent. diff --git a/man/df2rast.Rd b/man/df2rast.Rd index a442a63..de5e8de 100644 --- a/man/df2rast.Rd +++ b/man/df2rast.Rd @@ -12,9 +12,7 @@ and sites in rows. The first two columns must provide longitude and latitude, respectively.} \item{CRS}{character. Description of the Coordinate Reference System -(map projection) in PROJ.4, WKT or authority:code notation. See crs. If -this argument is missing, and the x coordinates are within -360 .. 360 and -the y coordinates are within -90 .. 90, longitude/latitude is assigned} +(map projection) in PROJ.4.} \item{...}{additional arguments to be passed passed down from a calling function.} diff --git a/man/dot-rast.geo.phylo.Rd b/man/dot-rast.geo.phylo.Rd index 57c5ee4..1492433 100644 --- a/man/dot-rast.geo.phylo.Rd +++ b/man/dot-rast.geo.phylo.Rd @@ -67,10 +67,10 @@ diversity. Biological conservation, 61(1), 1-10. Williams, P.H., Humphries, C.J., Forey, P.L., Humphries, C.J. and VaneWright, R.I. (1994). Biodiversity, taxonomic relatedness, and endemism in conservation. In: Systematics and Conservation Evaluation (eds Forey PL, -Humphries CJ, Vane-Wright RI), p. 438. Oxford University Press, Oxford. +Humphries C.J., Vane-Wright RI), p. 438. Oxford University Press, Oxford. Crisp, M., Laffan, S., Linder, H. and Monro, A. (2001). Endemism -in theAustralian flora. Journal of Biogeography, 28, 183–198. +in the Australian flora. Journal of Biogeography, 28, 183–198. Isaac, N. J., Turvey, S. T., Collen, B., Waterman, C. and Baillie, J. E. (2007). Mammals on the EDGE: conservation priorities based on diff --git a/man/geo.phylo.Rd b/man/geo.phylo.Rd index b1e5422..08b2656 100644 --- a/man/geo.phylo.Rd +++ b/man/geo.phylo.Rd @@ -83,11 +83,11 @@ diversity. Biological conservation, 61(1), 1-10. Williams, P.H., Humphries, C.J., Forey, P.L., Humphries, C.J. and VaneWright, R.I. (1994). Biodiversity, taxonomic relatedness, and endemism in conservation. In: Systematics and Conservation Evaluation -(eds Forey PL, Humphries CJ, Vane-Wright RI), p. 438. Oxford University +(eds Forey PL, Humphries C.J., Vane-Wright RI), p. 438. Oxford University Press, Oxford. Crisp, M., Laffan, S., Linder, H. and Monro, A. (2001). -Endemism in theAustralian flora. Journal of Biogeography, 28, 183–198. +Endemism in the Australian flora. Journal of Biogeography, 28, 183–198. Isaac, N. J., Turvey, S. T., Collen, B., Waterman, C. and Baillie, J. E. (2007). Mammals on the EDGE: conservation priorities based on diff --git a/man/geo.phylo.ses.Rd b/man/geo.phylo.ses.Rd index 992ed21..e6edb52 100644 --- a/man/geo.phylo.ses.Rd +++ b/man/geo.phylo.ses.Rd @@ -103,7 +103,7 @@ terra::plot(tses) Williams, P.H., Humphries, C.J., Forey, P.L., Humphries, C.J., VaneWright, R.I. (1994). Biodiversity, taxonomic relatedness, and endemism in conservation. In: Systematics and Conservation Evaluation (eds Forey PL, -Humphries CJ, Vane-Wright RI), p. 438. Oxford University Press, Oxford. +Humphries C.J., Vane-Wright RI), p. 438. Oxford University Press, Oxford. Crisp, M., Laffan, S., Linder, H., Monro, A. (2001). Endemism in the Australian flora. Journal of Biogeography, 28, 183–198. diff --git a/tests/testthat/test-geo.phylo.R b/tests/testthat/test-geo.phylo.R index 6bdf8c3..1565496 100644 --- a/tests/testthat/test-geo.phylo.R +++ b/tests/testthat/test-geo.phylo.R @@ -162,8 +162,8 @@ test_that("names are reordened in the function geo.phylo", { # tests expect(geo.phylo(data$x, tree, #range.BL = area.branch$range.BL, - inv.R = inv.R, - edge.path = data$edge.path[sample(1:nrow(data$edge.path)),], + inv.R = inv.R, + edge.path = data$edge.path[sample(1:nrow(data$edge.path)),], branch.length = data$branch.length, n.descen = data$n.descendants), ok = T) diff --git a/vignettes/phyloraster-vignette.Rmd b/vignettes/phyloraster-vignette.Rmd index a2d2ca3..187409b 100644 --- a/vignettes/phyloraster-vignette.Rmd +++ b/vignettes/phyloraster-vignette.Rmd @@ -95,7 +95,7 @@ library(phylobase) ## Data processing {#data} -In the step of pre processing, we offer support to manipulate matrices, +In the step of pre-processing, we offer support to manipulate matrices, shapefiles, rasters, and phylogenetic trees. In the processing step, we provide functions to calculate Faith's phylogenetic diversity (Faith, 1992), phylogenetic endemism (Rosauer et al., 2009), @@ -410,7 +410,7 @@ plot(t) - **Function** `delta.grid` The package also brings the function `delta.grid` that allows you to calculate -the difference between spatialized diversity metrics between two different times. +the difference between rasterized diversity metrics between two different times. This function would allow assessing how species richness varies between different times, which could be useful in a climate change scenario. For example, imagine that we currently have 33 tree frog species of the @@ -474,7 +474,7 @@ Gotelli, N. J., and McCabe, D. J. Species co-occurrence: A meta-analysis of J. M. Diamond's assembly rules model. Ecology, 83(8), 2091--2096. -[https://doi.org/10.1890/0012-9658(2002)083[2091:SCOAMA]2.0.CO;2](https://doi.org/10.1890/0012-9658(2002)083%5B2091:SCOAMA%5D2.0.CO;2){.uri} +<https://doi.org/10.1890/0012-9658(2002)083%5B2091:SCOAMA%5D2.0.CO;2> Gotelli, N. J., and Ulrich, W. (2012).