| Title: | Build Tidy ClinVar Evidence and Arbitration Tables |
|---|---|
| Description: | Joins official 'ClinVar' variant and submission reports directly into one tidy scalar 'DuckDB' table containing variations, alleles, GRCh37/GRCh38 locations, decisions, source assertions, and gene links. ClinVarbitration policy is implemented in SQL over those reports. An optional package-owned native extension streams VCV XML into the same table when richer observations, conditions, citations, attributes, and attributable evidence text are required, and streams PubMed baseline or update XML into scalar PMID-authoritative literature relations. |
| Authors: | Sounkou Mahamane Toure [aut, cre], DuckDB Foundation [cph] (Bundled DuckDB C extension headers), Centre for Population Genomics [cph] (ClinVarbitration 2.2.11 decision-policy semantics) |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.1.9000 |
| Built: | 2026-11-17 15:05:40 UTC |
| Source: | https://github.com/RGenomicsETL/DuckClinVarbitration |
Returns the disease-level policy relation for two imported releases under one
configured ClinVarbitration profile. The profile and pinned policy version
are held fixed; this function does not calculate case rankings or evaluation
summaries. transition_status is "inserted", "withdrawn", "changed",
or "unchanged". classification_changed is true only for a retained
allele-and-disease key whose policy classification changed. A changed status
also covers changed gold-star evidence level or retained evaluation date.
rclinvarbitration_disease_release_transitions( con, old_release_id, new_release_id, profile_id = "default" )rclinvarbitration_disease_release_transitions( con, old_release_id, new_release_id, profile_id = "default" )
con |
A DuckDB DBI connection initialized with
|
old_release_id |
Earlier imported ClinVar release label. |
new_release_id |
Later imported ClinVar release label. |
profile_id |
Configured policy profile identifier, normally
|
A data frame at the allele-and-disease decision grain, suitable for filtering temporal reclassification cases.
Downloads either the current ClinVar release or a named monthly archive from
the NCBI HTTPS service. The flat reports are the compact default input to
rclinvarbitration_import_flat(). VCV XML feeds the same scalar clinvar
table when an analysis also needs observations, citations, conditions,
attributes, or attributable text that the flat reports do not contain.
rclinvarbitration_download_clinvar( release = "latest", file = "vcv_xml", cache_dir = tools::R_user_dir("RClinVarbitration", "cache"), overwrite = FALSE, quiet = FALSE )rclinvarbitration_download_clinvar( release = "latest", file = "vcv_xml", cache_dir = tools::R_user_dir("RClinVarbitration", "cache"), overwrite = FALSE, quiet = FALSE )
release |
|
file |
One or more of |
cache_dir |
Directory in which downloaded files are cached. |
overwrite |
Download even when a valid cached file is present? |
quiet |
Passed to |
Existing files form a local cache. Current files and archived VCV XML files
are checked against NCBI's MD5 sidecar; a matching file is reused and a stale
or corrupt file is replaced only after a temporary download is verified.
NCBI does not publish MD5 sidecars
beside archived flat files, so those files are reused by name unless
overwrite = TRUE.
A complete VCV release is several gigabytes. The default cache location is
returned by tools::R_user_dir("RClinVarbitration", "cache"). The function
raises R's download timeout to at least the value of option
RClinVarbitration.download_timeout (7200 seconds by default) for the call.
A named character vector of local paths. The download attribute is
a data frame containing source URLs, MD5 values when available, and cache
hit status.
xml <- rclinvarbitration_download_clinvar(release = "latest") xml_2026_03 <- rclinvarbitration_download_clinvar(release = "2026-03")xml <- rclinvarbitration_download_clinvar(release = "latest") xml_2026_03 <- rclinvarbitration_download_clinvar(release = "2026-03")
Loads the package-owned duckclinvarbitration extension. Its native
clinvar_xml_entities(path) and rclinvarbitration_pubmed_xml_rows(path)
table functions are concrete one-pass staging surfaces for
rclinvarbitration_import_xml() and
rclinvarbitration_import_pubmed(). rclinvar_json_field() remains the
compact ClinVar field scalar. The
connection must have been created with
duckdb::duckdb(config = list(allow_unsigned_extensions = "true")), as for
any locally built DuckDB extension.
rclinvarbitration_enable(con, extension_path = NULL)rclinvarbitration_enable(con, extension_path = NULL)
con |
A DuckDB DBI connection. |
extension_path |
Optional explicit exact-version extension path. |
con, invisibly.
schema = "compatibility" writes the seven columns in Centre for Population
Genomics ClinVarbitration's clinvar_decisions.tsv: contig, position,
reference, alternate, clinical_significance, gold_stars, and
allele_id.
rclinvarbitration_export_clinvarbitration_parquet( con, path, release_id, assembly = c("GRCh38", "GRCh37"), profile_id = "default", submitter_exclusions = character(), schema = c("compatibility", "tidy") )rclinvarbitration_export_clinvarbitration_parquet( con, path, release_id, assembly = c("GRCh38", "GRCh37"), profile_id = "default", submitter_exclusions = character(), schema = c("compatibility", "tidy") )
con |
A DuckDB DBI connection initialized with
|
path |
New output |
release_id |
Imported ClinVar release label to export. |
assembly |
Genome assembly: |
profile_id |
Policy profile identifier, normally |
submitter_exclusions |
Additional submitter names to exclude from this
export. Matching is case-insensitive and ignores surrounding whitespace.
These exclusions are combined with any exclusions already stored for
|
schema |
Output schema: the upstream-compatible seven-column relation or the canonical scalar evidence relation. |
schema = "tidy" writes the canonical scalar clinvar relation.
record_kind distinguishes variations, alleles, assembly locations, source
assertions, conditions, genes, observations, citations, text, attributes,
allele policy decisions, and disease-level disease_decision policy rows.
Every row has its own stable record_key; repeated source elements are rows
rather than lists or structs. release_id is a
required Parquet column, so a reopened export retains its source identity.
The compatibility source is the allele-level policy view joined through
clinvar_vcf. Both GRCh37 and GRCh38 are supported, including distinct X/Y
locations for one AlleleID. Primary NC_ placements take precedence when
present. An allele available only on alternate placements retains its exact
sequence accession and is not mislabeled as a primary-chromosome VCF record.
The file is schema-compatible with the upstream TSV/Hail decision resource, but is not claimed to be byte-for-byte equivalent: this package derives submissions and locations from VCV XML, whereas upstream uses ClinVar's tab-delimited submission and variant summaries. PM5 is deliberately not exported; Rduckhts/DuckHTS own downstream consequence and PM5 processing.
A named list describing the written Parquet file, invisibly.
Releases up to the stable C API floor are built against DuckDB's
exact-version C_STRUCT_UNSTABLE ABI, so the package bundles one artifact per
supported engine release. The floor release itself (v1.5.6) uses the stable
C_STRUCT ABI, which DuckDB negotiates for every newer engine. From DuckDB
v2.0 the package also bundles a dedicated stable C API v2 host (v2.0.0,
ABI type C_STRUCT); resolution prefers that host for the v2.0 line and
otherwise falls back to the newest stable artifact that is no newer than the
running engine.
rclinvarbitration_extension_path(duckdb_version = NULL, duckdb_platform = NULL)rclinvarbitration_extension_path(duckdb_version = NULL, duckdb_platform = NULL)
duckdb_version |
Exact DuckDB version, with or without a |
duckdb_platform |
Exact platform reported by |
An absolute extension path.
Joins variant_summary and submission_summary directly in DuckDB. The
resulting clinvar table has one scalar row per variation, allele, assembly
location, decision, SCV submission, RCV accession, or allele-gene link,
identified by record_kind. It is the same canonical table used by
rclinvarbitration_import_xml().
Location rows retain source coordinates even when ClinVar does not provide a
complete VCF tuple (for example some CNVs). clinvar_vcf contains only
locations with a usable one-based position and non-missing REF/ALT.
rclinvarbitration_import_flat( con, submission_path, variant_path, release_id, parquet_path = NULL, assembly = c("GRCh38", "GRCh37"), profile_id = "default", submitter_exclusions = character() )rclinvarbitration_import_flat( con, submission_path, variant_path, release_id, parquet_path = NULL, assembly = c("GRCh38", "GRCh37"), profile_id = "default", submitter_exclusions = character() )
con |
A DuckDB DBI connection. |
submission_path |
Official |
variant_path |
Official |
release_id |
Immutable source-release label stored with the imported rows and returned in the import receipt. |
parquet_path |
Optional new Parquet path for the same tidy table. The
returned import receipt can be passed directly to
|
assembly |
One or both of |
profile_id |
Policy profile recorded on decision rows. |
submitter_exclusions |
Submitters excluded from the policy decision. |
This is the compact default substrate for ClinVarbitration and temporal analysis. XML import remains available for evidence absent from the flat reports, including richer attributable observations and XML-only text.
Invisibly returns the table name, release identity, source paths and byte sizes, and row counts by record kind.
Streams concrete PubMed baseline or update XML through the package-owned
libxml2 DuckDB extension. PMID is the article authority; DOI and PMCID are
retained as ordinary article identifiers when supplied. Each import appends
immutable source-versioned rows. DeleteCitation appends an explicit deleted
article event; it does not erase earlier article or child facts.
rclinvarbitration_import_pubmed( con, path, source_id, source_kind = c("baseline", "update") )rclinvarbitration_import_pubmed( con, path, source_id, source_kind = c("baseline", "update") )
con |
A DuckDB DBI connection with |
path |
Path to a PubMed baseline or update XML or XML.GZ file. |
source_id |
Immutable source snapshot or update label. |
source_kind |
Whether |
The caller's current DuckDB or DuckLake catalog owns the resulting
pubmed_* relations. pubmed_current_* selects the latest non-deleted event
per PMID, while pubmed_*_as_of(source_id) table macros select a historical
cutoff. This importer does not fetch Europe PMC or perform semantic screening.
Invisibly returns source identity, typed source ordinal, and scalar row counts.
The native extension reads .xml and .xml.gz with a libxml2 forward
reader. One compact row per selected ClinVar entity is written to temporary
spill-backed staging in one XML pass, projected into the scalar clinvar
table, and dropped. Repeated XML entities become additional rows; no XML DOM,
durable JSON, nested value, generic parser-node graph, or R data-frame
materialization is used. Compatibility relations are views over clinvar.
rclinvarbitration_import_xml( con, path, release_id, replace = FALSE, source_url = NULL, source_md5 = NULL )rclinvarbitration_import_xml( con, path, release_id, replace = FALSE, source_url = NULL, source_md5 = NULL )
con |
A DuckDB DBI connection. |
path |
Path to an official ClinVar VCV XML or XML.GZ release. |
release_id |
User-supplied release label stored with every row. |
replace |
Replace rows already stored for |
source_url |
Optional source URL for the release catalogue. When |
source_md5 |
Optional 32-character source MD5 digest. Download metadata is used automatically when available. |
A named numeric vector with imported entity counts.
Initialize the ClinVar relational schema
rclinvarbitration_init(con)rclinvarbitration_init(con)
con |
A DuckDB DBI connection. |
con, invisibly.
Returns DuckDB views implementing the supported policy over
clinvar_disease_submissions. The policy bins submitted classifications,
excludes unknown bins and applies the upstream policy's intended qualified
Illumina benign exclusion, optionally applies profile-specific submitter
exclusions, prefers evidence
evaluated from 2016 onward while always retaining expert-panel and practice
guideline evidence, and applies the 60/20 majority rule. The disease-level
and allele-level views both reproduce the upstream strong-review rule: the
first retained practice-guideline or expert-panel classification in source
order is decisive.
rclinvarbitration_policy_sql( policy_version = rclinvarbitration_policy_version() )rclinvarbitration_policy_sql( policy_version = rclinvarbitration_policy_version() )
policy_version |
Exact supported policy version. See
|
clinvar_policy_pathogenic_alleles is the disease-specific pathogenic or
likely-pathogenic join surface for downstream Rduckhts/DuckHTS annotation.
It does not perform VEP or PM5 computation.
A named character vector of DuckDB CREATE OR REPLACE VIEW
statements.
The identifier pins the policy semantics adapted from Centre for Population
Genomics ClinVarbitration 2.2.11 (upstream commit
658b9f241eb2d43aa11214b153b19c1e18a16337) and records that decisions are
grouped per disease rather than only per variation. The identifier has no
package-local suffix: the view names, rather than a speculative v1, state
whether the output is disease-scoped or allele-scoped.
rclinvarbitration_policy_version()rclinvarbitration_policy_version()
A character scalar.
Registers one tidy Parquet export in a persistent staging table, then replaces the current evidence set by key in one DuckLake transaction. New keys are inserted, absent keys are deleted, changed content is updated, and byte-identical records are left untouched. DuckLake's native data-change feed is the release-delta authority.
rclinvarbitration_publish_ducklake( con, export, table_name = "clinvar", staging_table = "clinvar_incoming", ducklake_name = NULL, author = "RClinVarbitration", commit_message = NULL )rclinvarbitration_publish_ducklake( con, export, table_name = "clinvar", staging_table = "clinvar_incoming", ducklake_name = NULL, author = "RClinVarbitration", commit_message = NULL )
con |
A DuckDB DBI connection whose current database is the writable DuckLake catalog. |
export |
The returned value from
|
table_name |
Persistent current-decision table. |
staging_table |
Persistent empty staging table. |
ducklake_name |
Attached DuckLake catalog. |
author |
Snapshot author. |
commit_message |
Snapshot message. |
The staging and target tables are initialized once from the Parquet schema. The staging table is retained because current DuckLake releases cannot create, register, and drop that table safely in the same transaction. It is empty before and after every successful publication.
Invisibly returns the publication snapshot, source identity, input row count, and DuckLake change counts.
Reproduces Centre for Population Genomics ClinVarbitration 2.2.11's
allele-level decision algorithm directly from NCBI's versioned
submission_summary and variant_summary files. The generated Parquet has
the exact seven-column clinvar_decisions.tsv layout: contig, position,
reference, alternate, clinical_significance, gold_stars, and
allele_id.
rclinvarbitration_reproduce_clinvarbitration_parquet( con, submission_path, variant_path, path, assembly = c("GRCh38", "GRCh37"), submitter_exclusions = character() )rclinvarbitration_reproduce_clinvarbitration_parquet( con, submission_path, variant_path, path, assembly = c("GRCh38", "GRCh37"), submitter_exclusions = character() )
con |
A DuckDB DBI connection. |
submission_path |
Archived NCBI |
variant_path |
Archived NCBI |
path |
New output |
assembly |
Genome assembly: |
submitter_exclusions |
Submitter names to exclude for a blinded run. |
This is separate from rclinvarbitration_import_xml() and the disease-aware
policy views. It exists to reproduce and differentially validate the upstream
allele-level artifact on matching archived flat-file releases. It uses
DuckDB's streaming CSV reader and SQL aggregation; it does not invoke Python,
Hail, VEP, or PM5 logic.
A named list describing the written Parquet file, invisibly.
Returns DuckDB DDL for one scalar ClinVar fact table plus compatibility
views and append-only, source-versioned PubMed relations. Every ClinVar XML
entity is one clinvar row identified by record_kind; repeated conditions,
observations, citations, names, and text are additional rows rather than
nested values or Cartesian products. PubMed current and as-of relations use
typed source order without deleting historical facts; read-only
pubmed_literature_* views project all source versions for direct semantic
consumers. Literature sections normalize article titles to section = "title"
and abstracts to section = "abstract", retaining structured labels in
subsection and abstract locators in source_entity_ordinal (NULL for
titles). The release catalogue and small policy configuration tables remain
separate.
rclinvarbitration_schema_sql()rclinvarbitration_schema_sql()
A named character vector of SQL statements.