Validate a molpath_db for referential integrity and completeness
Source:R/database.R
mp_validate_db.RdChecks that all foreign key relationships in the database are satisfied (e.g., every sample references an existing patient) and reports on data completeness across tables.
Value
Invisibly, a list with three elements:
- valid
Logical.
TRUEif no referential integrity issues were found.- issues
Character vector of issue descriptions (empty if valid).
- completeness
Named numeric vector with percentages of patients having data in each table (e.g.,
pct_with_variants,pct_with_survival).
Details
The following referential integrity checks are performed:
All
patient_idvalues in the samples table exist in patients.All
sample_idvalues in the variants table exist in samples.All
sample_idvalues in the reports table exist in samples.All
patient_idvalues in the clinical table exist in patients.All
patient_idvalues in the survival table exist in patients.
When called interactively, results are printed using cli formatting.
Examples
# \donttest{
db <- mp_example_db(n_patients = 10, seed = 1)
validation <- mp_validate_db(db)
#>
#> ── Validating molpath database ──
#>
#> ✔ No referential integrity issues found.
#>
#> ── Data completeness
#> • Patients with samples: 100%
#> • Patients with variants: 100%
#> • Patients with reports: 100%
#> • Patients with clinical: 100%
#> • Patients with survival: 100%
validation$valid
#> [1] TRUE
# }