Skip to content

Commit 7bf338c

Browse files
bblondercran-robot
authored andcommitted
version 3.1.1
1 parent 49a11ca commit 7bf338c

25 files changed

+2169
-95
lines changed

DESCRIPTION

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ Type: Package
33
Title: High Dimensional Geometry, Set Operations, Projection, and
44
Inference Using Kernel Density Estimation, Support Vector
55
Machines, and Convex Hulls
6-
Version: 3.1.0
7-
Date: 2022-11-14
6+
Version: 3.1.1
7+
Date: 2023-05-05
88
Author: Benjamin Blonder, with contributions from Cecina Babich Morrow, David J. Harris, Stuart Brown, Gregoire Butruille, Alex Laini, and Dan Chen
99
Maintainer: Benjamin Blonder <[email protected]>
1010
Description: Estimates the shape and volume of high-dimensional datasets and performs set operations: intersection / overlap, union, unique components, inclusion test, and hole detection. Uses stochastic geometry approach to high-dimensional kernel density estimation, support vector machine delineation, and convex hull generation. Applications include modeling trait and niche hypervolumes and species distribution modeling.
1111
License: GPL-3
12-
Depends: Rcpp, methods, R (>= 3.0.2)
12+
Depends: Rcpp, methods, R (>= 3.5.0)
1313
LinkingTo: Rcpp, RcppArmadillo, progress
1414
Imports: raster, maps, MASS, geometry, ks, hitandrun, pdist,
1515
fastcluster, compiler, e1071, progress, mvtnorm, data.table,
16-
rgeos, sp, foreach, doParallel, parallel, ggplot2, pbapply,
16+
terra, sp, foreach, doParallel, parallel, ggplot2, pbapply,
1717
palmerpenguins, purrr, dplyr, caret
1818
Suggests: rgl, magick, alphahull, knitr, rmarkdown, gridExtra
1919
NeedsCompilation: yes
2020
RoxygenNote: 7.1.1
2121
VignetteBuilder: knitr
22-
Packaged: 2022-11-14 17:13:33 UTC; benjaminblonder
22+
Packaged: 2023-05-06 05:04:48 UTC; benjaminblonder
2323
Repository: CRAN
24-
Date/Publication: 2022-11-16 03:50:10 UTC
24+
Date/Publication: 2023-05-07 02:30:02 UTC

MD5

