| Title: | Author, Validate, and Export Key Resources Tables |
|---|---|
| Description: | A toolkit for creating, importing, validating, enriching, rendering, and depositing Key Resources Tables (KRTs). A KRT lists the resources used and generated in a study (antibodies, cell lines, organisms, chemicals, software, datasets, protocols, and more), each paired with a persistent identifier such as a Research Resource Identifier (RRID), a Digital Object Identifier (DOI), a repository accession, or a catalog number, so that resources are unambiguously identifiable and machine-actionable. The package models resources as typed, validated records around a neutral core schema and maps them to journal or funder output profiles, following the FAIR (Findable, Accessible, Interoperable, Reusable) principles of Wilkinson et al. (2016) <doi:10.1038/sdata.2016.18>. It normalizes and optionally resolves identifiers against public registries, extracts resources from manuscripts, and renders tables both in the STAR (Structured, Transparent, Accessible Reporting) Methods style used by Cell Press journals and in the style required by ASAP (Aligning Science Across Parkinson's), with an emphasis on transparency, reproducibility, and correct per-component licensing. |
| Authors: | Ahmad Sofi-Mahmudi [aut, cre] (ORCID: <https://orcid.org/0000-0001-6829-0823>), Aligning Science Across Parkinson's [cph] (Copyright holder of the ASAP Key Resources Table schema (CC BY 4.0; Zenodo doi:10.5281/zenodo.17917979) from which the bundled ASAP profile is derived. ASAP does not endorse this package.) |
| Maintainer: | Ahmad Sofi-Mahmudi <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-11-11 13:51:43 UTC |
| Source: | https://github.com/cran/krt |
Add, update, remove, or get a resource in a KRT
add_resource(x, ...) update_resource(x, resource_id, ...) remove_resource(x, resource_id) get_resource(x, resource_id)add_resource(x, ...) update_resource(x, resource_id, ...) remove_resource(x, resource_id) get_resource(x, resource_id)
x |
A krt_tbl. |
... |
For |
resource_id |
The id of the resource to update, remove, or get. |
add_resource(), update_resource(), and remove_resource() return
the modified krt_tbl; get_resource() returns a krt_resource or NULL.
k <- new_krt("Demo") k <- add_resource(k, "Software/code", "R", version = "4.4.0", new_or_reuse = "reuse", rrid = "RRID:SCR_001905") get_resource(k, k$resources[[1]]$resource_id)k <- new_krt("Demo") k <- add_resource(k, "Software/code", "R", version = "4.4.0", new_or_reuse = "reuse", rrid = "RRID:SCR_001905") get_resource(k, k$resources[[1]]$resource_id)
Records that an activity (for example "normalize_ids", "import",
"validate", "resolve", "export") was applied to the table. Called
automatically by the mutating functions; exported so custom pipelines can
record their own steps.
append_provenance(x, activity, inputs = NULL, outputs = NULL, params = NULL)append_provenance(x, activity, inputs = NULL, outputs = NULL, params = NULL)
x |
A krt_tbl. |
activity |
A short activity label. |
inputs, outputs
|
Optional character vectors of input/output identifiers. |
params |
Optional named list of parameters for the activity. |
The krt_tbl with the entry appended.
k <- append_provenance(new_krt("Demo"), "import", params = list(format = "csv")) length(krt_provenance(k))k <- append_provenance(new_krt("Demo"), "import", params = list(format = "csv")) length(krt_provenance(k))
Map one resource to a profile's columns
apply_mapping(resource, profile)apply_mapping(resource, profile)
resource |
A |
profile |
A |
A named list of column values.
r <- new_resource("Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse") apply_mapping(r, "asap")[["IDENTIFIER"]]r <- new_resource("Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse") apply_mapping(r, "asap")[["IDENTIFIER"]]
KRT classThese are inverse coercions named after their target class. as_krt()
returns the S3 krt_tbl (the package's primary object): pass it a krt_tbl
and it is returned unchanged, or an S4 KRT and it is converted down. It is
the helper to call when a function should accept either representation.
as_KRT() is the opposite direction, a thin idempotent wrapper over
methods::as(x, "KRT") for Bioconductor workflows.
as_krt(x) as_KRT(x)as_krt(x) as_KRT(x)
x |
A krt_tbl or |
as_krt() returns a krt_tbl; as_KRT() returns an S4 KRT.
k4 <- as_KRT(krt_example) identical(length(as_krt(k4)$resources), length(krt_example$resources))k4 <- as_KRT(krt_example) identical(length(as_krt(k4)$resources), length(krt_example$resources))
Serializes the table's recorded activities as a W3C PROV-JSON document: the
table is an entity, each recorded step is an activity associated with the
krt software agent and generating the table.
as_prov_json(x, path = NULL, audience = c("author", "public"))as_prov_json(x, path = NULL, audience = c("author", "public"))
x |
A krt_tbl. |
path |
Output path, or |
audience |
|
The JSON string, or the path (invisibly).
cat(substr(as_prov_json(normalize_ids(krt_example)), 1, 40))cat(substr(as_prov_json(normalize_ids(krt_example)), 1, 40))
Export a KRT as RDF (JSON-LD or Turtle)
as_rdf( x, format = c("jsonld", "turtle"), path = NULL, audience = c("author", "public") )as_rdf( x, format = c("jsonld", "turtle"), path = NULL, audience = c("author", "public") )
x |
A krt_tbl. |
format |
|
path |
Output path, or |
audience |
|
The serialized RDF text, or the path (invisibly).
invisible(as_rdf(krt_example, format = "jsonld"))invisible(as_rdf(krt_example, format = "jsonld"))
Describes the table as an RO-Crate Dataset whose parts are its resources, each carrying its name, type, and identifiers.
as_rocrate(x, path = NULL, audience = c("author", "public"))as_rocrate(x, path = NULL, audience = c("author", "public"))
x |
A krt_tbl. |
path |
Output path, or |
audience |
|
The JSON-LD string, or the path (invisibly).
cat(substr(as_rocrate(krt_example), 1, 40))cat(substr(as_rocrate(krt_example), 1, 40))
Produces a rectangular view of the table by filling the union of present
fields with NA. Many-valued fields are collapsed with "; " in this view;
the lossless representation is the JSON/YAML export.
## S3 method for class 'krt_tbl' as.data.frame(x, row.names = NULL, optional = FALSE, ..., view = "wide")## S3 method for class 'krt_tbl' as.data.frame(x, row.names = NULL, optional = FALSE, ..., view = "wide")
x |
A krt_tbl. |
row.names, optional
|
Present for consistency with the |
... |
Ignored. |
view |
The view to produce: |
A data frame with one row per resource.
k <- add_resource(new_krt("Demo"), "Dataset", "RNA-seq", new_or_reuse = "new", doi = "10.5281/zenodo.123") as.data.frame(k) as.data.frame(krt_example, view = "asap")k <- add_resource(new_krt("Demo"), "Dataset", "RNA-seq", new_or_reuse = "new", doi = "10.5281/zenodo.123") as.data.frame(k) as.data.frame(krt_example, view = "asap")
Convert a validation report to a data frame
## S3 method for class 'krt_validation_report' as.data.frame(x, ...)## S3 method for class 'krt_validation_report' as.data.frame(x, ...)
x |
A |
... |
Ignored. |
A data frame with one row per finding.
Light, non-destructive coercion used when building resource records. Enum fields are lower/normalized where the vocabulary is lowercase; unknown enum values are passed through unchanged (validation reports on them separately).
coerce_field(name, value)coerce_field(name, value)
name |
Field name. |
value |
The value to coerce. |
The coerced value.
coerce_field("new_or_reuse", "NEW") coerce_field("pmid", 12345)coerce_field("new_or_reuse", "NEW") coerce_field("pmid", 12345)
Compose a compound identifier string from a resource's typed fields
compose_identifier(resource, order = NULL)compose_identifier(resource, order = NULL)
resource |
A |
order |
Optional character vector giving the field order; defaults to a sensible canonical order. |
A single "; "-joined identifier string.
r <- new_resource("Antibody", "Anti-TH", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse") compose_identifier(r)r <- new_resource("Antibody", "Anti-TH", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse") compose_identifier(r)
Detect and parse a Key Resources Table embedded in a document
detect_existing_krt(doc)detect_existing_krt(doc)
doc |
The result of |
A krt_tbl parsed from the embedded table, or NULL if none is
found.
detect_existing_krt(read_input_text("No table here."))detect_existing_krt(read_input_text("No table here."))
Projects the table to the ASAP columns and writes it as CSV or into an xlsx
template. If template is supplied (or the bundled ASAP template is used),
the data is written into its KRT sheet, preserving its dropdowns and
attribution worksheet.
export_asap( x, path = NULL, template = NULL, format = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE )export_asap( x, path = NULL, template = NULL, format = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE )
x |
A krt_tbl. |
path |
Output path, or |
template |
Optional xlsx template path. When supplied, output is xlsx. |
format |
|
audience |
|
redact |
Redaction strength for public output, or |
attribution |
If |
The path (invisibly) when written, or CSV text.
cat(substr(export_asap(krt_example), 1, 60))cat(substr(export_asap(krt_example), 1, 60))
Only resources that are citable scholarly objects (datasets, software, protocols, or anything with a DOI) are emitted. This format cannot encode the full biological or ethics semantics of a KRT; use it for reference managers, not as an archival copy.
export_citation( x, path = NULL, format = c("ris", "bibtex"), audience = c("author", "public"), redact = NULL )export_citation( x, path = NULL, format = c("ris", "bibtex"), audience = c("author", "public"), redact = NULL )
x |
A krt_tbl. |
path |
Output path, or |
format |
|
audience |
|
redact |
Redaction strength ( |
The path (invisibly) when written, or the citation text.
cat(export_citation(krt_example, format = "bibtex"))cat(export_citation(krt_example, format = "bibtex"))
Writes a table in a chosen format. "json" and "yaml" are lossless;
"csv", "tsv", "xlsx", "asap", "ris", and "bibtex" are lossy views
and raise a lossy-export warning listing fields that are not preserved as
columns. When audience = "public", sensitive ethics fields are redacted by
default.
export_krt( x, path = NULL, format = c("json", "yaml", "csv", "tsv", "xlsx", "asap", "ris", "bibtex"), profile = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE, template = NULL, view = NULL ) krt_write( x, path = NULL, format = c("json", "yaml", "csv", "tsv", "xlsx", "asap", "ris", "bibtex"), profile = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE, template = NULL, view = NULL )export_krt( x, path = NULL, format = c("json", "yaml", "csv", "tsv", "xlsx", "asap", "ris", "bibtex"), profile = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE, template = NULL, view = NULL ) krt_write( x, path = NULL, format = c("json", "yaml", "csv", "tsv", "xlsx", "asap", "ris", "bibtex"), profile = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE, template = NULL, view = NULL )
x |
A krt_tbl. |
path |
Output file path, or |
format |
Output format; inferred from |
profile |
Profile whose columns tabular exports use (default the table's profile). |
audience |
|
redact |
Redaction strength ( |
attribution |
If |
template |
Optional template path for ASAP/xlsx export. |
view |
Optional explicit view for tabular formats. |
The path (invisibly) when written, otherwise the content string.
export_krt(krt_example, format = "json") |> substr(1, 30) suppressWarnings(export_krt(krt_example, format = "asap")) |> substr(1, 40)export_krt(krt_example, format = "json") |> substr(1, 30) suppressWarnings(export_krt(krt_example, format = "asap")) |> substr(1, 40)
Export a KRT as a delimited table or spreadsheet
export_tabular( x, path = NULL, format = c("csv", "tsv", "xlsx"), profile = NULL, view = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE )export_tabular( x, path = NULL, format = c("csv", "tsv", "xlsx"), profile = NULL, view = NULL, audience = c("author", "public"), redact = NULL, attribution = TRUE )
x |
A krt_tbl. |
path |
Output path, or |
format |
|
profile |
Profile whose columns to use (default the wide core view). |
view |
Optional explicit view name. |
audience |
|
redact |
Redaction strength for public output, or |
attribution |
If |
The path (invisibly) when written, or the delimited text.
cat(substr(export_tabular(krt_example, format = "csv"), 1, 60))cat(substr(export_tabular(krt_example, format = "csv"), 1, 60))
Extract candidate resources from text (regex engine)
extract_candidates(text)extract_candidates(text)
text |
A character vector of manuscript text. |
A list of krt_resource candidates.
cand <- extract_candidates("Anti-TH (RRID:AB_390204); FIJI (RRID:SCR_002285)") length(cand)cand <- extract_candidates("Anti-TH (RRID:AB_390204); FIJI (RRID:SCR_002285)") length(cand)
Reads a manuscript (PDF, JATS/NISO XML, DOCX, or text), extracts candidate resources with the deterministic regex engine (default) or an LLM, and returns them as a validated krt_tbl. Every result is provenance-stamped with the engine used.
extract_krt( input, engine = c("regex", "llm"), format = NULL, profile = "generic", llm = NULL, resolve = FALSE, existing = c("detect", "ignore"), title = NULL )extract_krt( input, engine = c("regex", "llm"), format = NULL, profile = "generic", llm = NULL, resolve = FALSE, existing = c("detect", "ignore"), title = NULL )
input |
A file path or text string. |
engine |
|
format |
Optional explicit input format. |
profile |
Profile to assign to the extracted table. |
llm |
A |
resolve |
Whether to resolve identifiers during validation. |
existing |
|
title |
Optional title for the extracted table. |
A list with krt (the extracted krt_tbl), candidates (the raw
resource candidates), existing_krt (a parsed embedded table or NULL),
and report (a validation report).
res <- extract_krt("Anti-TH (RRID:AB_390204); FIJI (RRID:SCR_002285).") nrow(as.data.frame(res$krt))res <- extract_krt("Anti-TH (RRID:AB_390204); FIJI (RRID:SCR_002285).") nrow(as.data.frame(res$krt))
Sends the text to the configured provider and parses the returned JSON into candidate resources. Requires an API key (from the environment); returns an empty list if none is configured or the call fails.
extract_llm(text, llm = krt_llm(), ...)extract_llm(text, llm = krt_llm(), ...)
text |
Manuscript text. |
llm |
A |
... |
Reserved. |
A list of krt_resource candidates.
# Uses a mock provider so no network or key is needed: register_llm_provider("mock", function(prompt, llm) '[{"resource_type":"Software/code","display_name":"R"}]') extract_llm("text", krt_llm("openai")) # empty without a key extract_llm("text", structure(list(provider = "mock"), class = "krt_llm"))# Uses a mock provider so no network or key is needed: register_llm_provider("mock", function(prompt, llm) '[{"resource_type":"Software/code","display_name":"R"}]') extract_llm("text", krt_llm("openai")) # empty without a key extract_llm("text", structure(list(provider = "mock"), class = "krt_llm"))
Retrieves full text (JATS XML where available) from Europe PMC or bioRxiv, for
feeding into extract_krt(). Returns NULL offline or when the text is not
openly available.
fetch_fulltext(id, source = c("auto", "europepmc", "biorxiv"), timeout = 30)fetch_fulltext(id, source = c("auto", "europepmc", "biorxiv"), timeout = 30)
id |
A PMCID, DOI, or bioRxiv DOI. |
source |
|
timeout |
Request timeout in seconds. |
A character string of the full text or abstract, or NULL.
# Contacts Europe PMC. Offline, or when the text is not openly available, # this returns NULL rather than failing. txt <- fetch_fulltext("PMC5334499") is.null(txt) || nchar(txt) > 0# Contacts Europe PMC. Offline, or when the text is not openly available, # this returns NULL rather than failing. txt <- fetch_fulltext("PMC5334499") is.null(txt) || nchar(txt) > 0
The field registry declares every field a resource record may carry, together with its group, type, cardinality, and the resource types it applies to.
all_fields() field_spec(name) fields_for_type(resource_type) field_label(name, locale = NULL)all_fields() field_spec(name) fields_for_type(resource_type) field_label(name, locale = NULL)
name |
A field name. |
resource_type |
A resource type (one of |
locale |
Optional locale (currently advisory; labels fall back to a title-cased field name). |
all_fields() returns a named list of field specifications;
field_spec() returns one specification (or NULL); fields_for_type()
returns the names of fields that apply to a resource type; field_label()
returns a human-readable label.
str(field_spec("rrid")) fields_for_type("Antibody")str(field_spec("rrid")) fields_for_type("Antibody")
Find duplicate resources in a KRT
find_duplicates(x, fuzzy = FALSE)find_duplicates(x, fuzzy = FALSE)
x |
A krt_tbl. |
fuzzy |
If |
A list of duplicate groups; each element is a character vector of
resource_ids that share a signature (or are near-duplicates).
k <- new_krt("Demo") k <- add_resource(k, "Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") k <- add_resource(k, "Antibody", "Anti-TH (dup)", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") find_duplicates(k)k <- new_krt("Demo") k <- add_resource(k, "Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") k <- add_resource(k, "Antibody", "Anti-TH (dup)", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") find_duplicates(k)
Retrieve a registered profile
get_profile(name)get_profile(name)
name |
Profile name. |
A krt_profile object.
get_profile("asap")$columnsget_profile("asap")$columns
Detects the scheme of a single identifier token (DOI, ORCID, ROR, RRID, PMID, PMCID, URL, or a database accession) using the bundled syntax patterns.
id_parse(idstring)id_parse(idstring)
idstring |
A single identifier token. |
A list with scheme (character, or NA if unrecognized), value
(the cleaned identifier), and field (the resource field the value belongs
in, e.g. "doi", "rrid", "accession").
id_parse("https://doi.org/10.5281/zenodo.123") id_parse("RRID:AB_390204") id_parse("GSE12345")id_parse("https://doi.org/10.5281/zenodo.123") id_parse("RRID:AB_390204") id_parse("GSE12345")
Import an ASAP or Cell Press Key Resources Table
import_asap(path, sheet = 1, title = NULL)import_asap(path, sheet = 1, title = NULL)
path |
A file path (csv/tsv/xlsx) or a data frame already read in. |
sheet |
Worksheet (for xlsx). |
title |
Optional title for the resulting table. |
A krt_tbl; profile "asap" for a six-column ASAP sheet, or
"star-methods" for a Cell Press three-column table.
f <- tempfile(fileext = ".csv") writeLines(export_asap(krt_example), f) k <- import_asap(f) length(k$resources)f <- tempfile(fileext = ".csv") writeLines(export_asap(krt_example), f) k <- import_asap(f) length(k$resources)
Detects the format (JSON, YAML, ASAP/Cell Press table, or generic tabular) and reads it into a krt_tbl.
import_krt(input, format = NULL, profile = NULL, mapping = NULL, sheet = 1)import_krt(input, format = NULL, profile = NULL, mapping = NULL, sheet = 1)
input |
A file path, or a JSON/YAML string. |
format |
One of |
profile |
Optional profile to assign to the imported table. |
mapping |
Optional column-to-field mapping for tabular import. |
sheet |
Worksheet (for xlsx). |
A krt_tbl.
k <- import_krt(write_krt_json(krt_example)) length(k$resources)k <- import_krt(write_krt_json(krt_example)) length(k$resources)
Import a generic tabular Key Resources Table
import_tabular( path, mapping = NULL, sheet = 1, profile = "generic", title = NULL )import_tabular( path, mapping = NULL, sheet = 1, profile = "generic", title = NULL )
path |
A file path (csv/tsv/xlsx) or a data frame. |
mapping |
Optional named list mapping column names to core field names;
guessed from the headers when |
sheet |
Worksheet (for xlsx). |
profile |
Profile to assign to the imported table. |
title |
Optional title. |
A krt_tbl.
df <- data.frame(type = "Antibody", name = "Anti-TH", rrid = "RRID:AB_1", "new/reuse" = "reuse", check.names = FALSE) import_tabular(df)$resources[[1]]$resource_typedf <- data.frame(type = "Antibody", name = "Anti-TH", rrid = "RRID:AB_1", "new/reuse" = "reuse", check.names = FALSE) import_tabular(df)$resources[[1]]$resource_type
Is a value the ASAP "identifier pending" placeholder?
is_pending_identifier(str)is_pending_identifier(str)
str |
A candidate identifier string. |
TRUE if the string matches the "Identifier from ... pending"
convention.
is_pending_identifier("Identifier from Cellosaurus pending")is_pending_identifier("Identifier from Cellosaurus pending")
Coerce a KRT's resources to a DataFrame (Bioconductor)
krt_as_dataframe(x, view = "wide")krt_as_dataframe(x, view = "wide")
x |
A krt_tbl. |
view |
The view to project (default |
An S4Vectors::DataFrame of the resources (requires the S4Vectors
package).
if (requireNamespace("S4Vectors", quietly = TRUE)) krt_as_dataframe(krt_example)if (requireNamespace("S4Vectors", quietly = TRUE)) krt_as_dataframe(krt_example)
Returns the attribution block that should accompany outputs produced with the table's profile. For the ASAP profile (CC BY 4.0) this is the required attribution; for profiles with no redistribution obligation it is a short note.
krt_attribution(x)krt_attribution(x)
x |
A krt_tbl or a profile name. |
A character string.
cat(krt_attribution(krt_example))cat(krt_attribution(krt_example))
Audit the licenses of the package and its bundled assets
krt_audit_licenses()krt_audit_licenses()
A data frame with one row per licensable component (the package code, each profile, the bundled reference data and license text), giving its source, license, DOI, whether it is redistributable, and notes.
krt_audit_licenses()krt_audit_licenses()
Dispatches a subcommand. Used by the krt shell script
(system.file("scripts", "krt", package = "krt")); can also be called
directly with a character vector of arguments.
krt_cli(args = commandArgs(trailingOnly = TRUE))krt_cli(args = commandArgs(trailingOnly = TRUE))
args |
Command-line arguments (defaults to those passed to |
Invisibly an integer status code (0 success, 1 validation failure or
runtime error, 2 usage error such as an unknown command or a missing
required --out).
krt_cli("audit-licenses") f <- tempfile(fileext = ".json") writeLines(write_krt_json(krt_example), f) krt_cli(c("validate", f))krt_cli("audit-licenses") f <- tempfile(fileext = ".json") writeLines(write_krt_json(krt_example), f) krt_cli(c("validate", f))
Creates a Zenodo deposition, uploads the table as JSON, sets metadata, and
optionally publishes. The minted (pre-reserved) DOI is written back into the
table's provenance and table_id. Deposits default to the redacted public
audience, since a deposit is a shared artifact.
krt_deposit_zenodo( x, token = Sys.getenv("ZENODO_TOKEN"), sandbox = TRUE, metadata = NULL, publish = FALSE, audience = c("public", "author"), timeout = 60 )krt_deposit_zenodo( x, token = Sys.getenv("ZENODO_TOKEN"), sandbox = TRUE, metadata = NULL, publish = FALSE, audience = c("public", "author"), timeout = 60 )
x |
A krt_tbl. |
token |
Zenodo access token (defaults to |
sandbox |
Use the Zenodo sandbox (default |
metadata |
Optional Zenodo metadata list (a sensible default otherwise). |
publish |
Whether to publish immediately (default |
audience |
|
timeout |
Request timeout in seconds. |
A list with deposit (the API response), doi, uploaded and
published (per-stage status), and x (the table, with the DOI recorded
only when every stage succeeded). On failure, deposit is NULL.
## Not run: # Not executable without a Zenodo (sandbox) account and access token, so # this example cannot be run during a check. res <- krt_deposit_zenodo(krt_example, sandbox = TRUE) res$doi ## End(Not run)## Not run: # Not executable without a Zenodo (sandbox) account and access token, so # this example cannot be run during a check. res <- krt_deposit_zenodo(krt_example, sandbox = TRUE) res$doi ## End(Not run)
Compares resources by identity signature and reports which were added, removed, or changed (with field-level deltas).
krt_diff(x, y)krt_diff(x, y)
x, y
|
Two krt_tbl objects ( |
A krt_diff object with print() and as.data.frame() methods.
a <- add_resource(new_krt("A"), "Dataset", "D", doi = "10.5281/zenodo.1", new_or_reuse = "new") b <- update_resource(a, a$resources[[1]]$resource_id, notes = "added") as.data.frame(krt_diff(a, b))a <- add_resource(new_krt("A"), "Dataset", "D", doi = "10.5281/zenodo.1", new_or_reuse = "new") b <- update_resource(a, a$resources[[1]]$resource_id, notes = "added") as.data.frame(krt_diff(a, b))
A small krt_tbl spanning several common resource types (antibody, cell line, software, dataset, organism/strain, and protocol). Used throughout the documentation and tests so that examples run offline.
krt_examplekrt_example
An object of class krt_tbl with six resources.
Constructed by data-raw/06-build-example-krt.R. Identifiers are
real, publicly resolvable examples; the study is fictional.
krt_example summary(krt_example)krt_example summary(krt_example)
Fetches an experiment and extracts candidate resources from its body text.
krt_import_elabftw( base_url, experiment_id, token = Sys.getenv("ELABFTW_TOKEN"), timeout = 30 )krt_import_elabftw( base_url, experiment_id, token = Sys.getenv("ELABFTW_TOKEN"), timeout = 30 )
base_url |
The eLabFTW instance base URL (e.g. |
experiment_id |
The experiment id. |
token |
API token (defaults to |
timeout |
Request timeout in seconds. |
A krt_tbl of extracted resources.
## Not run: # Not executable without an eLabFTW instance and an API token, so this # example cannot be run during a check. krt_import_elabftw("https://elab.example.org", experiment_id = 42) ## End(Not run)## Not run: # Not executable without an eLabFTW instance and an API token, so this # example cannot be run during a check. krt_import_elabftw("https://elab.example.org", experiment_id = 42) ## End(Not run)
Fetches a protocol and records it as a Protocol resource.
krt_import_protocolsio( id, token = Sys.getenv("PROTOCOLSIO_TOKEN"), timeout = 30 )krt_import_protocolsio( id, token = Sys.getenv("PROTOCOLSIO_TOKEN"), timeout = 30 )
id |
A protocols.io protocol id or DOI. |
token |
API token (defaults to |
timeout |
Request timeout in seconds. |
A krt_tbl with a single Protocol resource.
# Contacts the public protocols.io API. Offline, this warns and returns an # empty table rather than failing. k <- suppressWarnings(krt_import_protocolsio("kxygx3w")) length(k$resources)# Contacts the public protocols.io API. Offline, this warns and returns an # empty table rather than failing. k <- suppressWarnings(krt_import_protocolsio("kxygx3w")) length(k$resources)
Configure an LLM for extraction
krt_llm( provider = c("openai", "anthropic", "gemini", "openai_compat"), model = NULL, base_url = NULL, api_key = NULL, temperature = 0, max_tokens = 4096 ) ## S3 method for class 'krt_llm' format(x, ...) ## S3 method for class 'krt_llm' print(x, ...)krt_llm( provider = c("openai", "anthropic", "gemini", "openai_compat"), model = NULL, base_url = NULL, api_key = NULL, temperature = 0, max_tokens = 4096 ) ## S3 method for class 'krt_llm' format(x, ...) ## S3 method for class 'krt_llm' print(x, ...)
provider |
One of the registered providers ( |
model |
Model id (a sensible default per provider when |
base_url |
Base URL for |
api_key |
API key; defaults to the provider's environment variable. |
temperature, max_tokens
|
Generation parameters. |
x |
A |
... |
Ignored. |
A krt_llm configuration object.
krt_llm("openai", model = "gpt-4o-mini")$providerkrt_llm("openai", model = "gpt-4o-mini")$provider
Combines resources from two or more tables, matching by normalized identity
signature. Matching resources are merged field by field; the strategy
resolves field-level conflicts. Conflicts are attached to the result as the
"merge_conflicts" attribute.
krt_merge( x, y, ..., strategy = c("union", "prefer_x", "prefer_y", "manual"), by = resource_signature )krt_merge( x, y, ..., strategy = c("union", "prefer_x", "prefer_y", "manual"), by = resource_signature )
x, y, ...
|
Tables to merge ( |
strategy |
|
by |
A function computing a resource's match key (default
|
The merged krt_tbl.
a <- add_resource(new_krt("A"), "Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") b <- add_resource(new_krt("B"), "Dataset", "D", doi = "10.5281/zenodo.1", new_or_reuse = "new") krt_merge(a, b)a <- add_resource(new_krt("A"), "Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") b <- add_resource(new_krt("B"), "Dataset", "D", doi = "10.5281/zenodo.1", new_or_reuse = "new") krt_merge(a, b)
Get or set KRT metadata
krt_meta(x) krt_meta(x) <- valuekrt_meta(x) krt_meta(x) <- value
x |
A krt_tbl. |
value |
A named list of metadata fields to set (any of |
krt_meta() returns a named list of the table's metadata.
k <- new_krt("Demo") krt_meta(k)$title krt_meta(k) <- list(title = "Renamed")k <- new_krt("Demo") krt_meta(k)$title krt_meta(k) <- list(title = "Renamed")
The krt plugin API
krt_plugin_api()krt_plugin_api()
A data frame describing each plugin kind, its registration function, and its contract.
krt_plugin_api()krt_plugin_api()
krt is extensible through five registries. Register custom components with the
corresponding function; krt_plugin_api() lists the entry points and their
contracts, and validate_plugin_contract() checks an object before you
register it.
register_profile(), register_validator(), register_resolver(),
register_llm_provider(), register_suggest_source().
Runs the checks that together decide whether a table is ready to share or deposit, and returns a single machine-readable verdict plus a human-readable checklist: profile validation (no errors), lossless JSON round-trip, a working public (redacted) export that leaks none of the policy's dropped fields, attribution availability, and whether the profile projection would drop fields.
krt_preflight(x, profile = NULL)krt_preflight(x, profile = NULL)
x |
A krt_tbl. |
profile |
Profile to check against (defaults to the table's profile). |
A krt_preflight object: a list with profile, ok (TRUE when no
check fails), and checks (a data frame of check, status, detail),
with print(), format(), and as.data.frame() methods.
pf <- krt_preflight(krt_example) pf$okpf <- krt_preflight(krt_example) pf$ok
Describe a profile
krt_profile_info(name)krt_profile_info(name)
name |
A profile name or a |
The krt_profile (invisibly); prints a human-readable summary
including its license and redistribution status.
krt_profile_info("asap")krt_profile_info("asap")
Licensing of a profile
krt_profile_license(name) krt_profile_sources(name) krt_profile_attribution(name)krt_profile_license(name) krt_profile_sources(name) krt_profile_attribution(name)
name |
A profile name or |
krt_profile_license() returns the SPDX license id;
krt_profile_sources() returns the source metadata list;
krt_profile_attribution() returns the attribution text (or NULL).
krt_profile_license("asap") krt_profile_sources("asap")$doikrt_profile_license("asap") krt_profile_sources("asap")$doi
List available profiles
krt_profiles()krt_profiles()
A data frame with one row per registered profile (name, title, license, whether it is officially endorsed).
krt_profiles()krt_profiles()
Returns the ordered provenance entries as a krt_provenance object (a list
of krt_prov_entry, so length() gives the number of steps). It has
print() and as.data.frame() methods; serialize the provenance graph with
as_prov_json() and as_rocrate().
krt_provenance(x)krt_provenance(x)
x |
A krt_tbl. |
A krt_provenance object.
krt_provenance(normalize_ids(krt_example))krt_provenance(normalize_ids(krt_example))
Queries ontology and registry search endpoints to autocomplete a resource's canonical name or identifier. Requires network access; returns an empty result offline.
krt_suggest(query, type = NULL, authority = "auto", n = 10, resolve = TRUE)krt_suggest(query, type = NULL, authority = "auto", n = 10, resolve = TRUE)
query |
The text to search for. |
type |
Optional resource type hint. |
authority |
Which authority to query: |
n |
Maximum number of suggestions. |
resolve |
Whether to contact the network (default |
A data frame with columns label, id, authority, score, uri.
krt_suggest("dopamine", authority = "chebi", resolve = FALSE)krt_suggest("dopamine", authority = "chebi", resolve = FALSE)
validate_krt() returns a krt_validation_report. It has print(),
summary(), and
as.data.frame() methods. valid is
TRUE when there are no error findings.
Access a KRT controlled vocabulary
krt_vocab(key)krt_vocab(key)
key |
Vocabulary name (e.g. "resource_type", "new_or_reuse", "status"). |
A character vector of allowed values.
krt_vocab("new_or_reuse")krt_vocab("new_or_reuse")
Convenience accessors for the controlled vocabularies used across the package.
krt_resource_types() krt_new_or_reuse() krt_statuses() krt_approval_types() krt_roles() krt_redaction_levels()krt_resource_types() krt_new_or_reuse() krt_statuses() krt_approval_types() krt_roles() krt_redaction_levels()
A character vector of allowed values.
krt_resource_types() krt_new_or_reuse()krt_resource_types() krt_new_or_reuse()
Write attribution to a file
krt_write_attribution(x, path)krt_write_attribution(x, path)
x |
A krt_tbl or profile name. |
path |
Output file path. |
The path, invisibly.
f <- tempfile(fileext = ".md") krt_write_attribution(krt_example, f)f <- tempfile(fileext = ".md") krt_write_attribution(krt_example, f)
KRT S4 classAn S4 wrapper around a krt_tbl, for interoperability with Bioconductor.
Convert with as(x, "KRT") and as(y, "krt_tbl"), or as_krt().
schema_version,profile,table_id,titleCharacter metadata.
resources,approvals,contributors,provenanceRecord lists.
metadataA list of remaining metadata (study type, locale, timestamps).
k4 <- methods::as(krt_example, "KRT") methods::is(k4, "KRT")k4 <- methods::as(krt_example, "KRT") methods::is(k4, "KRT")
Starts a Shiny application for importing, editing (in the generic view),
validating, normalizing identifiers, and exporting a Key Resources Table.
Requires the shiny, bslib, and DT packages.
launch_krt(...)launch_krt(...)
... |
Passed to |
Called for its side effect (runs the app).
if (interactive()) launch_krt()if (interactive()) launch_krt()
List registered LLM providers
list_llm_providers()list_llm_providers()
A character vector of provider names.
list_llm_providers()list_llm_providers()
List registered resolver schemes
list_resolvers()list_resolvers()
A character vector of scheme names.
list_resolvers()list_resolvers()
List autocomplete sources
list_suggest_sources()list_suggest_sources()
A character vector of source names.
list_suggest_sources()list_suggest_sources()
List registered validation rules
list_validators()list_validators()
A data frame of registered rules (id, layer, default severity, standard).
head(list_validators())head(list_validators())
Reads schema.yml, mappings.yml, and (optionally) validation.yml,
provenance.json, and ATTRIBUTION.md from a profile directory.
load_profile(path) is_profile(x)load_profile(path) is_profile(x)
path |
Path to the profile directory. |
x |
An object to test. |
A krt_profile object.
p <- load_profile(system.file("extdata", "profiles", "asap", package = "krt")) p$columnsp <- load_profile(system.file("extdata", "profiles", "asap", package = "krt")) p$columns
Returns the core fields that are present in the table but are not preserved as their own column by the profile (they are either folded into a free-text catch-all column or dropped). These drive the lossy-export warning.
mapping_lossy_fields(x, profile)mapping_lossy_fields(x, profile)
x |
A krt_tbl. |
profile |
A |
A character vector of field names (empty for a lossless profile).
mapping_lossy_fields(krt_example, "asap")mapping_lossy_fields(krt_example, "asap")
Create and add an ethics or governance approval
new_approval(approval_type, ..., .id = NULL) add_approval(x, ...)new_approval(approval_type, ..., .id = NULL) add_approval(x, ...)
approval_type |
One of |
... |
Additional named fields: |
.id |
Optional explicit approval id. |
x |
A krt_tbl. |
new_approval() returns a krt_approval; add_approval() returns
the updated krt_tbl.
a <- new_approval("IACUC", protocol_number = "2026-017", board_name = "Example IACUC") k <- add_approval(new_krt("Demo"), a)a <- new_approval("IACUC", protocol_number = "2026-017", board_name = "Example IACUC") k <- add_approval(new_krt("Demo"), a)
Create and add a contributor
new_contributor(name, ..., .id = NULL) add_contributor(x, ...)new_contributor(name, ..., .id = NULL) add_contributor(x, ...)
name |
Contributor name. |
... |
Additional named fields: |
.id |
Optional explicit contributor id. |
x |
A krt_tbl. |
new_contributor() returns a krt_contributor; add_contributor()
returns the updated krt_tbl.
k <- add_contributor(new_krt("Demo"), "Ada Researcher", orcid = "0000-0002-1825-0097", role = "author")k <- add_contributor(new_krt("Demo"), "Ada Researcher", orcid = "0000-0002-1825-0097", role = "author")
Constructs an empty (or pre-populated) krt_tbl: the neutral, typed core
object of the package. Resources, approvals, and contributors are stored as
present-only records; the rectangular table an author sees is a view
produced on demand by as.data.frame().
new_krt( title = NULL, profile = "generic", study_type = NULL, locale = NULL, resources = list(), approvals = list(), contributors = list() ) krt_new( title = NULL, profile = "generic", study_type = NULL, locale = NULL, resources = list(), approvals = list(), contributors = list() ) is_krt(x)new_krt( title = NULL, profile = "generic", study_type = NULL, locale = NULL, resources = list(), approvals = list(), contributors = list() ) krt_new( title = NULL, profile = "generic", study_type = NULL, locale = NULL, resources = list(), approvals = list(), contributors = list() ) is_krt(x)
title |
A short table or study title. |
profile |
Output profile name (default |
study_type |
Optional character vector describing the study (e.g.
|
locale |
Optional locale string (e.g. |
resources, approvals, contributors
|
Optional lists of records to seed the table with. |
x |
An object to test. |
An object of class krt_tbl.
k <- new_krt("Example study", study_type = "wet-lab") k <- add_resource(k, "Antibody", "Rabbit Anti-TH", vendor = "Millipore", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse") kk <- new_krt("Example study", study_type = "wet-lab") k <- add_resource(k, "Antibody", "Rabbit Anti-TH", vendor = "Millipore", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse") k
Builds a single krt_resource: a flat, present-only record describing one
research resource. Identifier fields are stored separately by type
(catalog_number, rrid, doi, ...); they are only combined into a
compound identifier string at export time.
new_resource( resource_type, display_name = NULL, ..., .id = NULL, .validate = TRUE ) is_resource(x)new_resource( resource_type, display_name = NULL, ..., .id = NULL, .validate = TRUE ) is_resource(x)
resource_type |
One of |
display_name |
The resource name as it appears in the manuscript. |
... |
Additional named fields (see |
.id |
Optional explicit resource id; generated from content if omitted. |
.validate |
If |
x |
An object to test. |
An object of class krt_resource.
new_resource("Antibody", "Rabbit Anti-TH", vendor = "Millipore", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse")new_resource("Antibody", "Rabbit Anti-TH", vendor = "Millipore", catalog_number = "AB152", rrid = "RRID:AB_390204", new_or_reuse = "reuse")
Canonicalizes the identifier fields of a table, a resource, or a bare
character vector: strips resolver prefixes from DOIs, hyphenates ORCIDs,
ensures the RRID: prefix, and so on. Applied consistently, this prevents
the same identifier from appearing in several syntactic forms.
normalize_ids(x, ...)normalize_ids(x, ...)
x |
A krt_tbl, a |
... |
Ignored. |
An object of the same type as x, with identifiers normalized.
normalize_ids("https://doi.org/10.1038/SDATA.2016.18") r <- new_resource("Software/code", "Fiji", rrid = "SCR_002285", new_or_reuse = "reuse") normalize_ids(r)$rridnormalize_ids("https://doi.org/10.1038/SDATA.2016.18") r <- new_resource("Software/code", "Fiji", rrid = "SCR_002285", new_or_reuse = "reuse") normalize_ids(r)$rrid
Splits an ASAP-style IDENTIFIER value (parts joined by ; or newlines)
and classifies each part into a resource field.
parse_compound_identifier(str)parse_compound_identifier(str)
str |
A compound identifier string. |
A named list of fields (e.g. catalog_number, rrid, doi,
accession, url), plus other for unclassified parts.
parse_compound_identifier("Cat# AB152; RRID:AB_390204")parse_compound_identifier("Cat# AB152; RRID:AB_390204")
Project a KRT onto a profile as a data frame
project_profile(x, profile)project_profile(x, profile)
x |
A krt_tbl. |
profile |
A |
A data frame with the profile's columns, one row per resource.
project_profile(krt_example, "asap")[, c("RESOURCE TYPE", "IDENTIFIER")]project_profile(krt_example, "asap")[, c("RESOURCE TYPE", "IDENTIFIER")]
Read manuscript text and tables from an input
read_input_text(input, format = NULL)read_input_text(input, format = NULL)
input |
A file path (pdf/xml/jats/docx/txt) or a plain-text string. |
format |
Optional explicit format; auto-detected when |
A list with text (character), tables (list of data frames), and
format.
read_input_text("We used FIJI (RRID:SCR_002285).")$textread_input_text("We used FIJI (RRID:SCR_002285).")$text
Read a KRT from canonical JSON
read_krt_json(input)read_krt_json(input)
input |
A file path or a JSON string. |
A krt_tbl.
k <- read_krt_json(write_krt_json(krt_example)) identical(length(k$resources), length(krt_example$resources))k <- read_krt_json(write_krt_json(krt_example)) identical(length(k$resources), length(krt_example$resources))
Read a KRT from canonical YAML
read_krt_yaml(input)read_krt_yaml(input)
input |
A file path or a YAML string. |
A krt_tbl.
k <- read_krt_yaml(write_krt_yaml(krt_example)) identical(length(k$resources), length(krt_example$resources))k <- read_krt_yaml(write_krt_yaml(krt_example)) identical(length(k$resources), length(krt_example$resources))
Removes or generalizes fields flagged by the redaction policy, so a table can be shared publicly without exposing internal ethics or consent details.
redact_krt(x, level = c("basic", "strict"), policy = NULL)redact_krt(x, level = c("basic", "strict"), policy = NULL)
x |
A krt_tbl. |
level |
|
policy |
An optional policy data frame overriding |
The redacted krt_tbl.
k <- add_approval(new_krt("Demo"), "IRB", protocol_number = "IRB-1", consent_scope = "study-specific") redact_krt(k)$approvals[[1]]$protocol_numberk <- add_approval(new_krt("Demo"), "IRB", protocol_number = "IRB-1", consent_scope = "study-specific") redact_krt(k)$approvals[[1]]$protocol_number
Default redaction strength for a profile's public exports
redaction_default(profile = NULL)redaction_default(profile = NULL)
profile |
A profile name or |
"basic" or "strict".
redaction_default("asap")redaction_default("asap")
The default redaction policy
redaction_policy()redaction_policy()
A data frame with columns scope ("approval" or "resource"),
field, level (the strip strength at which the field is removed:
"basic" fields are removed at both "basic" and "strict"; "strict"
fields only at "strict"), and action ("drop" or "generalize").
redaction_policy()redaction_policy()
Register an LLM provider
register_llm_provider(name, request_fn, parse_fn = NULL, replace = FALSE)register_llm_provider(name, request_fn, parse_fn = NULL, replace = FALSE)
name |
Provider name (e.g. |
request_fn |
A function |
parse_fn |
Optional custom parser |
replace |
Overwrite an existing provider named |
Invisibly NULL.
register_llm_provider("echo", function(prompt, llm) "[]", replace = TRUE) "echo" %in% list_llm_providers()register_llm_provider("echo", function(prompt, llm) "[]", replace = TRUE) "echo" %in% list_llm_providers()
Register an output profile
register_profile(name = NULL, path = NULL, profile = NULL, replace = FALSE)register_profile(name = NULL, path = NULL, profile = NULL, replace = FALSE)
name |
Profile name. If omitted, taken from the profile's |
path |
Path to a profile directory containing |
profile |
A pre-built |
replace |
Overwrite a profile already registered under |
Invisibly the profile name.
krt_profiles()krt_profiles()
Register an identifier resolver
register_resolver(scheme, fn, replace = FALSE)register_resolver(scheme, fn, replace = FALSE)
scheme |
The identifier scheme (e.g. |
fn |
A function |
replace |
Overwrite an existing resolver for |
Invisibly NULL.
"rrid" %in% list_resolvers()"rrid" %in% list_resolvers()
Register an autocomplete source
register_suggest_source(name, fn, replace = FALSE)register_suggest_source(name, fn, replace = FALSE)
name |
Source name (e.g. |
fn |
A function |
replace |
Overwrite an existing source named |
Invisibly NULL.
"ror" %in% list_suggest_sources()"ror" %in% list_suggest_sources()
Adds a rule to the validation engine. A rule is a function fn(x, ctx) that
inspects a krt_tbl and returns a list of issues (each created with the
internal issue helper); the engine attaches the rule id, layer, standard, and
resolved severity.
register_validator( rule_id, fn, layer = c("structural", "semantic"), severity = c("error", "warning", "note", "info"), applies = function(x) TRUE, standard = NA_character_, replace = FALSE )register_validator( rule_id, fn, layer = c("structural", "semantic"), severity = c("error", "warning", "note", "info"), applies = function(x) TRUE, standard = NA_character_, replace = FALSE )
rule_id |
A unique rule identifier, e.g. |
fn |
The rule function |
layer |
Either |
severity |
Default severity: one of |
applies |
A predicate |
standard |
Optional reporting standard the rule enforces (e.g.
|
replace |
Overwrite an existing rule with the same |
Invisibly NULL; called for its side effect.
# A rule inspects the table and returns a list of issues. This demonstration # rule reports nothing, so registering it leaves validation results unchanged. demo_rule <- function(x, ctx) list() register_validator("demo-no-op", demo_rule, layer = "semantic", severity = "note", replace = TRUE) "demo-no-op" %in% list_validators()$rule_id validate_krt(krt_example)$valid# A rule inspects the table and returns a list of issues. This demonstration # rule reports nothing, so registering it leaves validation results unchanged. demo_rule <- function(x, ctx) list() register_validator("demo-no-op", demo_rule, layer = "semantic", severity = "note", replace = TRUE) "demo-no-op" %in% list_validators()$rule_id validate_krt(krt_example)$valid
Produces a human-readable Key Resources Table. The "star-methods" profile
projects the table to the three Cell Press columns (REAGENT or RESOURCE,
SOURCE, IDENTIFIER) and groups resources under the twelve standard STAR
Methods category headers, in the order the template uses. The "generic"
profile (the default) renders the ASAP six-column layout; any other named
profile renders through its own declared columns.
render_krt( x, path = NULL, format = c("md", "html", "docx"), profile = NULL, template = NULL, audience = c("author", "public"), redact = NULL )render_krt( x, path = NULL, format = c("md", "html", "docx"), profile = NULL, template = NULL, audience = c("author", "public"), redact = NULL )
x |
A krt_tbl. |
path |
Output path, or |
format |
|
profile |
Profile controlling the layout (default the table's profile). |
template |
Unused placeholder for a future Word template. |
audience |
|
redact |
Redaction strength for public output, or |
The rendered text (md/html), or the path (invisibly) for docx.
cat(substr(render_krt(krt_example, profile = "star-methods"), 1, 80))cat(substr(render_krt(krt_example, profile = "star-methods"), 1, 80))
Resolve any identifier by detecting its scheme
resolve_id(id, resolve = TRUE, ...)resolve_id(id, resolve = TRUE, ...)
id |
An identifier string. |
resolve |
Whether to contact the registry. |
... |
Passed to the scheme-specific resolver. |
A resolver result list, or NULL if the scheme is unsupported.
resolve_id("RRID:AB_390204", resolve = FALSE)$normalizedresolve_id("RRID:AB_390204", resolve = FALSE)$normalized
Each resolver normalizes an identifier and, when resolve = TRUE and the
registry is reachable, retrieves a display name and type. All calls degrade
gracefully: offline or on error, resolved is FALSE.
resolve_rrid(rrid, resolve = TRUE, timeout = 15) resolve_doi(doi, resolve = TRUE, timeout = 15) resolve_orcid(orcid, resolve = TRUE, timeout = 15) resolve_pubmed(pmid, resolve = TRUE, timeout = 15) resolve_ror(ror, resolve = TRUE, timeout = 15) resolve_cellosaurus(cvcl, resolve = TRUE, timeout = 15)resolve_rrid(rrid, resolve = TRUE, timeout = 15) resolve_doi(doi, resolve = TRUE, timeout = 15) resolve_orcid(orcid, resolve = TRUE, timeout = 15) resolve_pubmed(pmid, resolve = TRUE, timeout = 15) resolve_ror(ror, resolve = TRUE, timeout = 15) resolve_cellosaurus(cvcl, resolve = TRUE, timeout = 15)
rrid, doi, orcid, pmid, ror, cvcl
|
The identifier to resolve. |
resolve |
Whether to contact the registry (default |
timeout |
Request timeout in seconds. |
A list with input, normalized, resolved, source, name,
type, and url.
# Offline: normalize only (no network). resolve_rrid("RRID:AB_390204", resolve = FALSE) resolve_doi("10.1038/sdata.2016.18", resolve = FALSE)$normalized # Live lookup. This contacts Crossref; offline it simply returns the # normalized identifier with `resolved = FALSE` instead of failing. resolve_doi("10.1038/sdata.2016.18", resolve = TRUE)$resolved# Offline: normalize only (no network). resolve_rrid("RRID:AB_390204", resolve = FALSE) resolve_doi("10.1038/sdata.2016.18", resolve = FALSE)$normalized # Live lookup. This contacts Crossref; offline it simply returns the # normalized identifier with `resolved = FALSE` instead of failing. resolve_doi("10.1038/sdata.2016.18", resolve = TRUE)$resolved
Builds a lowercased, trimmed tuple from the identifying fields
(resource_type, vendor, catalog_number, lot_number, rrid, doi, accession).
Two resources with the same signature are considered duplicates.
resource_signature(resource)resource_signature(resource)
resource |
A |
A single signature string.
r <- new_resource("Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") resource_signature(r)r <- new_resource("Antibody", "Anti-TH", vendor = "Millipore", catalog_number = "AB152", new_or_reuse = "reuse") resource_signature(r)
Resource type implied by an RRID
rrid_type(rrid)rrid_type(rrid)
rrid |
An RRID string (with or without the |
The implied resource type (character) or NA if the authority is
unknown.
rrid_type("RRID:AB_390204") rrid_type("CVCL_0063")rrid_type("RRID:AB_390204") rrid_type("CVCL_0063")
Finds RRIDs, DOIs, catalog numbers, database accessions, and PMIDs in a block of text and classifies each. Used by the regex extraction engine and available on its own.
scan_identifiers(text)scan_identifiers(text)
text |
A character vector of text. |
A data frame with columns value, field, type (an inferred
resource type, or NA), and confidence ("high" for precisely anchored
schemes such as RRID/DOI/accession/PMID, "medium" for looser catalog-number
matches) so the results can be triaged before acceptance.
scan_identifiers("We used anti-TH (RRID:AB_390204) and FIJI (RRID:SCR_002285).")scan_identifiers("We used anti-TH (RRID:AB_390204) and FIJI (RRID:SCR_002285).")
Summarize a KRT
## S3 method for class 'krt_tbl' summary(object, ...)## S3 method for class 'krt_tbl' summary(object, ...)
object |
A krt_tbl. |
... |
Ignored. |
A data frame with resource counts per resource type, including the number of newly generated versus reused resources.
summary(krt_example)summary(krt_example)
Summarize a validation report
## S3 method for class 'krt_validation_report' summary(object, ...)## S3 method for class 'krt_validation_report' summary(object, ...)
object |
A |
... |
Ignored. |
A data frame of finding counts by severity, layer, and standard.
Runs the registered validation rules over a table and returns a
krt_validation_report. Structural rules check schema conformance offline;
semantic rules check cross-field consistency and, when resolve = TRUE,
identifier existence. Conditional packs (cell-line authentication, organism
metadata, ethics/consent) apply only when the relevant resource types are
present; they are minimal checks, not full ICLAC or ARRIVE assessments.
validate_krt( x, profile = NULL, layers = c("structural", "semantic"), resolve = FALSE, severity = NULL, attach = FALSE )validate_krt( x, profile = NULL, layers = c("structural", "semantic"), resolve = FALSE, severity = NULL, attach = FALSE )
x |
A krt_tbl. |
profile |
Profile whose severity overrides apply (default the table's profile). |
layers |
Which layers to run: |
resolve |
If |
severity |
Optional named list mapping |
attach |
If |
Each finding's severity is resolved from the rule default, then any
profile override, then any per-rule value in severity. A severity of
"off" disables the rule.
A krt_validation_report, or the krt_tbl when attach = TRUE.
validate_krt(krt_example) validate_krt(krt_example, layers = "structural")validate_krt(krt_example) validate_krt(krt_example, layers = "structural")
Check that an object satisfies a plugin contract
validate_plugin_contract(kind, obj)validate_plugin_contract(kind, obj)
kind |
One of |
obj |
The plugin object or function to check. |
Invisibly TRUE; errors early if the contract is not met.
validate_plugin_contract("validator", function(x, ctx) list()) validate_plugin_contract("suggest_source", function(query, n) NULL)validate_plugin_contract("validator", function(x, ctx) list()) validate_plugin_contract("suggest_source", function(query, n) NULL)
Match a value against a controlled vocabulary
vocab_match(value, vocab, fuzzy = FALSE)vocab_match(value, vocab, fuzzy = FALSE)
value |
A character value to check. |
vocab |
A character vector of allowed values, or the name of a
vocabulary (resolved with |
fuzzy |
If |
A list with ok (logical), value (the matched canonical term or
NA), and suggestion (nearest term when fuzzy and not matched).
vocab_match("Antibody", "resource_type") vocab_match("antibodies", "resource_type", fuzzy = TRUE)vocab_match("Antibody", "resource_type") vocab_match("antibodies", "resource_type", fuzzy = TRUE)
Write a KRT to canonical JSON
write_krt_json(x, path = NULL, pretty = TRUE)write_krt_json(x, path = NULL, pretty = TRUE)
x |
A krt_tbl. |
path |
Output file path, or |
pretty |
Whether to pretty-print (default |
The JSON string (invisibly, the path when written to a file).
json <- write_krt_json(krt_example) substr(json, 1, 40)json <- write_krt_json(krt_example) substr(json, 1, 40)
Write a KRT to canonical YAML
write_krt_yaml(x, path = NULL)write_krt_yaml(x, path = NULL)
x |
A krt_tbl. |
path |
Output file path, or |
The YAML string (invisibly, the path when written to a file).
cat(substr(write_krt_yaml(krt_example), 1, 40))cat(substr(write_krt_yaml(krt_example), 1, 40))