| Title: | Molecular Pathology Data Platform for Clinical NGS Integration |
|---|---|
| Description: | A unified platform for ingesting, linking, querying, and visualizing molecular pathology data from heterogeneous sources including NGS files (FASTQ, BAM, VCF), XML variant interpretation reports, structured pathology PDF reports, pathology and clinical information systems, and survival outcome data. Provides a searchable in-memory database and an interactive Shiny application for clinical exploration and cohort analysis. Raw sequence and alignment readers do not perform variant calling or clinical interpretation. |
| Authors: | R. Heller [aut, cre] (ORCID: <https://orcid.org/0000-0001-8006-9742>) |
| Maintainer: | R. Heller <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9001 |
| Built: | 2026-11-03 18:14:58 UTC |
| Source: | https://github.com/CTTIR/molpathR |
Appends new data from one or more molpath_parsed objects to an existing
molpath_db database. Records are deduplicated after appending.
mp_add_data(db, parsed)mp_add_data(db, parsed)
db |
A |
parsed |
A single |
An updated molpath_db object with the new data merged in.
db <- mp_example_db(n_patients = 5, seed = 1) new_data <- new_molpath_parsed( data = tibble::tibble(patient_id = "P99", os_months = 12, os_status = 1L, pfs_months = 6, pfs_status = 1L), source_type = "survival", source_file = "new.csv" ) db <- mp_add_data(db, new_data)db <- mp_example_db(n_patients = 5, seed = 1) new_data <- new_molpath_parsed( data = tibble::tibble(patient_id = "P99", os_months = 12, os_status = 1L, pfs_months = 6, pfs_status = 1L), source_type = "survival", source_file = "new.csv" ) db <- mp_add_data(db, new_data)
Constructs a unified molpath_db database object from one or more
molpath_parsed objects. Each parsed object is categorized by its
source_type and merged into the appropriate database table. Raw FASTQ/BAM
reads remain available through their readers but cannot be interpreted as
variant calls by this function. Unknown gene annotations, pathogenicity and
patient links remain missing. Use mp_validate_db() to assess incomplete links.
mp_build_db(...)mp_build_db(...)
... |
One or more |
Source types map to database tables as follows:
"vcf" – non-reference GT calls or explicitly normalized variants
"xml_report" – variants and explicitly identified patients/samples
"pdf_report" – reports
"nexus_pathology" – patients and samples
"nexus_clinical" – clinical
"survival" – survival
A molpath_db S3 object containing linked patients, samples,
variants, reports, clinical, survival, and metadata tables.
# Build from a molpath_parsed object surv_parsed <- new_molpath_parsed( data = tibble::tibble( patient_id = c("P1", "P2"), os_months = c(12, 24), os_status = c(1L, 0L), pfs_months = c(6, 18), pfs_status = c(1L, 0L) ), source_type = "survival", source_file = "test.csv" ) db <- mp_build_db(surv_parsed)# Build from a molpath_parsed object surv_parsed <- new_molpath_parsed( data = tibble::tibble( patient_id = c("P1", "P2"), os_months = c(12, 24), os_status = c(1L, 0L), pfs_months = c(6, 18), pfs_status = c(1L, 0L) ), source_type = "survival", source_file = "test.csv" ) db <- mp_build_db(surv_parsed)
Generates a realistic but entirely synthetic molpath_db object
containing patients, samples, variants, reports, clinical data, and
survival data.
The data set is designed to mirror the structure of a real-world
molecular pathology database with plausible clinical correlations,
including diagnosis-specific mutation profiles, TNM staging, and
survival outcomes.
mp_example_db(n_patients = 150, seed = 42)mp_example_db(n_patients = 150, seed = 42)
n_patients |
Integer. Number of patients to generate.
Default |
seed |
Integer. Random seed for reproducibility. Default |
A molpath_db object (S3 list) containing:
A tibble with columns patient_id, age, sex,
diagnosis, diagnosis_date.
A tibble with columns sample_id, patient_id,
sample_type, date, source_file.
A tibble with columns sample_id, gene, variant,
variant_type, classification, vaf, chromosome, position, ref_allele,
alt_allele.
A tibble with columns sample_id, report_type,
report_date, summary_text, source_file.
A tibble with columns patient_id, parameter,
value, date, source.
A tibble with columns patient_id, os_months,
os_status, pfs_months, pfs_status.
db <- mp_example_db() db$patients nrow(db$variants) # Smaller data set for quick tests db_small <- mp_example_db(n_patients = 20, seed = 123)db <- mp_example_db() db$patients nrow(db$variants) # Smaller data set for quick tests db_small <- mp_example_db(n_patients = 20, seed = 123)
Creates a set of realistic mock files that can be used to test the molpathR import pipeline. Files include VCF, XML, text-based PDF-like reports, a survival CSV, and a tiny FASTQ file.
mp_example_files( dir = tempdir(), seed = 42, reference_date = as.Date("2025-01-01") )mp_example_files( dir = tempdir(), seed = 42, reference_date = as.Date("2025-01-01") )
dir |
Character. Directory where files are written.
Default |
seed |
Integer. Random seed for reproducibility. Default |
reference_date |
Date. Fixed anchor for synthetic report dates; default 2025-01-01. File contents do not depend on the day they are generated. |
A named list of file paths:
Character vector of 5 VCF file paths.
Character vector of 5 XML report file paths.
Character vector of 5 text-based mock PDF report paths.
Path to the survival CSV file.
Path to the sample FASTQ file.
files <- mp_example_files() readLines(files$vcf[1], n = 5)files <- mp_example_files() readLines(files$vcf[1], n = 5)
Returns a named list containing all data layers for the given patient, including samples, variants (via sample linkage), reports, clinical data, and survival data.
mp_get_patient(db, patient_id)mp_get_patient(db, patient_id)
db |
A |
patient_id |
A single patient ID string. |
A named list with elements: patient, samples, variants,
reports, clinical, survival.
db <- mp_example_db(n_patients = 20, seed = 1) pat <- mp_get_patient(db, db$patients$patient_id[1]) pat$samplesdb <- mp_example_db(n_patients = 20, seed = 1) pat <- mp_get_patient(db, db$patients$patient_id[1]) pat$samples
Reads an RDS file, verifies it contains a valid molpath_db object,
and prints a summary of the loaded database. Known legacy zero-column empty
tables and one-row metadata tibbles are normalized explicitly. Malformed
schemas or values are rejected; incomplete foreign-key links remain visible
through mp_validate_db() rather than being invented.
mp_load_db(path)mp_load_db(path)
path |
Character string giving the file path to an RDS file
containing a |
A molpath_db object.
db <- mp_example_db(n_patients = 5, seed = 1) tmp <- tempfile(fileext = ".rds") mp_save_db(db, tmp) db2 <- mp_load_db(tmp) unlink(tmp)db <- mp_example_db(n_patients = 5, seed = 1) tmp <- tempfile(fileext = ".rds") mp_save_db(db, tmp) db2 <- mp_load_db(tmp) unlink(tmp)
Combines all tables from two molpath_db objects into a single unified
database. Records are deduplicated after merging. Metadata source files are
combined as a union. Identical primary-key rows are deduplicated and missing
attributes may be filled from the other source. Conflicting observed patient,
sample or survival attributes require explicit reconciliation and cause an error.
mp_merge_db(db1, db2)mp_merge_db(db1, db2)
db1 |
A |
db2 |
A |
A new molpath_db object containing merged data from both inputs.
db1 <- mp_example_db(n_patients = 5, seed = 1) db2 <- db1 db1$survival <- db1$survival[0, ] db_combined <- mp_merge_db(db1, db2)db1 <- mp_example_db(n_patients = 5, seed = 1) db2 <- db1 db1$survival <- db1$survival[0, ] db_combined <- mp_merge_db(db1, db2)
Returns a list of four ggplot objects summarising the database:
diagnosis distribution, age by sex, sample types, and top mutated genes.
Arrange with patchwork or cowplot as needed.
mp_plot_cohort_overview(db)mp_plot_cohort_overview(db)
db |
A |
A named list of four ggplot2::ggplot objects: diagnosis, age,
sample_types, top_genes.
db <- mp_example_db(n_patients = 20, seed = 1) plots <- mp_plot_cohort_overview(db) plots$diagnosisdb <- mp_example_db(n_patients = 20, seed = 1) plots <- mp_plot_cohort_overview(db) plots$diagnosis
Bar chart of SNV substitution types (C>A, C>G, C>T, T>A, T>C, T>G).
mp_plot_mutation_spectrum(db, sample_id = NULL)mp_plot_mutation_spectrum(db, sample_id = NULL)
db |
A |
sample_id |
Optional character vector of sample IDs to include.
If |
A ggplot2::ggplot object.
db <- mp_example_db(n_patients = 20, seed = 1) mp_plot_mutation_spectrum(db)db <- mp_example_db(n_patients = 20, seed = 1) mp_plot_mutation_spectrum(db)
Creates Kaplan-Meier curves from the survival table. Optionally stratifies by a clinical variable or gene mutation status.
mp_plot_survival(db, group_by = NULL, type = c("os", "pfs"))mp_plot_survival(db, group_by = NULL, type = c("os", "pfs"))
db |
A |
group_by |
Optional character string. If it matches a column in the
patients table (e.g., |
type |
Character; |
A ggplot2::ggplot object.
db <- mp_example_db(n_patients = 50, seed = 1) mp_plot_survival(db, type = "os") mp_plot_survival(db, group_by = "diagnosis", type = "os")db <- mp_example_db(n_patients = 50, seed = 1) mp_plot_survival(db, type = "os") mp_plot_survival(db, group_by = "diagnosis", type = "os")
Displays a timeline of events for a single patient: sample collections, report dates, and clinical measurements.
mp_plot_timeline(db, patient_id)mp_plot_timeline(db, patient_id)
db |
A |
patient_id |
A single patient ID. |
A ggplot2::ggplot object.
db <- mp_example_db(n_patients = 20, seed = 1) pid <- db$patients$patient_id[1] mp_plot_timeline(db, pid)db <- mp_example_db(n_patients = 20, seed = 1) pid <- db$patients$patient_id[1] mp_plot_timeline(db, pid)
Histogram or density plot of variant allele frequencies (VAF), optionally filtered by gene.
mp_plot_vaf_distribution(db, gene = NULL)mp_plot_vaf_distribution(db, gene = NULL)
db |
A |
gene |
Optional character vector of gene symbols to include. |
A ggplot2::ggplot object.
db <- mp_example_db(n_patients = 20, seed = 1) mp_plot_vaf_distribution(db) mp_plot_vaf_distribution(db, gene = "TP53")db <- mp_example_db(n_patients = 20, seed = 1) mp_plot_vaf_distribution(db) mp_plot_vaf_distribution(db, gene = "TP53")
Creates a tile plot showing variant classifications across samples and genes.
mp_plot_variant_landscape(db, genes = NULL, top_n = 20)mp_plot_variant_landscape(db, genes = NULL, top_n = 20)
db |
A |
genes |
Character vector of genes to display. If |
top_n |
Integer. Number of top genes to show when |
A ggplot2::ggplot object.
db <- mp_example_db(n_patients = 20, seed = 1) mp_plot_variant_landscape(db, top_n = 10)db <- mp_example_db(n_patients = 20, seed = 1) mp_plot_variant_landscape(db, top_n = 10)
Uses tidy evaluation to filter the patients table.
mp_query_patients(db, ...)mp_query_patients(db, ...)
db |
A |
... |
Filter expressions passed to |
A tibble of matching patients.
db <- mp_example_db(n_patients = 20, seed = 1) mp_query_patients(db, diagnosis == "Melanoma") mp_query_patients(db, age > 60, sex == "F")db <- mp_example_db(n_patients = 20, seed = 1) mp_query_patients(db, diagnosis == "Melanoma") mp_query_patients(db, age > 60, sex == "F")
Uses tidy evaluation to filter the samples table.
mp_query_samples(db, ...)mp_query_samples(db, ...)
db |
A |
... |
Filter expressions passed to |
A tibble of matching samples.
db <- mp_example_db(n_patients = 20, seed = 1) mp_query_samples(db, sample_type == "FFPE")db <- mp_example_db(n_patients = 20, seed = 1) mp_query_samples(db, sample_type == "FFPE")
Filter the variants table by gene, classification, VAF range, or variant type.
mp_query_variants( db, genes = NULL, classification = NULL, min_vaf = NULL, max_vaf = NULL, variant_type = NULL )mp_query_variants( db, genes = NULL, classification = NULL, min_vaf = NULL, max_vaf = NULL, variant_type = NULL )
db |
A |
genes |
Character vector of gene symbols to include. |
classification |
Character vector of classifications to include.
|
min_vaf |
Minimum variant allele frequency (inclusive). |
max_vaf |
Maximum variant allele frequency (inclusive). |
variant_type |
Character vector of variant types to include (e.g.,
|
A tibble of matching variants.
db <- mp_example_db(n_patients = 20, seed = 1) mp_query_variants(db, genes = c("TP53", "KRAS")) mp_query_variants(db, classification = "Pathogenic", min_vaf = 0.1)db <- mp_example_db(n_patients = 20, seed = 1) mp_query_variants(db, genes = c("TP53", "KRAS")) mp_query_variants(db, classification = "Pathogenic", min_vaf = 0.1)
Detect the file type from its extension and/or content, then dispatch to the appropriate parser.
mp_read_auto(path, source_name = NULL)mp_read_auto(path, source_name = NULL)
path |
Character scalar. Path to the file. |
source_name |
Optional original filename for an extensionless upload. Dispatch uses its basename, and the result retains that basename as source identity. A disposable copy is removed after reading. |
Extension mapping:
.vcf, .vcf.gz: mp_read_vcf
.fastq, .fq, .fastq.gz, .fq.gz:
mp_read_fastq
.bam: mp_read_bam
.xml: mp_read_xml_report
.pdf: mp_read_pdf_report
.xlsx, .xls, .csv: tries survival/clinical
format detection
A molpath_parsed object produced by the appropriate parser.
f <- system.file("extdata", "example.vcf", package = "molpathR") if (nzchar(f)) { result <- mp_read_auto(f) print(result) }f <- system.file("extdata", "example.vcf", package = "molpathR") if (nzchar(f)) { result <- mp_read_auto(f) print(result) }
Parse a BAM (Binary Alignment Map) file into a tidy tibble.
mp_read_bam(path, regions = NULL)mp_read_bam(path, regions = NULL)
path |
Character scalar. Path to a |
regions |
Character scalar or |
Uses Rsamtools::scanBam() when installed. Otherwise it calls
samtools view; if neither is available an informative error is raised.
Backend decoding errors are reported rather than triggering another reader.
A molpath_parsed object whose data slot is a
tibble with columns qname, flag,
rname, pos, mapq, cigar, seq, and
qual.
bam_file <- system.file("extdata", "example.bam", package = "molpathR") if (nzchar(bam_file)) { result <- mp_read_bam(bam_file) print(result) }bam_file <- system.file("extdata", "example.bam", package = "molpathR") if (nzchar(bam_file)) { result <- mp_read_bam(bam_file) print(result) }
Parse a FASTQ file into a tidy tibble of sequencing reads.
mp_read_fastq(path, n = NULL)mp_read_fastq(path, n = NULL)
path |
Character scalar. Path to a |
n |
Integer or |
Uses ShortRead when installed, streaming the first requested records rather than sampling. Otherwise a strict 4-line text parser is used. Invalid or incomplete records raise an error; backend parse errors are not hidden.
A molpath_parsed object whose data slot is a
tibble with columns read_id, sequence,
quality, and seq_length.
fq_file <- system.file("extdata", "example.fastq", package = "molpathR") if (nzchar(fq_file)) { result <- mp_read_fastq(fq_file, n = 100) print(result) }fq_file <- system.file("extdata", "example.fastq", package = "molpathR") if (nzchar(fq_file)) { result <- mp_read_fastq(fq_file, n = 100) print(result) }
Parse a clinical data export (CSV format) from a clinical information system such as Nexus.
mp_read_nexus_clinical(path_or_connection)mp_read_nexus_clinical(path_or_connection)
path_or_connection |
Character scalar. Path to the CSV file, or an open connection. |
A molpath_parsed object whose data slot is a
tibble with columns patient_id, parameter,
value, unit, date, and source.
clin_file <- system.file("extdata", "nexus_clinical.csv", package = "molpathR") if (nzchar(clin_file)) { result <- mp_read_nexus_clinical(clin_file) print(result) }clin_file <- system.file("extdata", "nexus_clinical.csv", package = "molpathR") if (nzchar(clin_file)) { result <- mp_read_nexus_clinical(clin_file) print(result) }
Parse an export from a pathology information system (e.g. Nexus) in either CSV or XML format.
mp_read_nexus_pathology(path_or_connection)mp_read_nexus_pathology(path_or_connection)
path_or_connection |
Character scalar. Path to the CSV or XML export file, or an open connection. |
A molpath_parsed object whose data slot is a
tibble with columns patient_id, name,
dob, sex, sample_id, sample_type,
diagnosis, and report_date.
nexus_file <- system.file("extdata", "nexus_pathology.csv", package = "molpathR") if (nzchar(nexus_file)) { result <- mp_read_nexus_pathology(nexus_file) print(result) }nexus_file <- system.file("extdata", "nexus_pathology.csv", package = "molpathR") if (nzchar(nexus_file)) { result <- mp_read_nexus_pathology(nexus_file) print(result) }
Extract structured information from a pathology PDF report using
pdftools::pdf_text() and regex-based section parsing. Complete extracted
pages and text are retained in metadata even when section heuristics match
only part of the report. Database report summaries use that complete text.
This does not perform OCR or validate extraction accuracy against the PDF.
mp_read_pdf_report(path, template = "generic")mp_read_pdf_report(path, template = "generic")
path |
Character scalar. Path to the |
template |
Character scalar. Template name controlling which regex
patterns are applied.
Currently |
A molpath_parsed object whose data slot is a
tibble with columns section and content
extracted from the report (Patient, Sample, Findings, Interpretation,
Recommendations).
pdf_file <- system.file("extdata", "report.pdf", package = "molpathR") if (nzchar(pdf_file)) { result <- mp_read_pdf_report(pdf_file) print(result) }pdf_file <- system.file("extdata", "report.pdf", package = "molpathR") if (nzchar(pdf_file)) { result <- mp_read_pdf_report(pdf_file) print(result) }
Read a survival data file in Excel or CSV format and standardise the column names to a canonical schema.
mp_read_survival(path)mp_read_survival(path)
path |
Character scalar. Path to a |
A molpath_parsed object whose data slot is a
tibble with columns patient_id, os_months,
os_status, pfs_months, and pfs_status.
surv_file <- system.file("extdata", "survival.csv", package = "molpathR") if (nzchar(surv_file)) { result <- mp_read_survival(surv_file) print(result) }surv_file <- system.file("extdata", "survival.csv", package = "molpathR") if (nzchar(surv_file)) { result <- mp_read_survival(surv_file) print(result) }
Parse a Variant Call Format (VCF 4.x) file and return a tidy tibble of variant calls.
mp_read_vcf(path)mp_read_vcf(path)
path |
Character scalar. Path to a |
A validated text parser preserves original ID, INFO, FORMAT and sample fields for single- and multi-sample VCFs, including gzip input. Installing VariantAnnotation does not change the returned representation. Header lines and declared sample names are retained in the result metadata.
A molpath_parsed object whose data slot is a
tibble with columns chrom, pos, id,
ref, alt, qual, filter, info, and any
sample-level columns present in the file, plus format when declared.
Sample names conflicting with these fixed output names are rejected.
vcf_file <- system.file("extdata", "example.vcf", package = "molpathR") if (nzchar(vcf_file)) { result <- mp_read_vcf(vcf_file) print(result) }vcf_file <- system.file("extdata", "example.vcf", package = "molpathR") if (nzchar(vcf_file)) { result <- mp_read_vcf(vcf_file) print(result) }
Parse a structured XML variant interpretation report (e.g. from Molecular Health or similar providers) into a tidy tibble.
mp_read_xml_report(path, provider = "molecular_health")mp_read_xml_report(path, provider = "molecular_health")
path |
Character scalar. Path to the |
provider |
Character scalar. Report provider template to apply.
Currently supported: |
A molpath_parsed object whose data slot is a
tibble with one row per variant and columns for patient
info, sample info, gene, variant description, classification, evidence
level, therapeutic implications and an explicit VAF proportion when supplied.
VAF must be between 0 and 1, inclusive; percentages or other units are not inferred.
xml_file <- system.file("extdata", "report.xml", package = "molpathR") if (nzchar(xml_file)) { result <- mp_read_xml_report(xml_file, provider = "molecular_health") print(result) }xml_file <- system.file("extdata", "report.xml", package = "molpathR") if (nzchar(xml_file)) { result <- mp_read_xml_report(xml_file, provider = "molecular_health") print(result) }
Starts an interactive Shiny application for exploring molecular pathology
data. If a molpath_db object is provided, the app launches pre-loaded
with that database. Otherwise, the user can upload data through the app
interface.
mp_run_app(db = NULL, ...)mp_run_app(db = NULL, ...)
db |
Optional |
... |
Additional arguments passed to |
CSV/TSV downloads require a working zip executable (or R_ZIPCMD).
Excel downloads additionally require the optional writexl package. Uploaded
files are staged and validated as one batch before changing session data.
This function does not return a value; it launches a Shiny app.
## Not run: # Launch with example data db <- mp_example_db() mp_run_app(db) # Launch empty — upload data in browser mp_run_app() ## End(Not run)## Not run: # Launch with example data db <- mp_example_db() mp_run_app(db) # Launch empty — upload data in browser mp_run_app() ## End(Not run)
Validates the database and saves it as a compressed RDS file. Serialization and read-back verification occur in a sibling temporary file before replacement. If replacement fails, the previous destination is restored or an explicit recovery path is reported. Use one writer per destination; this is not a multi-process database transaction. The file path is returned invisibly for use in pipelines.
mp_save_db(db, path)mp_save_db(db, path)
db |
A |
path |
Character string giving the file path to save to. Should
typically end in |
The file path, returned invisibly.
db <- mp_example_db(n_patients = 5, seed = 1) tmp <- tempfile(fileext = ".rds") mp_save_db(db, tmp) unlink(tmp)db <- mp_example_db(n_patients = 5, seed = 1) tmp <- tempfile(fileext = ".rds") mp_save_db(db, tmp) unlink(tmp)
Searches all text fields across all tables for the given term (case-insensitive).
mp_search(db, term)mp_search(db, term)
db |
A |
term |
A single search string. |
A named list of tibbles, one per table, containing rows that match the search term. Empty tibbles are omitted.
db <- mp_example_db(n_patients = 20, seed = 1) mp_search(db, "TP53")db <- mp_example_db(n_patients = 20, seed = 1) mp_search(db, "TP53")
Computes summary statistics across all layers of the database.
mp_summary(db)mp_summary(db)
db |
A |
An S3 object of class molpath_summary (a named list) containing
n_patients, n_samples, n_variants, n_reports, n_clinical,
diagnosis_distribution, variant_gene_counts, classification_distribution,
sample_type_distribution, date_range, and completeness.
db <- mp_example_db(n_patients = 20, seed = 1) mp_summary(db)db <- mp_example_db(n_patients = 20, seed = 1) mp_summary(db)
Checks 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.
mp_validate_db(db)mp_validate_db(db)
db |
A |
The following referential integrity checks are performed:
All patient_id values in the samples table exist in patients.
All sample_id values in the variants table exist in samples.
All sample_id values in the reports table exist in samples.
All patient_id values in the clinical table exist in patients.
All patient_id values in the survival table exist in patients.
When called interactively, results are printed using cli formatting.
Invisibly, a list with three elements:
Logical. TRUE if no referential integrity issues were found.
Character vector of issue descriptions (empty if valid).
Named numeric vector with percentages of patients
having data in each table (e.g., pct_with_variants,
pct_with_survival).
db <- mp_example_db(n_patients = 10, seed = 1) validation <- mp_validate_db(db) validation$validdb <- mp_example_db(n_patients = 10, seed = 1) validation <- mp_validate_db(db) validation$valid
Constructs a molpath_db object, which is a list of linked tibbles
representing the core data model for molecular pathology workflows.
new_molpath_db( patients = tibble::tibble(patient_id = character(), age = integer(), sex = character(), diagnosis = character()), samples = tibble::tibble(sample_id = character(), patient_id = character(), sample_type = character(), date = as.Date(character()), source_file = character()), variants = tibble::tibble(sample_id = character(), gene = character(), variant = character(), classification = character(), vaf = double()), reports = tibble::tibble(sample_id = character(), report_type = character(), report_date = as.Date(character()), summary_text = character(), source_file = character()), clinical = tibble::tibble(patient_id = character(), parameter = character(), value = character(), date = as.Date(character()), source = character()), survival = tibble::tibble(patient_id = character(), os_months = double(), os_status = integer(), pfs_months = double(), pfs_status = integer()), metadata = list(creation_date = Sys.time(), source_files = character(), parser_versions = list()) )new_molpath_db( patients = tibble::tibble(patient_id = character(), age = integer(), sex = character(), diagnosis = character()), samples = tibble::tibble(sample_id = character(), patient_id = character(), sample_type = character(), date = as.Date(character()), source_file = character()), variants = tibble::tibble(sample_id = character(), gene = character(), variant = character(), classification = character(), vaf = double()), reports = tibble::tibble(sample_id = character(), report_type = character(), report_date = as.Date(character()), summary_text = character(), source_file = character()), clinical = tibble::tibble(patient_id = character(), parameter = character(), value = character(), date = as.Date(character()), source = character()), survival = tibble::tibble(patient_id = character(), os_months = double(), os_status = integer(), pfs_months = double(), pfs_status = integer()), metadata = list(creation_date = Sys.time(), source_files = character(), parser_versions = list()) )
patients |
A tibble with columns |
samples |
A tibble with columns |
variants |
A tibble with columns |
reports |
A tibble with columns |
clinical |
A tibble with columns |
survival |
A tibble with columns |
metadata |
A list containing |
An S3 object of class molpath_db.
db <- new_molpath_db() dbdb <- new_molpath_db() db
Constructs a molpath_parsed object representing the result of parsing a
single data source. This serves as an intermediate representation before
data is integrated into a molpath_db.
new_molpath_parsed( data = tibble::tibble(), source_type = character(1L), source_file = character(1L), parse_date = Sys.time(), metadata = list() )new_molpath_parsed( data = tibble::tibble(), source_type = character(1L), source_file = character(1L), parse_date = Sys.time(), metadata = list() )
data |
A tibble (or data frame) containing the parsed data. |
source_type |
A character string identifying the source type (e.g.,
|
source_file |
A character string with the path to the source file. |
parse_date |
A |
metadata |
A named list of parser-specific provenance, such as original VCF headers. |
An S3 object of class molpath_parsed.
parsed <- new_molpath_parsed( data = tibble::tibble(gene = "BRAF", variant = "V600E"), source_type = "vcf", source_file = "sample1.vcf" ) parsedparsed <- new_molpath_parsed( data = tibble::tibble(gene = "BRAF", variant = "V600E"), source_type = "vcf", source_file = "sample1.vcf" ) parsed
Displays a human-readable summary of a molpath_db, including table
dimensions, date ranges, and data completeness.
## S3 method for class 'molpath_db' print(x, ...)## S3 method for class 'molpath_db' print(x, ...)
x |
A |
... |
Additional arguments (ignored). |
The molpath_db object (invisibly).
Displays a compact summary of a parsed data source, including source metadata and a preview of the data.
## S3 method for class 'molpath_parsed' print(x, ...)## S3 method for class 'molpath_parsed' print(x, ...)
x |
A |
... |
Additional arguments (ignored). |
The molpath_parsed object (invisibly).
Prints a detailed summary of a molpath_db, including per-table
completeness, unique counts for key columns, and metadata.
## S3 method for class 'molpath_db' summary(object, ...)## S3 method for class 'molpath_db' summary(object, ...)
object |
A |
... |
Additional arguments (ignored). |
The molpath_db object (invisibly).
Prints a detailed summary of a parsed data source, including column types, missing value counts, and a preview of distinct values.
## S3 method for class 'molpath_parsed' summary(object, ...)## S3 method for class 'molpath_parsed' summary(object, ...)
object |
A |
... |
Additional arguments (ignored). |
The molpath_parsed object (invisibly).
Checks that all required tables are present, that each is a tibble, and that
mandatory columns, types, value ranges and primary identifiers are valid.
Incomplete cross-table links are reported as warnings; use mp_validate_db()
for a structured link report. Missing parent evidence is not fabricated.
validate_molpath_db(x)validate_molpath_db(x)
x |
An object of class |
The original molpath_db object (invisibly). Structural or value
corruption raises an error. Incomplete links warn and remain unchanged.
db <- new_molpath_db() validate_molpath_db(db)db <- new_molpath_db() validate_molpath_db(db)