+24-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
b3c29beecd3002bc246f2b8e77305be9 *DESCRIPTION
2-
ccbf0614181f0692aad5ab4df7ed14c2 *NAMESPACE
1+
0d6de4c4af6d3a5200b94a538cfa129d *DESCRIPTION
2+
70c531eb2b80940eda0d842d1fed277c *NAMESPACE
33
2504fce4086aa1ded92a46ac12456534 *R/AllClassDefinitions.R
44
d780110ab1104663ea8469eb6a9badeb *R/RcppExports.R
55
b4115c5719f6fd3598630927a8422d2d *R/bootstrap.R
@@ -41,8 +41,8 @@ c542a80e39002d2da0a488ae459fc19d *R/hypervolume_n_occupancy_test.R
4141
d1ddfce7ef86939997e92453d27bbdb9 *R/hypervolume_overlap_statistics.R
4242
1145a625aeb698fee23ff3dc0d9a2b0c *R/hypervolume_overlap_test.R
4343
91ff36480815ff70ad1b10adcdba2b58 *R/hypervolume_permute.R
44-
7cd85e2e9d9f74ca8657b4775d70210e *R/hypervolume_plot.R
45-
784dea230abe03a08a3bd2c5dec8095d *R/hypervolume_project.R
44+
57e87c49a4d3ce92e00cdcfd3de0667a *R/hypervolume_plot.R
45+
0793a7c9d3087691113f2398bf83860b *R/hypervolume_project.R
4646
a31b43a4bdc935d4fe2e79dfd60b985f *R/hypervolume_prune.R
4747
782970edb735a7f2928115472ffdb76e *R/hypervolume_redundancy.R
4848
3061bfa697218aa8f3e3e00b61cd8811 *R/hypervolume_resample.R
@@ -57,7 +57,7 @@ deb303165d43ffbc43e1030a02c87826 *R/hypervolume_to_data_frame.R
5757
1ad2e7de8bceb65df4adcc0ead394c9c *R/hypervolume_variable_importance.R
5858
7ed8781e830d3584d99cabd7b0ed891a *R/k_split.R
5959
1805b8420a6e91bbfafc37f42029e5b6 *R/kdtree_build.R
60-
64f892dd5b05d659356ebd51d2b208d1 *R/n_occupancy_function.R
60+
0dde245b3290ed41fd3816e181a75b99 *R/n_occupancy_function.R
6161
f709b7ae6e69ba9d4d025e8c95605001 *R/occupancy_bootstrap_gof.R
6262
9c1cfc6c0ae8c45a2b515486c06444ac *R/occupancy_filter.R
6363
1856237f6c0e70c259e6f0d593187acc *R/occupancy_to_intersection.R
@@ -71,8 +71,10 @@ e4fecfe83b3063870f86086da4ecdcba *R/sampling_bias_bootstrap.R
7171
7f5e758235d6c25201334b843e72496c *R/to_hv_list.R
7272
68e336b162fe81230a673ca9a78b8c27 *R/volume_calculation.R
7373
468a1141d8ba6ed60cdd6c00f814c071 *R/weight_data.R
74-
612f191fc03281795a412fb2fde3eed8 *build/partial.rdb
75-
3876d25e73ace1291ed1638688a93c99 *build/vignette.rds
74+
6c5a43d81902e6475a4adeeced7e04d9 *build/partial.rdb
75+
57b54f08ac8dab6009f548a4942fd6c8 *build/vignette.rds
76+
6a7313fabc82ac45b1f3ff723e5fe771 *data/acacia_pinus.rda
77+
c99bf5e78dcd9bbc8177675ea3c9fbe0 *data/circles.rda
7678
cceabacac136caf05eb2f8091cc48e06 *data/morphSnodgrassHeller.txt.gz
7779
19c6798aede220cac653d5afaa7eee6b *data/quercus.txt.gz
7880
a4ab66decef1fe807c2f25d0950479d6 *demo/00Index
@@ -81,9 +83,14 @@ a4ab66decef1fe807c2f25d0950479d6 *demo/00Index
8183
ac1cd8bc3020a4ee83e85780b7076ebb *demo/quercus.R
8284
bb30f1fa3dfd17aff427a2ce44b78d77 *inst/doc/Hypervolume-Resampling.R
8385
eb67de4b7bf54b941ee015dbe2b60589 *inst/doc/Hypervolume-Resampling.Rmd
84-
5a431b8bfc5df89b87d7bc4bc420ffef *inst/doc/Hypervolume-Resampling.html
86+
5809f8d8b152e598d4065210d7cacffe *inst/doc/Hypervolume-Resampling.html
87+
d5f3a7681880433ea103a78ad05e9bc1 *inst/doc/occupancy.R
88+
929b10840b6fdfa9b34430f5a962a823 *inst/doc/occupancy.Rmd
89+
7437e28c8bd9738e3e16f1da19cb87b2 *inst/doc/occupancy.html
8590
bbbc147e6337bd91c682a5a2ba55ea00 *man/Hypervolume-class.Rd
8691
fa994ea935b4b6bf268102df0fe0b384 *man/HypervolumeList-class.Rd
92+
bda089af6f38bac40309dab60617bfd5 *man/acacia_pinus.Rd
93+
91ef1a1de6b4848ebe8686f47f4771ca *man/circles.Rd
8794
6b378f5876567eaf44498f06a32215da *man/copy_param_hypervolume.Rd
8895
f3d90b840f0300b7497e037b896780ec *man/estimate_bandwidth.Rd
8996
ab0b2982451570f502235f7b02a8c1ad *man/expectation_ball.Rd
@@ -138,17 +145,23 @@ ff0fad298cc15ea6dbe03e77ce4cbb1d *man/occupancy_to_intersection.Rd
138145
38340b4ef01aa6df59455c3d534982da *man/occupancy_to_union.Rd
139146
16e41e6f4368949085aacde508f1a573 *man/occupancy_to_unshared.Rd
140147
253cca7e64a009600f6438a995553363 *man/padded_range.Rd
141-
d6610543949a85584bd1cc557a5e00e7 *man/plot.Hypervolume.Rd
148+
fab4fb95a4d861fa0543c60858e36f61 *man/plot.Hypervolume.Rd
142149
d32e44fe6089d32345856a5528e9029d *man/print.Hypervolume.Rd
143150
3ac8ccf723ac0b606ed39afa3eacfb05 *man/quercus.Rd
144151
520687ae929e59120ed7d0ff7fee0469 *man/summary.Hypervolume.Rd
145152
1a96a16d12ce78396951d5d96ca87630 *man/to_hv_list.Rd
146153
f893cf1ba3d94b14e199a7bffb1c74b8 *man/weight_data.Rd
147154
c5c84d3f314d36078d1d4f5de07f064d *src/KDTree.h
148-
fdcb2e0c2502ed804ae55e75cf88055c *src/Makevars
149-
fdcb2e0c2502ed804ae55e75cf88055c *src/Makevars.win
155+
2a6f9e9e044a78154d3cfda5936d6f48 *src/Makevars
156+
2a6f9e9e044a78154d3cfda5936d6f48 *src/Makevars.win
150157
64a5b03557cf150267c610319fcfe80d *src/MyHeaps.h
151158
67f7d7071fc387ed22c205b7ec41655b *src/RcppExports.cpp
152159
f6e83b70c0ea08470d52f64d6d59177b *src/convert.cpp
153160
4db2ff4d41eea52eaa9e5c084d5016c6 *src/fastPdist2.cpp
154161
eb67de4b7bf54b941ee015dbe2b60589 *vignettes/Hypervolume-Resampling.Rmd
162+
1459c102b8747af3e912993320169a35 *vignettes/g1.png
163+
8115abb6dc324950838b59cce4755041 *vignettes/g2.png
164+
ed2a4c20e3a9ff42a10bed6abeeaf2e0 *vignettes/g3.png
165+
d15912fedc532b96d8085e2429e2729b *vignettes/g4.png
166+
929b10840b6fdfa9b34430f5a962a823 *vignettes/occupancy.Rmd
167+
95416fdb099e0de1128bb81838476f90 *vignettes/simulation_results.png

