Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty",
"version": "0.11.0",
"version": "0.11.1",
"license": "MIT",
"upload_type": "software",
"description": "<p>This R package provides functions to explore data cubes using simple measures and cross-validation techniques. It can also be used for uncertainty calculation using the bootstrap resampling method, and functionality is provided for efficient interpretation and visualisation of uncertainty related to indicators based on occurrence cubes.<\/p>",
Expand Down Expand Up @@ -43,5 +43,11 @@
{
"identifier": "inbo"
}
],
"publisher": "Research Institute for Nature and Forest (INBO)",
"grants": [
{
"id": "101059592"
}
]
}
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ identifiers:
value: 10.5281/zenodo.14850237
- type: url
value: https://b-cubed-eu.github.io/dubicube/
version: 0.11.0
version: 0.11.1
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Package: dubicube
Title: Calculation and Interpretation of Data Cube Indicator Uncertainty
Version: 0.11.0
Version: 0.11.1
Authors@R: c(
person("Ward", "Langeraert", , "ward.langeraert@inbo.be", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-5900-8109", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Toon", "Van Daele", , "toon.vandaele@inbo.be", role = "aut",
comment = c(ORCID = "0000-0002-1362-853X", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = "cph",
comment = c(ROR = "https://ror.org/00j54wy13")),
person("European Union (ID 101059592)", , , "b-cubedsupport@meisebotanicgarden.be", role = "fnd")
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = c("cph", "pbl"),
comment = c(ROR = "00j54wy13")),
person("European Union (ID 101059592)", , , "b-cubedsupport@meisebotanicgarden.be", role = "fnd",
comment = c(grant_id = "101059592"))
)
Description: This R package provides functions to explore data cubes using
simple measures and cross-validation techniques. It can also be used
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# dubicube 0.11.1

* Add grant ID for Zenodo integration #94
* Fix ROR url bug
* Add publisher to metadata
* Make pkgdown lighter #93

# dubicube 0.11.0

