-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
185 lines (138 loc) · 6.75 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.width = 10,
fig.height = 8
)
library(bisonpictools)
```
# bisonpictools
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/poissonconsulting/bisonpictools/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/bisonpictools/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/bisonpictools/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/bisonpictools)
<!-- badges: end -->
The goal of `bisonpictools` is to facilitate the visualization and analysis of camera trap data for wood bison herds.
The package includes functions to check the correct formatting of data, visualize the data, manipulate and analyse the data using a complex custom-built Bayesian model, and generate predictions of abundances, survival and fecundity rates, and population ratios.
The data are analyzed using an Bayesian Integrated Population Model, which combines a stage-structured population projection matrix model with multiple sources of data into a unified framework, allowing for estimates of age-sex class ratios, population vital rates, and abundances, while maintaining the correct propagation of uncertainty.
See the [analytical methods](https://poissonconsulting.github.io/bisonpictools/articles/bisonpic-methods.html) vignette for more detail on the modeling approach.
## bisonpic Suite
`bisonpictools` is one of three packages in the [bisonpic suite](https://github.com/poissonconsulting/bisonpicsuite) of tools.
- [`bisonpictools`](https://github.com/poissonconsulting/bisonpictools)
- [`shinybisonpic`](https://github.com/poissonconsulting/shinybisonpic)
- [`runbisonpic`](https://github.com/poissonconsulting/runbisonpic)
`bisonpictools` provides the underlying visualization and analysis functionality; `shinybisonpic` is a web-based Shiny app that provides a Graphical User Interface to facilitate data visualization and exploration, and `runbisonpic` is a local-based Shiny app to set up and run an analysis.
## Installation
To install the latest development version of `bisonpictools`:
```{r, eval = FALSE}
install.packages("remotes")
remotes::install_github("poissonconsulting/bisonpictools")
```
And to load the package into the current R session:
```{r, eval = FALSE}
library(bisonpictools)
```
## Data
`bisonpictools` accepts data in a specific format for wood bison camera trap locations and events, as well as census and proportion of calf estimates from aerial surveys of the herd.
There is a downloadable excel template in each of the Shiny apps that aids the user to populate their data appropriately.
```{r}
# Example data for locations of camera traps
location_data
```
```{r}
# Example data for camera trap events
event_data
```
```{r}
# Example data for census estimate from aerial surveys
census_data
```
```{r}
# Example data for proportion of calves estimate from aerial surveys
proportion_calf_data
```
## Data Visualization
Use the `bpt_plot_ratios()` function to visualize ratios in the classified counts from the camera trap events over time.
For example, the calf:cow ratio plotted over all years and locations:
``` {r}
library(bisonpictools)
bpt_plot_ratios(
event_data,
location_data,
numerator = c("f0", "m0", "u0"),
denominator = "fa"
)
```
## Data Analysis
The `bpt_analyse()` function runs the analysis.
The following example uses the built-in example data in the demonstrative "quick" analysis mode.
```{r, eval = FALSE}
analysis <- bpt_analyse(
event_data = event_data,
location_data = location_data,
census_data = census_data,
proportion_calf_data = proportion_calf_data,
nthin = 1L,
analysis_mode = "quick"
)
```
```{r, echo = FALSE}
analysis <- readRDS(file = system.file(package = "bisonpictools", "test-objects/analysis.RDS"))
```
## View model estimates
Use the `bpt_coefficient_table()` function to view the model estimates.
```{r}
bpt_coefficient_table(analysis)
```
## Make predictions
Predictions of the total and the class-wise abundances, the fecundity and survival rates, and several ratios of interest are derived from the posterior distribution of the estimated parameters.
These can be visualized in tables using the functions with the `bpt_predict` prefix:
```{r}
# E.g., Predict total abundance
bpt_predict_abundance_total(analysis)
```
```{r, eval = FALSE}
# Can predict other values using the following functions
bpt_predict_abundance_class(analysis) # Predicts abundance by class
bpt_predict_survival(analysis) # Predicts survival rates
bpt_predict_fecundity(analysis) # Predicts fecundity rate and proportion of reproductive cows
bpt_predict_ratios(analysis) # Predicts population ratios
```
Each of the above predictions can be plotted in a figure using the `bpt_plot_predictions()` function.
```{r}
# E.g., Plot predicted abundances by class
bpt_plot_predictions(analysis, prediction = "abundance-class")
```
The other predictions can be plotted by executing the following code:
```{r, eval = FALSE}
# Plot total abundance
bpt_plot_predictions(analysis, prediction = "abundance-total")
# Plot survival rates
bpt_plot_predictions(analysis, prediction = "survival")
# Plot fecundity rates
bpt_plot_predictions(analysis, prediction = "fecundity")
# Plot ratios
bpt_plot_predictions(analysis, prediction = "ratios")
```
## Information
Additional information is available from the [`bisonpicsuite`](https://poissonconsulting.github.io/bisonpicsuite/) and [`bisonpictools`](https://poissonconsulting.github.io/bisonpictools/) websites, which contain the following articles:
- `bisonpicsuite`
- [Getting Started with bisonpicsuite](https://poissonconsulting.github.io/bisonpicsuite/articles/bisonpicsuite-getting-started.html)
- [Bisonpic User Guide](https://poissonconsulting.github.io/bisonpicsuite/articles/bisonpic-user-guide.html)
- `bisonpictools`
- [Getting Started with bisonpictools](https://poissonconsulting.github.io/bisonpictools/articles/bisonpictools-getting-started.html)
- [Analytical Methods](https://poissonconsulting.github.io/bisonpictools/articles/bisonpic-methods.html)
## Contribution
Please report any [issues](https://github.com/poissonconsulting/bisonpictools/issues).
## Code of Conduct
Please note that the `bisonpictools` project is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
By contributing to this project, you agree to abide by its terms.
```{r, results = "asis", echo = FALSE}
cat(bpt_licensing_md())
```