---
title: "Retrieve HAB Data From IOC-UNESCO Databases"
output:
  rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Retrieve HAB Data From IOC-UNESCO Databases}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include=FALSE}
hab_available <- tryCatch({
  httr::status_code(httr::GET("https://www.marinespecies.org/hab/",
                               httr::timeout(5))) < 400
}, error = function(e) FALSE)

toxin_available <- tryCatch({
  httr::status_code(httr::GET("https://toxins.hais.ioc-unesco.org/",
                               httr::timeout(5))) < 400
}, error = function(e) FALSE)
```

## IOC-UNESCO Databases

The Intergovernmental Oceanographic Commission (IOC) of UNESCO is the United Nations body dedicated to supporting global ocean science, services, and governance. The [IOC-UNESCO Taxonomic Reference List of Harmful Microalgae](https://www.marinespecies.org/hab/) (Lundholm et al., 2009) focuses on species known to produce toxins or exhibit toxic effects, along with a few species suspected of toxin production. All toxic species in the list are verified with [WoRMS](https://www.marinespecies.org) to ensure accurate taxonomy.

The [IOC-UNESCO Toxins database](https://toxins.hais.ioc-unesco.org/) complements this list by providing detailed reference information about toxins, some of which are associated with harmful algal events.

The information from these databases can be accessed through APIs, as demonstrated in this tutorial using `SHARK4R`.

## Getting Started

#### Installation

You can install the latest version of `SHARK4R` from CRAN using:
```{r, eval=FALSE}
install.packages("SHARK4R")
```

Load the `SHARK4R` and `dplyr` libraries:
```{r}
library(SHARK4R)
```

## Retrieve HAB List From IOC Taxonomic List

The complete HAB list, including scientific names and AphiaIDs, can be downloaded from the [IOC-UNESCO Taxonomic Reference List of Harmful Microalgae](https://www.marinespecies.org/hab/). The output fields are customizable through function parameters—for example, setting `classification = FALSE` excludes higher taxonomic information from the results.

```{r, eval=hab_available}
# Retrieve complete HAB list
hab_list <- get_hab_list()

# Print result
print(hab_list)
```

A separate list of harmful non-toxic species is also available (Zingone & Escalera, 2025). This compilation focuses on taxa for which no toxin production is known, yet which have been linked to negative impacts on marine organisms, including mortality and ecosystem disturbance. The list is designed to be used alongside the IOC-UNESCO Taxonomic Reference List of Harmful Microalgae and is mutually exclusive with it. As a result, any species known to produce toxins is omitted, even when reported harmful effects are attributed to non-toxic processes such as oxygen depletion.

```{r, eval=hab_available}
# Retrieve complete Harmful non-toxic list
hab_non_toxic_list <- get_hab_list(harmful_non_toxic_only = TRUE,
                                   verbose = FALSE)

# Print result
print(hab_non_toxic_list)
```

## Retrieve HAB Toxins From IOC Toxins Database

The complete Toxin list can be downloaded from the [IOC-UNESCO Toxins database](https://toxins.hais.ioc-unesco.org/) using the `get_toxin_list()` function.

```{r, eval=toxin_available}
# Retrieve complete toxin list
toxin_list <- get_toxin_list()

# Print result
print(toxin_list)
```

---

## Citation

```{r, echo=FALSE}
# Print citation
citation("SHARK4R")
```

```{r, echo=FALSE}
clean_shark4r_cache(0, clear_perm_cache = TRUE, verbose = FALSE)
```

---

## References

- Lundholm, N.; Bernard, C.; Churro, C.; Escalera, L.; Hoppenrath, M.; Iwataki, M.; Larsen, J.; Mertens, K.; Murray, S.; Probert, I.; Salas, R.; Tillmann, U.; Zingone, A. (Eds) (2009 onwards). IOC-UNESCO Taxonomic Reference List of Harmful Microalgae. Accessed at https://www.marinespecies.org/hab/ on `r Sys.Date()`. [doi:10.14284/362](https://doi.org/10.14284/362)
- Zingone A. and L. Escalera (2025) Non toxigenic animal-killing microalgal species. In: Lundholm, N.; Bernard, C.; Churro, C.; Escalera, L.; Hoppenrath, M.; Iwataki, M.; Larsen, J.; Mertens, K.; Murray, S.; Probert, I.; Salas, R.; Tillmann, U.; Zingone, A. (Eds) (2009 onwards). IOC-UNESCO Taxonomic Reference List of Harmful Microalgae. Accessed at https://www.marinespecies.org/hab/ on `r Sys.Date()`. [doi:10.14284/362](https://doi.org/10.14284/362)
