Package {r4subpharma}


Title: 'pharmaverse' Adapters for R4SUB Submission Readiness Evidence
Version: 0.1.0
Description: Bridges the 'pharmaverse' clinical reporting stack and the R4SUB (Ready for Submission) ecosystem. Converts 'metacore' metadata objects and ADaM (Analysis Data Model) datasets - such as those built with 'admiral' - into standardized R4SUB evidence table rows via 'r4subcore', so that submission readiness can be scored with 'r4subscore' without changing an existing pharmaverse pipeline.
License: MIT + file LICENSE
URL: https://r4sub.github.io/r4subpharma/, https://github.com/R4SUB/r4subpharma
BugReports: https://github.com/R4SUB/r4subpharma/issues
Depends: R (≥ 4.2)
Imports: cli, r4subcore, tibble
Suggests: knitr, metacore, pharmaverseadam, r4subdata, r4subprofile, r4subscore, rmarkdown, testthat (≥ 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-08-31 17:07:11 UTC; alpine
Author: Pawan Rama Mali ORCID iD [aut, cre, cph]
Maintainer: Pawan Rama Mali <prm@outlook.in>
Repository: CRAN
Date/Publication: 2026-09-11 13:00:02 UTC

r4subpharma: 'pharmaverse' Adapters for R4SUB Submission Readiness Evidence

Description

Bridges the 'pharmaverse' clinical reporting stack and the R4SUB (Ready for Submission) ecosystem. Converts 'metacore' metadata objects and ADaM (Analysis Data Model) datasets - such as those built with 'admiral' - into standardized R4SUB evidence table rows via 'r4subcore', so that submission readiness can be scored with 'r4subscore' without changing an existing pharmaverse pipeline.

Author(s)

Maintainer: Pawan Rama Mali prm@outlook.in (ORCID) [copyright holder]

See Also

Useful links:


Convert an ADaM Dataset to Submission Readiness Evidence

Description

Compares a built ADaM dataset - such as one produced by an 'admiral' pipeline

Usage

adam_to_evidence(
  data,
  metadata,
  ctx,
  dataset_name = NULL,
  source_name = "adam",
  source_version = NULL
)

Arguments

data

A data.frame: one ADaM dataset.

metadata

A Metacore object or a data.frame accepted by as_variable_metadata().

ctx

An r4subcore::r4sub_run_context providing run and study identifiers.

dataset_name

Character or NULL. Which dataset in metadata to check data against. May be omitted when the metadata covers a single dataset.

source_name

Character. Label recorded as the evidence source. Default "adam".

source_version

Character or NULL. Optional version label.

Details

Four indicators are evaluated:

T-ADAM-001

Each variable described in the metadata is present in the dataset (traceability).

T-ADAM-002

Each dataset column is described in the metadata; columns that are not are flagged (traceability).

Q-ADAM-001

Present variables have the data type family the metadata specifies (quality).

Q-ADAM-002

Present variables carry a non-empty label attribute (usability).

Value

A data.frame conforming to the R4SUB evidence schema.

See Also

metacore_to_evidence(), submission_readiness()

Examples


# Check the CDISC pilot ADSL from pharmaverseadam against the ADaM metadata
# shipped in r4subdata.
ctx <- suppressMessages(r4subcore::r4sub_run_context("CDISCPILOT01", "DEV"))
ev  <- suppressMessages(adam_to_evidence(
  pharmaverseadam::adsl,
  r4subdata::adam_metadata,
  ctx,
  dataset_name = "ADSL"
))
table(ev$indicator_id, ev$result)


Coerce Metadata to the Variable-Metadata Contract

Description

Normalizes the accepted metadata inputs into a single tidy table with one row per dataset variable. A metacore object is unpacked into its dataset, variable, and derivation components; a data.frame is checked for the required dataset and variable columns and completed with any missing optional columns.

Usage

as_variable_metadata(metadata)

Arguments

metadata

Either a Metacore object or a data.frame with at least the columns dataset and variable. Optional columns label, type, origin, derivation, and is_derived are used when present.

Value

A tibble with columns dataset, variable, label, type, origin, derivation, and is_derived.

Examples


# The example ADaM metadata shipped in r4subdata.
meta <- as_variable_metadata(r4subdata::adam_metadata)
head(meta)


Convert Metadata to Submission Readiness Evidence

Description

Turns dataset metadata - either a metacore object or a plain data.frame - into standardized R4SUB evidence rows describing how completely each variable is documented. This lets metadata assembled for a 'pharmaverse' pipeline feed the same evidence table and Submission Confidence Index as any other source.

Usage

metacore_to_evidence(
  metadata,
  ctx,
  source_name = "metacore",
  source_version = NULL
)

Arguments

metadata

A Metacore object or a data.frame accepted by as_variable_metadata().

ctx

An r4subcore::r4sub_run_context providing run and study identifiers.

source_name

Character. Label recorded as the evidence source. Default "metacore".

source_version

Character or NULL. Optional version label for the metadata source.

Details

Two indicators are evaluated, reusing the identifiers emitted by r4subcore::define_xml_to_evidence() so that metadata- and Define-XML-sourced evidence group together in scoring and explainability:

Q-DEFINE-002

Variable is documented (has a label and a data type).

Q-DEFINE-003

Derivation text is present for derived variables.

Value

A data.frame conforming to the R4SUB evidence schema.

See Also

adam_to_evidence(), submission_readiness()

Examples


# The example ADaM metadata shipped in r4subdata.
ctx <- suppressMessages(r4subcore::r4sub_run_context("STUDY01", "DEV"))
ev  <- suppressMessages(metacore_to_evidence(r4subdata::adam_metadata, ctx))
table(ev$indicator_id, ev$result)


Score Submission Readiness for a 'pharmaverse' Deliverable

Description

A single entry point that harvests evidence from metadata and one or more ADaM datasets and, when 'r4subscore' is available, computes the Submission Confidence Index (SCI) in one call. It is the fastest way to go from a 'pharmaverse' pipeline to a readiness score.

Usage

submission_readiness(data, metadata, ctx, config = NULL)

Arguments

data

A named list of ADaM data.frames (names are dataset identifiers, e.g. "ADSL"), or a single data.frame when the metadata covers one dataset.

metadata

A Metacore object or a data.frame accepted by as_variable_metadata().

ctx

An r4subcore::r4sub_run_context providing run and study identifiers.

config

An optional sci_config (see r4subscore::sci_config_default()). When NULL, the r4subscore default is used.

Value

An object of class "submission_readiness": a list with evidence (the combined evidence data.frame), pillar_scores, and sci (an sci_result, or NULL if 'r4subscore' is not installed).

See Also

metacore_to_evidence(), adam_to_evidence()

Examples


# Score the CDISC pilot ADSL against the ADaM metadata in r4subdata.
ctx <- suppressMessages(r4subcore::r4sub_run_context("CDISCPILOT01", "DEV"))
res <- suppressMessages(submission_readiness(
  list(ADSL = pharmaverseadam::adsl),
  r4subdata::adam_metadata,
  ctx
))
nrow(res$evidence)