Skip to contents

The ECOTOX workflow uses a local DuckDB database or a service that you host. Install the data once, then inspect its health and schema.

Install and inspect ECOTOX

library(ComptoxR)
library(dplyr)

eco_install()
eco_health()
eco_tables()
eco_fields("results")
eco_inventory()
eco_species("rainbow trout", field = "common_name")

These calls can use a large local download, so site builds do not run them.

Run a focused query

Filter by chemical, species, and endpoint in eco_results(). Results retain the original ECOTOX life-stage code and description.

trout <- eco_results(
  casrn = "71-43-2",
  common_name = "Rainbow trout",
  endpoint = "LC50"
) |>
  select(test_cas, common_name, latin_name, endpoint,
         organism_lifestage, org_lifestage, final_conc, obs_duration,
         final_obs_duration)

Keep concentration and duration units from the full result when you report values. Apply life-stage harmonization explicitly with a versioned envharmonizer release that matches the ECOTOX source release.

For a local database, read its recorded release before applying the optional mapping. Install the experimental envharmonizer 0.1.1 package separately. This release supports the June and September 2026 ECOTOX source releases. Use the database’s recorded release; do not relabel earlier mapping evidence to match a newer database.

con <- DBI::dbConnect(duckdb::duckdb(),
                     dbdir = eco_health()$db_path, read_only = TRUE)
release <- DBI::dbGetQuery(
  con, "SELECT value FROM _metadata WHERE key = 'ecotox_release'"
)$value
source_results <- eco_results(casrn = "50-29-3", eco_group = "Fish",
                              endpoint = c("LC50", "EC50"), con = con)
mapped_results <- envharmonizer::harmonize_lifestage(source_results, release)
DBI::dbDisconnect(con, shutdown = TRUE)

Experimental mappings; not independently reviewed. Users must assess suitability for their analysis. Keep the source results and mapping manifest.

Upgrade from derived life-stage output

This is a breaking change. Results no longer include harmonized_life_stage or reproductive_stage. Remove the former lifestage_details argument from calls. The con argument is now in position 11 instead of position 12; use its name in calls that supply a connection.

Update the ComptoxR client and the package used by the local Plumber server. Restart the server after the update. Existing local databases continue to work. Queries ignore old derived tables and do not change or delete them. Keep your local databases and mapping evidence for reproducibility.

Advanced query design

Before a complex query, inspect eco_fields() for the current table names and columns. Full ECOTOX query design can include effect groups, exposure types, taxonomic joins, unit conversions, and study-level joins. Those larger joins are outside this focused first workflow.