Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre MacPhail authored and Alexandre MacPhail committed Jul 24, 2024
1 parent f74e55d commit 87212e9
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 77 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Addition of five new functions:
* `wt_dd_summary()` for querying data from Data Discover. See [APIs](https://abbiodiversity.github.io/wildrtrax/articles/apis.html#data-discover) for more information
* `wt_evaluate_classifier()`, `wt_get_threshold()`, and `wt_additional_species()` for wrangling acoustic automated classification results
* `wt_evaluate_classifier()`, `wt_get_threshold()`, and `wt_additional_species()` for wrangling acoustic automated classification results. See [Acoustic classifiers](https://abbiodiversity.github.io/wildrtrax/articles/acoustic-classifiers.html) for more information.
* `wt_add_grts()` to intersect locations with GRTS IDs from [NABat](https://www.nabatmonitoring.org/)
* `wt_download_tags()` now becomes `wt_download_media()` to support broader media downloads in batch from WildTrax
* Deprecated `wt_report()`
Expand All @@ -13,6 +13,7 @@

* Switch to `curl::curl_download()` for media and assets
* Removed dependencies `pipeR`, `progressr`, `jsonlite`, `future`, `furrr`, `tools`, `magrittr`, `markdown`, `rmarkdown` to increase package stability but reduces speed for functions such as `wt_audio_scanner()`, `wt_run_ap()`. Moved `vembedr` to suggests for vignettes
* Switched `wt_download_report()` to POST requests
* Lowercase package name

---
Expand Down
2 changes: 1 addition & 1 deletion R/acoustic-pre-processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ wt_audio_scanner <- function(path, file_type, extra_cols = F) {
}

# Create the main tibble
df <- z %>%
df <- df %>%
tidyr::unnest(file_path) %>%
dplyr::mutate(size_Mb = round(purrr::map_dbl(.x = file_path, .f = ~ fs::file_size(.x)) / 10e5, digits = 2), # Convert file sizes to megabytes
file_path = as.character(file_path)) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/analyze-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ wt_summarise_cam <- function(detect_data, raw_data, time_interval = "day",
#' detections <- wt_ind_detect(x = df, threshold = 30, units = "minutes")
#' }
#'
#' @return A dataframe of independent detections in your camera data, based on the threshold you specified. The df wil include information about the duration of each detection, the number of images, the average number of individual animals per image, and the max number of animals in the detection.
#' @return A dataframe of independent detections in your camera data, based on the threshold you specified. The df will include information about the duration of each detection, the number of images, the average number of individual animals per image, and the max number of animals in the detection.

wt_ind_detect <- function(x, threshold, units = "minutes", datetime_col = image_date_time, remove_human = TRUE, remove_domestic = TRUE) {

Expand Down
7 changes: 3 additions & 4 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,12 @@ wt_download_media <- function(input, output, type = c("recording","image", "tag_
purrr::map2_chr(.$spectrogram_url, .$clip_file_name_spec, ~ curl::curl_download(.x, .y, mode = "wb"))
purrr::map2_chr(.$clip_url, .$clip_file_name_audio, ~ curl::curl_download(.x, .y, mode = "wb"))
}
} else if ("media_url" %in% colnames(data)){
} else if ("media_url" %in% colnames(input_data)){
output_data <- input_data %>%
mutate(image_name = file.path(output, paste0(location, "_", format(parse_date_time(recording_date_time, "%Y-%m-%d %H:%M:%S"), "%Y%m%d_%H%M%S"),".jpeg"))) %>%
mutate(image_name = file.path(output, "/", paste0(location, "_", format(parse_date_time(image_date_time, "%Y-%m-%d %H:%M:%S"), "%Y%m%d_%H%M%S"),".jpeg"))) %>%
{
purrr::map2_chr(.$spectrogram_url, .$image_name, ~ curl::curl_download(.x, .y, mode = "wb"))
purrr::map2_chr(.$media_url, .$image_name, ~ curl::curl_download(.x, .y, mode = "wb"))
}

} else {
stop("Required columns are either 'recording_url', 'media_url', 'spectrogram_url', or 'clip_url'. Use wt_download_report(reports = 'recording', 'image_report' or 'tag') to get the correct media.")
}
Expand Down
2 changes: 1 addition & 1 deletion R/classifier-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' remove_species = TRUE, thresholds = c(10, 99))
#' }
#'
#' @return A tibble containing columsn for precision, recall, and F-score for each of the requested thresholds.
#' @return A tibble containing columns for precision, recall, and F-score for each of the requested thresholds.

wt_evaluate_classifier <- function(data, resolution = "recording", remove_species = TRUE, species = NULL, thresholds = c(10, 99)){

Expand Down
1 change: 1 addition & 0 deletions R/convenience-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ wt_add_grts <- function(data, group_locations_in_cell = FALSE) {
#' Format data for a specified portal
#'
#' @description This function takes the WildTrax reports and converts them to the desired format
#' `r lifecycle::badge("experimental")`
#'
#' @param input The report from `wt_download_report()`
#' @param format A format i.e. 'FWMIS'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![R-CMD-check](https://github.com/ABbiodiversity/wildrtrax/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ABbiodiversity/wildrtrax/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/ABbiodiversity/wildrtrax/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ABbiodiversity/wildrtrax)
[![CRAN status](https://www.r-pkg.org/badges/version/wildrtrax)](https://CRAN.R-project.org/package=wildrtrax)
[![Codecov test coverage](https://codecov.io/gh/ABbiodiversity/wildRtrax/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ABbiodiversity/wildRtrax?branch=main)
<!-- badges: end -->

## Overview
Expand Down
79 changes: 19 additions & 60 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,19 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
on:
push:
branches: [main]
pull_request:
branches: [main]

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ articles:
classifiers-tutorial: classifiers-tutorial.html
introduction: introduction.html
tutorials: tutorials.html
last_built: 2024-07-22T21:47Z
last_built: 2024-07-23T20:54Z
urls:
reference: https://abbiodiversity.github.io/wildrtrax/reference
article: https://abbiodiversity.github.io/wildrtrax/articles
2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wt_download_media.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/wt_evaluate_classifier.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/wt_format_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/wt_ind_detect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/classifiers-tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ eval[eval$threshold==threshold_use,]
```

A precision at our chosen score threshold of approximately `r round(eval$precision,2)` means that more than half of these detections are likely still false positives, we should probably visually verify to remove those false positives. Given that the overall recall rate of BirdNET is < 10% for precision values above 0.7, the detections should be used with caution in ecological analyses. From a detectability perspective, a recall rate of 10% means that your detection probability with BirdNET is 10% of what it would be with a human listener.
A precision at our chosen score threshold of approximately `round(eval[eval$threshold==threshold_use,]$precision,3)` means that ~1/3 of detections are likely still false positives, we should probably visually verify to remove those false positives. Given that the overall recall rate of BirdNET is < 10% for precision values above 0.7, the detections should be used with caution in ecological analyses. From a detectability perspective, a recall rate of 10% means that your detection probability with BirdNET is 10% of what it would be with a human listener.

## Check for additional species detected

Expand Down
2 changes: 1 addition & 1 deletion vignettes/introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ library(wildrtrax)

### What is `wildrtrax`?

`wildrtrax`, pronounced *'wild-R-tracks'*, is an R package for ecologists and advanced users who work with environmental sensors such as autonomous recording units (ARUs) and remote cameras. It contains functions designed to meet most needs in order to organize, analyze and standardize data with the [WildTrax](https://wwww.wildtrax.ca) infrastructure. `wildrtrax` iis self-contained and must be run under an R statistical environment, and it also depends on many other R packages. `wildrtrax` is free software and distributed under [MIT License (c) 2023](https://github.com/ABbiodiversity/wildrtrax/blob/master/LICENSE).
`wildrtrax`, pronounced *'wild-R-tracks'*, is an R package for ecologists and advanced users who work with environmental sensors such as autonomous recording units (ARUs) and remote cameras. It contains functions designed to meet most needs in order to organize, analyze and standardize data with the [WildTrax](https://wwww.wildtrax.ca) infrastructure. `wildrtrax` is self-contained and must be run under an R statistical environment, and it also depends on many other R packages. `wildrtrax` is free software and distributed under [MIT License (c) 2023](https://github.com/ABbiodiversity/wildrtrax/blob/master/LICENSE).

### What is **WildTrax**?

Expand Down

0 comments on commit 87212e9

Please sign in to comment.