diff --git a/README.html b/README.html deleted file mode 100644 index e547021c..00000000 --- a/README.html +++ /dev/null @@ -1,666 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - -Species-Habitat Associations in R is a R
package to analyze species-habitat associations. Therefore, information about the location of the species is needed (as a point pattern) and about the environmental conditions (as a raster map). In order to analyse the data for significant habitat associations either the location data or the environmental data is randomized n-times. Then, counts within the habitats are compared between the randomized data and the observed data. Positive or negative associations are present if the observed counts is higher or lower than the randomized counts (using quantile thresholds). Methods are mainly described in Plotkin et al. (2000), Harms et al. (2001) and Wiegand & Moloney (2014). shar is mainly based on the spatstat
(Baddeley et al. 2015) and raster
(Hijmans 2017) package.
You can install the released version of shar from CRAN with:
- -And the development version from GitHub with:
- -shar comes with build-in example data sets. species_a
and species_b
are examplary location of species, e.g. trees, as ppp
-objects from the spatstat
package. landscape
contains examplary continious environmental data. However, all methods depend on discrete data. Therefore we need to classify the data first.
There are two possibilities to randomize the environmental data, both described in Harms et al. (2001). The first shifts the habitat map in all 4 cardinal directions around a torus. The second one assigns the habitat values to an empty map using a random walk algorithm. Both functions return a list with randomized rasters and the observed one. For more information on the methods, please click here.
-torus_trans <- translate_raster(raster = landscape_classified, verbose = FALSE)
-
-random_walk <- randomize_raster(raster = landscape_classified, n_random = 19, verbose = FALSE)
To randomize the point pattern, either use the Gamma test described by Plotkin et al. (2000) or pattern reconstruction (Tscheschel & Stoyan 2006).
-gamma_test <- fit_point_process(pattern = species_a, process = "cluster", n_random = 19, verbose = FALSE)
-
-reconstruct <- reconstruct_pattern(pattern = species_b, max_runs = 500, n_random = 19, verbose = FALSE) # takes some time
Of coures, there are several utility functions. For example, you can plot a randomized pattern or calculate the differences between the observed pattern and the randomized patterns (using summary functions).
- - - -## [1] 0.05466079 0.05691795 0.07273102 0.05258555 0.04835521 0.03688952 0.04172061 0.05272703 0.06877212 0.05079050 0.04569044
-## [12] 0.07600530 0.04997626 0.04574796 0.05884596 0.06559402 0.06293930 0.06222483 0.04067297
-
-The data was created that species_a
has a negative association to habitat 4 and species_b
has a positive association to habitat 5. At one point a posititive association to one habitat leads consequently to a negative association to another habitat (and vice versa). All this can be seen in the results.
## > Input: randomized raster | Quantile thresholds: negative < 0.025 - positive > 0.975
-
-## habitat count lo hi significance
-## 1 1 10 0 8 positive
-## 2 2 14 8 24 n.s.
-## 3 3 30 14 29 positive
-## 4 4 0 10 26 negative
-## 5 5 14 4 17 n.s.
-
-
-## > Input: randomized point pattern | Quantile thresholds: negative < 0.025 - positive > 0.975
-
-## habitat count lo hi significance
-## 1 1 7 6.80 20.65 n.s.
-## 2 2 20 48.90 65.00 negative
-## 3 3 31 52.90 75.00 negative
-## 4 4 33 34.90 56.75 negative
-## 5 5 109 14.45 34.00 positive
-
-Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. London:Chapman and Hall/CRC Press, 2015. http://www.crcpress.com/Spatial-Point-Patterns-Methodology-and-Applications-with-R/Baddeley-Rubak-Turner/9781482210200/
-Harms, K. E., Condit, R., Hubbell, S. P., & Foster, R. B. (2001). Habitat associations of trees and shrubs in a 50-ha neotropical forest plot. Journal of Ecology, 89(6), 947-959.
-Hijmans, R. J. (2017). raster: Geographic Data Analysis and Modeling. R package version 2.6-7. https://CRAN.R-project.org/package=raster
-Plotkin, J. B., Potts, M. D., Leslie, N., Manokaran, N., LaFrankie, J. V., & Ashton, P. S. (2000). Species-area curves, spatial aggregation, and habitat specialization in tropical forests. Journal of Theoretical Biology, 207(1), 81-99.
-Tscheschel, A., & Stoyan, D. (2006). Statistical reconstruction of random point patterns. Computational Statistics and Data Analysis, 51(2), 859-871.
-Wiegand, T., & Moloney, K. A. (2014). Handbook of spatial point-pattern analysis in ecology. Boca Raton: Chapman and Hall/CRC Press.
- - - diff --git a/docs/articles/background.html b/docs/articles/background.html index 735ac7f3..a720810d 100644 --- a/docs/articles/background.html +++ b/docs/articles/background.html @@ -81,7 +81,7 @@background.Rmd
publication_record.Rmd
reconstruct_multiple_patterns.Rmd
In case you want to reconstruct several patterns at once (e.g. for different points in time if repeated censuses are available), you can use the following code.
- +In case you want to only create the spatial characteristics, this is straightforward using lapply()
.
# create list with patterns
-list_pattern <- list(species_a, species_b)
-
-# reconstruct all patterns in list
-result <- lapply(list_pattern, function(x) reconstruct_pattern(pattern = x,
- n_random = 3,
- verbose = FALSE))
# create list with patterns
+list_pattern <- list(species_a, species_b)
+
+# reconstruct all patterns in list
+result <- lapply(list_pattern, function(x) reconstruct_pattern(pattern = x,
+ n_random = 3,
+ verbose = FALSE))
The result will be a nested list including all m randomization (including the observed pattern) of the n provided input patterns.
- +## [[1]]
-## [1] 0.04799855 0.06070875 0.05544398
+## [1] 0.05362194 0.06927709 0.05838513
##
## [[2]]
-## [1] 0.03580434 0.03500364 0.03510883
+## [1] 0.03392639 0.02950383 0.03060779
Another possible would be to first reconstruct n times the spatial characteristics and afterwards reconstruct the marks m times for each of the n spatial reconstructions.
Firstly, reconstruct only the spatial characteristics n times. The observed pattern is not needed in this case, so you can put return_input = FALSE
.
# reconstruct spatial strucutre
-reconstructed_pattern <- reconstruct_pattern(species_a,
- n_random = 3,
- return_input = FALSE,
- verbose = FALSE)
# reconstruct spatial strucutre
+reconstructed_pattern <- reconstruct_pattern(species_a,
+ n_random = 3,
+ return_input = FALSE,
+ verbose = FALSE)
Secondly, to reconstruct the (numeric) marks of the observed pattern for each of the spatially reconstructed patterns, just use lapply()
in combination with reconstruct_marks()
.
# get only selected marks of input (numeric marks)
-species_a_marks <- spatstat::subset.ppp(species_a, select = dbh)
-
-# reconstruct marks 3 times for each input pattern
-result_marks <- lapply(reconstructed_pattern,
- function(x) reconstruct_marks(pattern = x,
- marked_pattern = species_a_marks,
- n_random = 3, verbose = FALSE))
# get only selected marks of input (numeric marks)
+species_a_marks <- spatstat::subset.ppp(species_a, select = dbh)
+
+# reconstruct marks 3 times for each input pattern
+result_marks <- lapply(reconstructed_pattern,
+ function(x) reconstruct_marks(pattern = x,
+ marked_pattern = species_a_marks,
+ n_random = 3, verbose = FALSE))
Again, the result is a nested list with the same dimensions as provided input patterns and reconstructions.
-# get energy
-lapply(result_marks, function(x) calculate_energy(pattern = x,
- method = "marks", verbose = FALSE))
# get energy
+lapply(result_marks, function(x) calculate_energy(pattern = x,
+ method = "marks", verbose = FALSE))
## $randomized_1
-## [1] 0.01828473 0.01967240 0.01984451
+## [1] 0.01924850 0.01956473 0.01998020
##
## $randomized_2
-## [1] 0.01981852 0.01979014 0.01955417
+## [1] 0.01973147 0.01984389 0.01905541
##
## $randomized_3
-## [1] 0.01946311 0.01931315 0.01995718
+## [1] 0.01973478 0.01980956 0.01993697