| Title: | Guarded Evidence Synthesis for the Indian Microplastics Evidence Database |
|---|---|
| Description: | A research-grade, guardrail-first interface to the Indian Microplastics Evidence Database (IMED). It provides release-data access, relational and scientific validation, comparability-aware filtering, descriptive and inferential statistics, evidence-synthesis eligibility, meta-analysis helpers, publication figures, mapping, provenance and citation retrieval, and manuscript-oriented outputs. Unsafe pooling across incompatible matrices, denominators, mass bases and comparability classes is blocked by default. |
| Authors: | Chanikya Naidu [aut, cre] |
| Maintainer: | Chanikya Naidu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.3 |
| Built: | 2026-11-03 23:49:28 UTC |
| Source: | https://github.com/cran/imedR |
This is the preferred entry point for quantitative analysis.
imed_analysis_set( x, comparability_class, matrix = NULL, mass_basis = NULL, metric_type = "Abundance", include_holds = FALSE )imed_analysis_set( x, comparability_class, matrix = NULL, mass_basis = NULL, metric_type = "Abundance", include_holds = FALSE )
x |
An 'imed_db' object, as returned by 'imed_data()'. |
comparability_class |
The single 'Comparability_Class' to analyse (required). |
matrix |
Optional 'Matrix_Code' value(s) to keep. |
mass_basis |
Optional 'Mass_Basis' value(s) to keep. |
metric_type |
'Metric_Type' to keep (default '"Abundance"'). |
include_holds |
If 'FALSE' (default), records flagged as scientific HOLDs are removed. |
A 'tibble' of the selected measurement records that passed the comparability check. It has the additional class 'imed_analysis_set' and the attribute 'comparability_class'. The function stops with an informative message if the selected records are not comparable.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) aset <- imed_analysis_set(toy, comparability_class = "CLASS_A") class(aset) nrow(aset)toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) aset <- imed_analysis_set(toy, comparability_class = "CLASS_A") class(aset) nrow(aset)
Check scientific comparability of an analysis subset
imed_check_comparability( x, action = c("error", "warn", "return"), require_single_unit = TRUE )imed_check_comparability( x, action = c("error", "warn", "return"), require_single_unit = TRUE )
x |
An 'imed_db', or a measurement-level data frame that includes comparability metadata (for example from 'imed_filter()'). |
action |
error, warn, or return. |
require_single_unit |
Require one reported unit. Convertible units should first be explicitly standardized outside this function. |
A 'tibble' with columns 'comparable' (logical) and 'issue' (character; '"None"' when no problem is found) if 'action = "return"'. For 'action = "error"' or '"warn"' the function returns invisibly a single logical value ('TRUE' if the records are comparable) and stops or warns when they are not.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_check_comparability(toy, action = "return")toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_check_comparability(toy, action = "return")
Uses linked SIZE_METHODS records to identify unresolved or heterogeneous analytical/reporting lower bounds. It never substitutes mesh/filter pore size for an analytical lower size limit.
imed_check_size_window( x, sample_id = NULL, action = c("error", "warn", "return") )imed_check_size_window( x, sample_id = NULL, action = c("error", "warn", "return") )
x |
An imed_db. |
sample_id |
Optional sample IDs. |
action |
error, warn or return. |
A 'tibble' with columns 'compatible' (logical) and 'issue' (character; '"None"' when no problem is found) if 'action = "return"'. For 'action = "error"' or '"warn"' the function returns invisibly a single logical value ('TRUE' if the size windows are compatible) and stops or warns when they are not.
db <- imed_data(tables = "SIZE_METHODS", validate = FALSE) imed_check_size_window(db, action = "return")db <- imed_data(tables = "SIZE_METHODS", validate = FALSE) imed_check_size_window(db, action = "return")
Primary study citations for a subset
imed_cite(x, study_id = NULL)imed_cite(x, study_id = NULL)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
A 'tibble' with one row per study and the citation fields that are available ('Study_ID', 'Authors', 'Year', 'Title', 'Journal', 'DOI').
db <- imed_data(tables = "STUDIES", validate = FALSE) head(imed_cite(db))db <- imed_data(tables = "STUDIES", validate = FALSE) head(imed_cite(db))
Grouped comparison summary
imed_compare(x, group, value = "Mean")imed_compare(x, group, value = "Mean")
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
group |
Grouping field (unquoted or quoted name). |
value |
Name of the numeric measurement field to summarise (default '"Mean"'). |
A 'tibble' of descriptive statistics with one row per group, as returned by 'imed_describe()' with a 'group' argument.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_compare(toy, group = "Group")toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_compare(toy, group = "Group")
The package exposes 19 core scientific/schema tables. Internal extraction, workflow and QC-log sheets are intentionally not part of the analytical API.
imed_data(tables = NULL, validate = TRUE)imed_data(tables = NULL, validate = TRUE)
tables |
Optional table names. |
validate |
Run validation after loading. |
An object of class 'c("imed_db", "list")': a named list with one 'tibble' for each requested table. The attribute 'imed_release' holds the data release ('"1.0"') and, when 'validate = TRUE', the attribute 'validation' holds the 'tibble' returned by 'imed_validate()'.
db <- imed_data(tables = c("STUDIES", "SITES"), validate = FALSE) class(db) names(db)db <- imed_data(tables = c("STUDIES", "SITES"), validate = FALSE) class(db) names(db)
Descriptive statistics for a guarded analysis set
imed_describe(x, value = "Mean", group = NULL)imed_describe(x, value = "Mean", group = NULL)
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
value |
Name of the numeric measurement field to summarise (default '"Mean"'). |
group |
Optional grouping field (unquoted or quoted name). |
A 'tibble' with the columns 'n' (number of finite values), 'mean', 'sd', 'median', 'q1', 'q3', 'min' and 'max'. If 'group' is supplied there is one row per group, with the grouping field as the first column.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_describe(toy) imed_describe(toy, group = "Group")toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_describe(toy) imed_describe(toy, group = "Group")
Join measurement records to their scientific comparability metadata
imed_enrich_measurements(x)imed_enrich_measurements(x)
x |
An imed_db. |
A 'tibble' containing the measurement records joined, by 'Measurement_ID', to their comparability metadata. Columns that occur in both tables carry the suffix '.cmp' in the comparability copy.
db <- imed_data(tables = c("MEASUREMENTS", "MEASUREMENT_COMPARABILITY"), validate = FALSE) head(imed_enrich_measurements(db))db <- imed_data(tables = c("MEASUREMENTS", "MEASUREMENT_COMPARABILITY"), validate = FALSE) head(imed_enrich_measurements(db))
Evidence-quality/reporting profile
imed_evidence_profile(x)imed_evidence_profile(x)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
A one-row 'tibble' with the number of QA/QC records ('n_records') and the numbers that report a procedural blank ('procedural_blank_yes'), a recovery test ('recovery_test_reported') and chemical confirmation ('chemical_confirmation_reported').
db <- imed_data(tables = "METHODS_QAQC", validate = FALSE) imed_evidence_profile(db)db <- imed_data(tables = "METHODS_QAQC", validate = FALSE) imed_evidence_profile(db)
Export a publication figure
imed_export_figure( plot, filename, width = 180, height = 120, units = "mm", dpi = 600 )imed_export_figure( plot, filename, width = 180, height = 120, units = "mm", dpi = 600 )
plot |
A 'ggplot' object, for example from 'imed_plot()'. |
filename |
Output file path; the format follows the file extension. |
width |
Figure width in 'units' (default 180). |
height |
Figure height in 'units' (default 120). |
units |
Units for 'width' and 'height' (default '"mm"'). |
dpi |
Resolution in dots per inch (default 600). |
The path 'filename', returned invisibly. The function is called for its side effect of writing the figure to disk.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) p <- imed_plot(toy, type = "histogram") out <- tempfile(fileext = ".png") imed_export_figure(p, out, width = 90, height = 60, dpi = 100) file.exists(out) unlink(out)toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) p <- imed_plot(toy, type = "histogram") out <- tempfile(fileext = ".png") imed_export_figure(p, out, width = 90, height = 60, dpi = 100) file.exists(out) unlink(out)
Filter IMED with scientific guard metadata retained
imed_filter( x, matrix = NULL, comparability_class = NULL, mass_basis = NULL, metric_type = NULL, study_id = NULL, include_holds = FALSE )imed_filter( x, matrix = NULL, comparability_class = NULL, mass_basis = NULL, metric_type = NULL, study_id = NULL, include_holds = FALSE )
x |
An 'imed_db' (HOLD flags are added automatically) or a measurement-level data frame. |
matrix |
Optional 'Matrix_Code' value(s) to keep. |
comparability_class |
Optional 'Comparability_Class' value(s) to keep. |
mass_basis |
Optional 'Mass_Basis' value(s) to keep. |
metric_type |
Optional 'Metric_Type' value(s) to keep. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
include_holds |
If 'FALSE' (default), records flagged as scientific HOLDs are removed. |
A 'tibble' of the records that satisfy all supplied filters. If 'x' is an 'imed_db', the result is the measurement-level table with comparability metadata and two added columns: '.imed_hold' (logical) and '.imed_hold_reason' (character).
db <- imed_data(tables = c("MEASUREMENTS", "MEASUREMENT_COMPARABILITY"), validate = FALSE) nrow(imed_filter(db)) nrow(imed_filter(db, include_holds = TRUE))db <- imed_data(tables = c("MEASUREMENTS", "MEASUREMENT_COMPARABILITY"), validate = FALSE) nrow(imed_filter(db)) nrow(imed_filter(db, include_holds = TRUE))
Flag measurement-level scientific HOLDs
imed_flag_holds(x)imed_flag_holds(x)
x |
An 'imed_db', or a measurement-level data frame that includes comparability metadata. |
A 'tibble' of measurement records, with comparability metadata when 'x' is an 'imed_db', and two added columns: '.imed_hold' (logical, 'TRUE' for records that must not enter strict synthesis) and '.imed_hold_reason' (character, the reason or 'NA').
db <- imed_data(tables = c("MEASUREMENTS", "MEASUREMENT_COMPARABILITY"), validate = FALSE) h <- imed_flag_holds(db) table(h$.imed_hold)db <- imed_data(tables = c("MEASUREMENTS", "MEASUREMENT_COMPARABILITY"), validate = FALSE) h <- imed_flag_holds(db) table(h$.imed_hold)
Forest plot for an imedR meta-analysis
imed_forest(fit, ...)imed_forest(fit, ...)
fit |
A fitted 'metafor' 'rma' object, for example from 'imed_meta_mean()'. |
... |
Further arguments passed to 'metafor::forest()'. |
The fitted model 'fit', returned invisibly. The function is called for its side effect of drawing a forest plot on the active graphics device.
if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) fit <- imed_meta_mean(toy) imed_forest(fit) }if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) fit <- imed_meta_mean(toy) imed_forest(fit) }
A funnel plot is diagnostic only and should not be interpreted as a direct test of publication bias, especially with small or heterogeneous evidence.
imed_funnel(fit, ...)imed_funnel(fit, ...)
fit |
A fitted 'metafor' 'rma' object, for example from 'imed_meta_mean()'. |
... |
Further arguments passed to 'metafor::funnel()'. |
The fitted model 'fit', returned invisibly. The function is called for its side effect of drawing a funnel plot on the active graphics device.
if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) fit <- imed_meta_mean(toy) imed_funnel(fit) }if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) fit <- imed_meta_mean(toy) imed_funnel(fit) }
Leave-one-study-out influence analysis for a guarded mean meta-analysis
imed_leave_one_out(x, method = "REML")imed_leave_one_out(x, method = "REML")
x |
A guarded analysis set that passes 'imed_meta_eligibility()', as for 'imed_meta_mean()'. |
method |
Between-study variance estimator passed to 'metafor' (default '"REML"'). |
A 'tibble' with one row per omitted study. The first column, 'omitted', identifies the study that was left out; the remaining columns are the pooled estimate and heterogeneity statistics returned by 'metafor::leave1out()' after that study is removed.
if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_leave_one_out(toy) }if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_leave_one_out(toy) }
Study-characteristics table for manuscripts
imed_manuscript_table(x, study_id = NULL)imed_manuscript_table(x, study_id = NULL)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
A 'tibble' with one row per study and the descriptive fields that are available ('Study_ID', 'Authors', 'Year', 'States_UTs', 'Matrices_Studied', 'Journal', 'DOI', 'Entry_Status').
db <- imed_data(tables = "STUDIES", validate = FALSE) head(imed_manuscript_table(db))db <- imed_data(tables = "STUDIES", validate = FALSE) head(imed_manuscript_table(db))
Coordinate-provenance-aware IMED map
imed_map(x, geo_min = c("GEO-4", "GEO-3", "GEO-2"), study_id = NULL)imed_map(x, geo_min = c("GEO-4", "GEO-3", "GEO-2"), study_id = NULL)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
geo_min |
Character vector of coordinate classes to retain, chosen from '"GEO-4"', '"GEO-3"' and '"GEO-2"' (default all three). Only sites whose stored class is in this set and that have numeric coordinates are drawn. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
A 'ggplot' object with one point for each site that has numeric coordinates and a retained coordinate class. The function stops if the suggested package 'sf' is not installed.
if (requireNamespace("sf", quietly = TRUE)) { db <- imed_data(tables = c("SITES", "SITE_COORDINATE_CLASS"), validate = FALSE) imed_map(db) }if (requireNamespace("sf", quietly = TRUE)) { db <- imed_data(tables = c("SITES", "SITE_COORDINATE_CLASS"), validate = FALSE) imed_map(db) }
Checks class/unit/basis, usable uncertainty, and study-level independence.
imed_meta_eligibility(x, require_independent_studies = TRUE)imed_meta_eligibility(x, require_independent_studies = TRUE)
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
require_independent_studies |
If TRUE, duplicate Study_ID is flagged. |
A 'tibble' with columns 'eligible' (logical) and 'issue' (character). The value '"None"' in 'issue' means that no problem was found; otherwise each row describes one reason why the records cannot enter a standard meta-analysis.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_meta_eligibility(toy)toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_meta_eligibility(toy)
Intended only for one comparable outcome/unit/basis with independent study effects. Requires metafor.
imed_meta_mean(x, method = "REML")imed_meta_mean(x, method = "REML")
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
method |
Between-study variance estimator passed to 'metafor' (default '"REML"'). |
A fitted random-effects model of class 'c("rma.uni", "rma")' from 'metafor::rma.uni()', using the study means as effects and the squared standard error of each mean as its variance. The pooled estimate is on the original measurement scale.
if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) fit <- imed_meta_mean(toy) fit }if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) fit <- imed_meta_mean(toy) fit }
Uses BIOTA_CONTEXT N_Positive/N_Examined and a logit transformed proportion. Multiple rows per Study_ID are blocked unless the user preselects one independent effect per study.
imed_meta_prevalence(x, study_id = NULL, method = "REML")imed_meta_prevalence(x, study_id = NULL, method = "REML")
x |
An 'imed_db' (required if 'study_id' is used) or a 'BIOTA_CONTEXT'-style data frame with 'N_Positive' and 'N_Examined'. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
method |
Between-study variance estimator passed to 'metafor' (default '"REML"'). |
A fitted random-effects model of class 'c("rma.uni", "rma")' from 'metafor::rma.uni()'. Effects are logit-transformed proportions, so the pooled estimate is on the log-odds scale; use 'plogis()' to back-transform it to a proportion.
if (requireNamespace("metafor", quietly = TRUE)) { biota <- data.frame( Sample_ID = paste0("SA", 1:6), N_Positive = c(5, 12, 3, 20, 8, 15), N_Examined = c(30, 40, 25, 60, 35, 50) ) fit <- imed_meta_prevalence(biota) plogis(coef(fit)) }if (requireNamespace("metafor", quietly = TRUE)) { biota <- data.frame( Sample_ID = paste0("SA", 1:6), N_Positive = c(5, 12, 3, 20, 8, 15), N_Examined = c(30, 40, 25, 60, 35, 50) ) fit <- imed_meta_prevalence(biota) plogis(coef(fit)) }
Requires at least 10 independent effects by default and at least 5 effects per model coefficient. These are guardrails, not guarantees of adequate power.
imed_meta_regression(x, moderators, min_k = 10, method = "REML")imed_meta_regression(x, moderators, min_k = 10, method = "REML")
x |
A guarded analysis set that passes 'imed_meta_eligibility()'. |
moderators |
Character vector of field names in the measurement table to use as moderators. |
min_k |
Minimum number of independent effects required (default 10). At least 5 effects per model coefficient are also required. |
method |
Between-study variance estimator passed to 'metafor' (default '"REML"'). |
A fitted random-effects meta-regression model of class 'c("rma.uni", "rma")' from 'metafor::rma.uni()', with the study identifiers as labels. The coefficients describe the change in the mean outcome associated with each moderator.
if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_meta_regression(toy, moderators = "Group") }if (requireNamespace("metafor", quietly = TRUE)) { toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_meta_regression(toy, moderators = "Group") }
Missingness profile for a table
imed_missingness(x, table = "MEASUREMENTS")imed_missingness(x, table = "MEASUREMENTS")
x |
An 'imed_db' object, as returned by 'imed_data()'. |
table |
Name of the table to profile (default '"MEASUREMENTS"'). |
A 'tibble' with one row per field and the columns 'field', 'n' (number of rows), 'missing' (number of missing or not-reported values) and 'missing_pct' (the percentage missing).
db <- imed_data(tables = "MEASUREMENTS", validate = FALSE) head(imed_missingness(db, "MEASUREMENTS"))db <- imed_data(tables = "MEASUREMENTS", validate = FALSE) head(imed_missingness(db, "MEASUREMENTS"))
Publication-oriented abundance/distribution figure
imed_plot( x, xvar = NULL, value = "Mean", type = c("box", "violin", "scatter", "histogram"), guard = TRUE )imed_plot( x, xvar = NULL, value = "Mean", type = c("box", "violin", "scatter", "histogram"), guard = TRUE )
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
xvar |
Field to place on the x axis (unquoted or quoted name). Required for the box, violin and scatter types. |
value |
Name of the numeric measurement field to plot (default '"Mean"'). |
type |
Plot type: '"box"', '"violin"', '"scatter"' or '"histogram"'. |
guard |
If 'TRUE' (default), stop when the records fail the comparability check. |
A 'ggplot' object that can be printed, modified with further 'ggplot2' layers or saved with 'imed_export_figure()'.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_plot(toy, xvar = "Group", type = "box") imed_plot(toy, type = "histogram")toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_plot(toy, xvar = "Group", type = "box") imed_plot(toy, type = "histogram")
Plot polymer or particle-characteristic composition
imed_plot_composition( x, what = c("polymers", "particles"), study_id = NULL, characteristic_type = NULL )imed_plot_composition( x, what = c("polymers", "particles"), study_id = NULL, characteristic_type = NULL )
x |
An 'imed_db' object, as returned by 'imed_data()'. |
what |
polymers or particles. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
characteristic_type |
Optional character vector of 'Characteristic_Type' values; used only when 'what = "particles"'. |
A 'ggplot' object showing the reported values by polymer or particle category as horizontal bars.
db <- imed_data(tables = "POLYMERS", validate = FALSE) imed_plot_composition(db, what = "polymers")db <- imed_data(tables = "POLYMERS", validate = FALSE) imed_plot_composition(db, what = "polymers")
Plot method/QAQC reporting profile
imed_plot_methods(x)imed_plot_methods(x)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
A 'ggplot' object showing, for each QA/QC item, the number of records with each reported status (including '"Missing/NR"').
db <- imed_data(tables = "METHODS_QAQC", validate = FALSE) imed_plot_methods(db)db <- imed_data(tables = "METHODS_QAQC", validate = FALSE) imed_plot_methods(db)
Provenance records for studies or target records
imed_provenance(x, study_id = NULL, record_id = NULL)imed_provenance(x, study_id = NULL, record_id = NULL)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
study_id |
Optional character vector of 'Study_ID' values used to restrict the records. |
record_id |
Optional character vector of 'Target_Record_ID' values to retrieve. |
A 'tibble' with the provenance records (the PROVENANCE table), restricted to the requested studies or target records when these are supplied.
db <- imed_data(tables = "PROVENANCE", validate = FALSE) head(imed_provenance(db))db <- imed_data(tables = "PROVENANCE", validate = FALSE) head(imed_provenance(db))
Tidy a statistical result object for manuscript reporting
imed_results_table(x)imed_results_table(x)
x |
A result object: an 'imed_stats' result or a fitted 'metafor' 'rma' object. |
A 'tibble'. For an 'imed_stats' object, the data-frame components of the result are stacked and labelled in a 'section' column. For a 'metafor' 'rma' object, a single row with the pooled 'estimate', its standard error 'se', the confidence limits 'ci_lb' and 'ci_ub', the test statistic 'z', 'p_value', the heterogeneity measures 'tau2', 'I2' and 'H2', and the number of effects 'k'. Other objects cause an error.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) res <- imed_stats(toy, group = "Group", test = "welch") imed_results_table(res)toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) res <- imed_stats(toy, group = "Group", test = "welch") imed_results_table(res)
Compares all eligible records with a stricter subset when evidence fields are available. This is descriptive sensitivity analysis, not causal proof.
imed_sensitivity(x, value = "Mean")imed_sensitivity(x, value = "Mean")
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
value |
Name of the numeric measurement field to summarise (default '"Mean"'). |
A 'tibble' with columns 'stratum', 'n' (number of finite values), 'mean' and 'median'. The first row summarises all compatible records; a second row for strict-synthesis-eligible records is added when the field 'Strict_Synthesis_Eligibility' is present.
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_sensitivity(toy)toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_sensitivity(toy)
Tests are explicit, never auto-selected from p-values or normality alone.
imed_stats( x, value = "Mean", group = NULL, test = c("none", "welch", "wilcoxon", "kruskal") )imed_stats( x, value = "Mean", group = NULL, test = c("none", "welch", "wilcoxon", "kruskal") )
x |
An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class. |
value |
Name of the numeric measurement field to analyse (default '"Mean"'). |
group |
Grouping field (unquoted or quoted name); required when 'test' is not '"none"'. |
test |
Test to run: '"none"' (default), '"welch"', '"wilcoxon"' or '"kruskal"'. The test is never chosen automatically. |
An object of class 'c("imed_stats", "list")' with the elements 'descriptive' (a 'tibble' from 'imed_describe()'), 'normality' (a 'tibble' with the Shapiro-Wilk test, present when 3 to 5000 finite values are available) and 'test' (a 'tibble' with 'method', 'statistic' and 'p_value', present when 'test' is not '"none"').
toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_stats(toy, group = "Group", test = "welch")toy <- data.frame( Study_ID = paste0("S", 1:12), Comparability_Class = "CLASS_A", Reported_Unit = "items/L", Metric_Type = "Abundance", Strict_Synthesis_Eligibility = "YES", Group = rep(c("g1", "g2"), 6), Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2), SD = rep(c(0.6, 0.9), 6), N = rep(c(10, 12, 8), 4) ) imed_stats(toy, group = "Group", test = "welch")
List loaded IMED tables
imed_tables(x = imed_data(validate = FALSE))imed_tables(x = imed_data(validate = FALSE))
x |
An 'imed_db' object. Defaults to the bundled snapshot loaded without validation. |
A 'tibble' with one row per table and the columns 'table' (table name), 'rows' (number of rows) and 'columns' (number of columns).
db <- imed_data(tables = c("STUDIES", "SITES"), validate = FALSE) imed_tables(db)db <- imed_data(tables = c("STUDIES", "SITES"), validate = FALSE) imed_tables(db)
The package snapshot contains the core scientific tables from the frozen IMED v1.0 release. Use 'imed_data()' rather than accessing CSV files directly. The relational backbone is STUDIES -> SITES -> SAMPLES -> MEASUREMENTS. Supporting tables preserve size-method hierarchy, particle characteristics, polymers, biota, processing, QA/QC, derived metrics, risk assessments, source discrepancies, provenance, comparability and coordinate classes.
Validate IMED core scientific and relational integrity
imed_validate(x, strict = FALSE)imed_validate(x, strict = FALSE)
x |
An imed_db. |
strict |
Stop on ERROR-level failures. |
A 'tibble' with one row per check and the columns 'check', 'severity' ('"ERROR"' or '"HOLD"'), 'passed' (logical), 'n_issues' (integer) and 'detail'. With 'strict = TRUE' the function stops if any ERROR-level check fails.
db <- imed_data(validate = FALSE) v <- imed_validate(db) table(v$severity, v$passed)db <- imed_data(validate = FALSE) v <- imed_validate(db) table(v$severity, v$passed)
Returns database integrity, HOLD burden, missingness and comparability counts.
imed_validation_report(x)imed_validation_report(x)
x |
An 'imed_db' object, as returned by 'imed_data()'. |
A named list with five elements: 'integrity' (the 'tibble' returned by 'imed_validate()'), 'cardinalities' (table, row and column counts from 'imed_tables()'), 'hold_summary' (a one-row 'tibble' with the number of measurements, the number flagged as HOLD and the number eligible), 'comparability' (counts of records by 'Comparability_Class' and 'Strict_Synthesis_Eligibility') and 'measurement_missingness' (the 'tibble' returned by 'imed_missingness()' for the measurements table).
db <- imed_data(validate = FALSE) rep <- imed_validation_report(db) names(rep) rep$hold_summarydb <- imed_data(validate = FALSE) rep <- imed_validation_report(db) names(rep) rep$hold_summary
Package and targeted data-release version
imed_version()imed_version()
A named character vector with two elements: 'package' (the version of imedR) and 'imed_release' (the version of the bundled IMED data release).
imed_version()imed_version()