* Improve figures of whole-cube versus group-specific tutorial #88
Expand Down
6 changes: 3 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/b-cubed-eu/dubicube",
"issueTracker": "https://github.com/b-cubed-eu/dubicube/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.11.0",
"version": "0.11.1",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -216,7 +216,7 @@
},
"SystemRequirements": null
},
"fileSize": "387.377KB",
"fileSize": "1846.596KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand All @@ -233,7 +233,7 @@
"familyName": "Van Daele"
}
],
"name": "dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty. Version 0.11.0",
"name": "dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty. Version 0.11.1",
"identifier": "10.5281/zenodo.14850237",
"url": "https://b-cubed-eu.github.io/dubicube/",
"@id": "https://doi.org/10.5281/zenodo.14850237",
Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ citHeader("To cite `dubicube` in publications please use:")
# begin checklist entry
bibentry(
bibtype = "Manual",
title = "dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty. Version 0.11.0",
title = "dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty. Version 0.11.1",
author = c(person(given = "Ward", family = "Langeraert"), person(given = "Toon", family = "Van Daele")),
year = 2026,
url = "https://b-cubed-eu.github.io/dubicube/",
abstract = "This R package provides functions to explore data cubes using simple measures and cross-validation techniques. It can also be used for uncertainty calculation using the bootstrap resampling method, and functionality is provided for efficient interpretation and visualisation of uncertainty related to indicators based on occurrence cubes.",
textVersion = "Langeraert, Ward; Van Daele, Toon (2026) dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty. Version 0.11.0. https://b-cubed-eu.github.io/dubicube/",
textVersion = "Langeraert, Ward; Van Daele, Toon (2026) dubicube: Calculation and Interpretation of Data Cube Indicator Uncertainty. Version 0.11.1. https://b-cubed-eu.github.io/dubicube/",
keywords = "uncertainty quantification; uncertainty visualisation; biodiversity indicators; data cubes",
doi = "10.5281/zenodo.14850237",
)
Expand Down
Binary file added inst/bootstrapping/bootstrap_results.rds
Binary file not shown.
Binary file added inst/bootstrapping/processed_cube.rds
Binary file not shown.
Binary file added inst/bootstrapping/speed_comparison.rds
Binary file not shown.
Binary file added inst/cross_validation/cv_results.rds
Binary file not shown.
2 changes: 1 addition & 1 deletion organisation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info@inbo.be:
email: info@inbo.be
website: https://www.vlaanderen.be/inbo/en-gb
logo: https://inbo.github.io/checklist/reference/figures/logo-en.png
ror: https://ror.org/00j54wy13
ror: 00j54wy13
orcid: yes
zenodo: inbo
rightsholder: optional
Expand Down
79 changes: 74 additions & 5 deletions vignettes/articles/bootstrap-interval-calculation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,14 @@ b3data_package <- read_package(

# Load bird cube data
bird_cube_belgium <- read_resource(b3data_package, "bird_cube_belgium_mgrs10")
head(bird_cube_belgium)
```

We process the cube with **b3gbi**.
First, we select 2000 random rows to make the dataset smaller.
This is to reduce the computation time for this tutorial.
We select the data from 2011 - 2020.

```{r}
```r
set.seed(123)

# Make dataset smaller
Expand All @@ -161,6 +160,47 @@ processed_cube <- process_cube(
processed_cube
```

```{r, echo=FALSE, message=FALSE, results='hide'}
if (
system.file("bootstrapping", "processed_cube.rds", package = "dubicube") == ""
) {
# Read data package
b3data_package <- read_package(
"https://zenodo.org/records/15211029/files/datapackage.json"
)

# Load bird cube data
bird_cube_belgium <- read_resource(b3data_package, "bird_cube_belgium_mgrs10")

set.seed(123)

# Make dataset smaller
rows <- sample(nrow(bird_cube_belgium), 2000)
bird_cube_belgium <- bird_cube_belgium[rows, ]

# Process cube
processed_cube <- process_cube(
bird_cube_belgium,
first_year = 2011,
last_year = 2020,
cols_occurrences = "n"
)

saveRDS(
processed_cube,
file.path("..", "..", "inst", "bootstrapping", "processed_cube.rds")
)
} else {
processed_cube <- readRDS(
system.file("bootstrapping", "processed_cube.rds", package = "dubicube")
)
}
```

```{r, echo=FALSE}
processed_cube
```

### Analysis of the data

Let's say we are interested in the mean number of observations per grid cell per year.
Expand All @@ -171,8 +211,8 @@ We create a function to calculate this.
```

```{r}
# Function to calculate statistic of interest
# Mean number of observations per grid cell per year
# Function to calculate the statistic of interest
# Mean observations per grid cell per year
mean_obs <- function(data) {
data %>%
dplyr::mutate(x = mean(obs), .by = "cellCode") %>%
Expand All @@ -197,7 +237,7 @@ On their own, these values don’t reveal how much uncertainty surrounds them. T

We use the `bootstrap_cube()` function to perform bootstrapping (see also the [bootstrap tutorial](https://b-cubed-eu.github.io/dubicube/articles/bootstrap-method-cubes.html)).

```{r}
```r
bootstrap_results <- bootstrap_cube(
data_cube = processed_cube,
fun = mean_obs,
Expand All @@ -207,6 +247,35 @@ bootstrap_results <- bootstrap_cube(
)
```

```{r, echo=FALSE, message=FALSE, results='hide'}
if (
system.file(
"bootstrapping", "bootstrap_results.rds", package = "dubicube"
) == ""
) {
bootstrap_results <- bootstrap_cube(
data_cube = processed_cube,
fun = mean_obs,
grouping_var = "year",
samples = 1000,
seed = 123
)

saveRDS(
bootstrap_results,
file.path("..", "..", "inst", "bootstrapping", "bootstrap_results.rds")
)
} else {
bootstrap_results <- readRDS(
system.file("bootstrapping", "bootstrap_results.rds", package = "dubicube")
)
}
```

```{r, echo=FALSE}
print("Performing whole-cube bootstrap with `boot::boot()`.")
```

### Interval calculation

Now we can use the `calculate_bootstrap_ci()` function to calculate confidence limits. It relies on the following arguments:
Expand Down
87 changes: 81 additions & 6 deletions vignettes/articles/bootstrap-method-cubes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,22 @@ library(dubicube) # Analysis of data quality & indicator uncertainty
We load the bird cube data from the **b3data** data package using **frictionless** (see also [here](https://github.com/b-cubed-eu/b3data-scripts)).
It is an occurrence cube for birds in Belgium between 2000 en 2024 using the MGRS grid at 10 km scale.

```{r}
```r
# Read data package
b3data_package <- read_package(
"https://zenodo.org/records/15211029/files/datapackage.json"
)

# Load bird cube data
bird_cube_belgium <- read_resource(b3data_package, "bird_cube_belgium_mgrs10")
head(bird_cube_belgium)
```

We process the cube with **b3gbi**.
First, we select 2000 random rows to make the dataset smaller.
This is to reduce the computation time for this tutorial.
We select the data from 2011 - 2020.

```{r}
```r
set.seed(123)

# Make dataset smaller
Expand All @@ -134,24 +133,71 @@ processed_cube <- process_cube(
processed_cube
```

```{r, echo=FALSE, message=FALSE, results='hide'}
if (
system.file("bootstrapping", "processed_cube.rds", package = "dubicube") == ""
) {
# Read data package
b3data_package <- read_package(
"https://zenodo.org/records/15211029/files/datapackage.json"
)

# Load bird cube data
bird_cube_belgium <- read_resource(b3data_package, "bird_cube_belgium_mgrs10")

set.seed(123)

# Make dataset smaller
rows <- sample(nrow(bird_cube_belgium), 2000)
bird_cube_belgium <- bird_cube_belgium[rows, ]

# Process cube
processed_cube <- process_cube(
bird_cube_belgium,
first_year = 2011,
last_year = 2020,
cols_occurrences = "n"
)

saveRDS(
processed_cube,
file.path("..", "..", "inst", "inst", "bootstrapping", "processed_cube.rds")
)
} else {
processed_cube <- readRDS(
system.file("bootstrapping", "processed_cube.rds", package = "dubicube")
)
}
```

```{r, echo=FALSE}
processed_cube
```

### Analysis of the data

Let's say we are interested in the mean number of observations per grid cell per year.
We create a function to calculate this.

```{r, echo=FALSE}
# nolint start: object_usage_linter.
```

```{r}
# Function to calculate the statistic of interest
# Mean observations per grid cell per year
mean_obs <- function(data) {
obs <- x <- NULL

data %>%
dplyr::mutate(x = mean(obs), .by = "cellCode") %>%
dplyr::summarise(diversity_val = mean(x), .by = "year") %>%
as.data.frame()
}
```

```{r, echo=FALSE}
# nolint end: object_usage_linter.
```

We get the following results:

```{r}
Expand Down Expand Up @@ -182,7 +228,7 @@ We use the `bootstrap_cube()` function to do this. It relies on the following ar
- **`progress`**:
Logical flag to show a progress bar. Set to `TRUE` to enable progress reporting; default is `FALSE`.

```{r}
```r
bootstrap_results <- bootstrap_cube(
data_cube = processed_cube,
fun = mean_obs,
Expand All @@ -192,6 +238,35 @@ bootstrap_results <- bootstrap_cube(
)
```

```{r, echo=FALSE, message=FALSE, results='hide'}
if (
system.file(
"bootstrapping", "bootstrap_results.rds", package = "dubicube"
) == ""
) {
bootstrap_results <- bootstrap_cube(
data_cube = processed_cube,
fun = mean_obs,
grouping_var = "year",
samples = 1000,
seed = 123
)

saveRDS(
bootstrap_results,
file.path("..", "..", "inst", "bootstrapping", "bootstrap_results.rds")
)
} else {
bootstrap_results <- readRDS(
system.file("bootstrapping", "bootstrap_results.rds", package = "dubicube")
)
}
```

```{r, echo=FALSE}
print("Performing whole-cube bootstrap with `boot::boot()`.")
```

This returned a list of `"boot"` objects. We can convert this to a dataframe

```{r}
Expand Down
Loading