NAMESPACE

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#todo: remove sp/raster dependences
2+
13
useDynLib(hypervolume)
24

35
export(
@@ -125,15 +127,15 @@ import(palmerpenguins)
125127
#import(alphahull)
126128
#import(concaveman)
127129

128-
importFrom("raster","raster", "getValues","values","extent","rasterToPolygons","rasterize")
130+
#importFrom("raster","raster", "getValues","values","extent","rasterToPolygons","rasterize")
129131
importFrom("grDevices", "col2rgb", "rainbow", "rgb", "hsv", "rgb2hsv")
130132
importFrom("graphics", ".filled.contour", "axis", "box", "contour","par", "plot", "points", "text","lines")
131133
importFrom("stats", "cor", "cutree", "dist", "dnorm", "na.omit", "pgamma", "rmultinom", "rnorm", "runif", "sd", "median", "quantile","rbinom", "p.adjust", "predict", "var", "weighted.mean", "aggregate")
132134
importFrom("utils", "data", "head", "write.table", "str", "combn", "read.table")
133135
importFrom("maps", "map")
134136
importFrom("graphics", "abline", "legend", "mtext")
135137
importFrom("utils", "str", "combn")
136-
importFrom("rgeos","gBuffer")
138+
importFrom("terra","buffer","values","rast","rasterize","as.polygons","ext")
137139
importFrom("purrr","reduce")
138140
importFrom("caret","findLinearCombos")
139141

R/hypervolume_plot.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ do_outline_alpha <- function(rp, alpha)
1313

1414
do_outline_ball <- function(rp, radius)
1515
{
16-
gb = rgeos::gBuffer(sp::SpatialPoints(rp), quadsegs=2, width=radius)
16+
gb = terra::buffer(sp::SpatialPoints(rp), quadsegs=2, width=radius)
1717
return(gb)
1818
}
1919

@@ -23,13 +23,13 @@ do_outline_raster <- function(pts,res)
2323

2424
pr <- padded_range(pts,multiply.interval.amount=0.25)
2525

26-
e <- extent(t(pr))
26+
e <- terra::ext(pr[1,1], pr[2,1], pr[1,2], pr[2,2])
2727

28-
r <- raster::raster(e, ncol=res, nrow=res)
28+
r <- terra::rast(e, ncols=res, nrows=res)
2929

30-
x <- raster::rasterize(pts, r, rep(1, nrow(pts)), fun=mean,background=NA)
30+
x <- terra::rasterize(pts, r, rep(1, nrow(pts)), fun=mean,background=NA)
3131

32-
w <- raster::rasterToPolygons(x,dissolve=TRUE)
32+
w <- terra::as.polygons(x,dissolve=TRUE)
3333

3434
return(w)
3535
}
@@ -64,7 +64,7 @@ plot.HypervolumeList <- function(x,
6464
contour.alphahull.alpha=0.25,
6565
contour.ball.radius.factor=1,
6666
contour.kde.level=1e-4,
67-
contour.raster.resolution=100,
67+
contour.raster.resolution=20,
6868
show.centroid=TRUE, cex.centroid=2,
6969
colors=rainbow(floor(length(x@HVList)*1.5),alpha=0.8),
7070
point.alpha.min=0.2, point.dark.factor=0.5,

R/hypervolume_project.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
hypervolume_project <- function(hv, rasters, type = "probability",
22
verbose = TRUE, ...) {
3-
raster.values = data.frame(raster::getValues(rasters))
3+
raster.values = data.frame(terra::values(rasters))
44
if (type == "probability") {
55
projected.values <- hypervolume_estimate_probability(hv = hv,
66
points = raster.values,

R/n_occupancy_function.R

+12-10
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ n_occupancy_function <- function(hv_list, classification = NULL, method = "subsa
1313
}
1414
}
1515

16-
# get random state from global environment
17-
old_state <- get0(".Random.seed", envir = .GlobalEnv, inherits = FALSE)
18-
19-
16+
2017
if(!is.null(seed)){
18+
# get random state from global environment
19+
old_state <- get0(".Random.seed", envir = .GlobalEnv, inherits = FALSE)
20+
2121
set.seed(seed)
22+
23+
on.exit({
24+
# restore random state
25+
if (!is.null(old_state)) {
26+
assign(".Random.seed", old_state, envir = .GlobalEnv, inherits = FALSE)
27+
}
28+
})
29+
2230
}
2331

24-
on.exit({
25-
# restore random state
26-
if (!is.null(old_state)) {
27-
assign(".Random.seed", old_state, envir = .GlobalEnv, inherits = FALSE)
28-
}
29-
})
3032

3133

3234
# store some properties of the hypervolumes stored in hv_list:

build/partial.rdb

2 Bytes
Binary file not shown.

build/vignette.rds

40 Bytes
Binary file not shown.

data/acacia_pinus.rda

278 KB
Binary file not shown.

data/circles.rda

30 KB
Binary file not shown.

inst/doc/Hypervolume-Resampling.html

+55-56
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@
2929
</script>
3030

3131
<style type="text/css">
32-
code{white-space: pre-wrap;}
33-
span.smallcaps{font-variant: small-caps;}
34-
span.underline{text-decoration: underline;}
35-
div.column{display: inline-block; vertical-align: top; width: 50%;}
36-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
37-
ul.task-list{list-style: none;}
38-
</style>
32+
code{white-space: pre-wrap;}
33+
span.smallcaps{font-variant: small-caps;}
34+
span.underline{text-decoration: underline;}
35+
div.column{display: inline-block; vertical-align: top; width: 50%;}
36+
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
37+
ul.task-list{list-style: none;}
38+
</style>
3939

4040

4141

4242
<style type="text/css">
43-
code {
44-
white-space: pre;
45-
}
46-
.sourceCode {
47-
overflow: visible;
48-
}
43+
code {
44+
white-space: pre;
45+
}
46+
.sourceCode {
47+
overflow: visible;
48+
}
4949
</style>
5050
<style type="text/css" data-origin="pandoc">
5151
pre > code.sourceCode { white-space: pre; position: relative; }
@@ -63,55 +63,54 @@
6363
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
6464
}
6565
pre.numberSource code
66-
{ counter-reset: source-line 0; }
66+
{ counter-reset: source-line 0; }
6767
pre.numberSource code > span
68-
{ position: relative; left: -4em; counter-increment: source-line; }
68+
{ position: relative; left: -4em; counter-increment: source-line; }
6969
pre.numberSource code > span > a:first-child::before
70-
{ content: counter(source-line);
71-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
72-
border: none; display: inline-block;
73-
-webkit-touch-callout: none; -webkit-user-select: none;
74-
-khtml-user-select: none; -moz-user-select: none;
75-
-ms-user-select: none; user-select: none;
76-
padding: 0 4px; width: 4em;
77-
color: #aaaaaa;
78-
}
79-
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
70+
{ content: counter(source-line);
71+
position: relative; left: -1em; text-align: right; vertical-align: baseline;
72+
border: none; display: inline-block;
73+
-webkit-touch-callout: none; -webkit-user-select: none;
74+
-khtml-user-select: none; -moz-user-select: none;
75+
-ms-user-select: none; user-select: none;
76+
padding: 0 4px; width: 4em;
77+
color: #aaaaaa;
78+
}
79+
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
8080
div.sourceCode
81-
{ }
81+
{ }
8282
@media screen {
8383
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
8484
}
85-
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
86-
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
87-
code span.at { color: #7d9029; } /* Attribute */
88-
code span.bn { color: #40a070; } /* BaseN */
89-
code span.bu { } /* BuiltIn */
90-
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
91-
code span.ch { color: #4070a0; } /* Char */
92-
code span.cn { color: #880000; } /* Constant */
93-
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
94-
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
95-
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
96-
code span.dt { color: #902000; } /* DataType */
97-
code span.dv { color: #40a070; } /* DecVal */
98-
code span.er { color: #ff0000; font-weight: bold; } /* Error */
99-
code span.ex { } /* Extension */
100-
code span.fl { color: #40a070; } /* Float */
101-
code span.fu { color: #06287e; } /* Function */
102-
code span.im { } /* Import */
103-
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
104-
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
105-
code span.op { color: #666666; } /* Operator */
106-
code span.ot { color: #007020; } /* Other */
107-
code span.pp { color: #bc7a00; } /* Preprocessor */
108-
code span.sc { color: #4070a0; } /* SpecialChar */
109-
code span.ss { color: #bb6688; } /* SpecialString */
110-
code span.st { color: #4070a0; } /* String */
111-
code span.va { color: #19177c; } /* Variable */
112-
code span.vs { color: #4070a0; } /* VerbatimString */
113-
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
114-
85+
code span.al { color: #ff0000; font-weight: bold; }
86+
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; }
87+
code span.at { color: #7d9029; }
88+
code span.bn { color: #40a070; }
89+
code span.bu { color: #008000; }
90+
code span.cf { color: #007020; font-weight: bold; }
91+
code span.ch { color: #4070a0; }
92+
code span.cn { color: #880000; }
93+
code span.co { color: #60a0b0; font-style: italic; }
94+
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; }
95+
code span.do { color: #ba2121; font-style: italic; }
96+
code span.dt { color: #902000; }
97+
code span.dv { color: #40a070; }
98+
code span.er { color: #ff0000; font-weight: bold; }
99+
code span.ex { }
100+
code span.fl { color: #40a070; }
101+
code span.fu { color: #06287e; }
102+
code span.im { color: #008000; font-weight: bold; }
103+
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; }
104+
code span.kw { color: #007020; font-weight: bold; }
105+
code span.op { color: #666666; }
106+
code span.ot { color: #007020; }
107+
code span.pp { color: #bc7a00; }
108+
code span.sc { color: #4070a0; }
109+
code span.ss { color: #bb6688; }
110+
code span.st { color: #4070a0; }
111+
code span.va { color: #19177c; }
112+
code span.vs { color: #4070a0; }
113+
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; }
115114
</style>
116115
<script>
117116
// apply pandoc div.sourceCode style to pre.sourceCode instead

0 commit comments

Comments
 (0)