Validate All Studies in a metawoRld Project
validate_world.Rd
Iterates through all study subdirectories within the project's data/
directory and runs validate_study()
on each one to check conformity
against the project schema and internal consistency.
Arguments
- path
Character string. The path to the root directory of the metawoRld project. Defaults to the current working directory (
.
).- check_linkages
Logical. Passed down to
validate_study()
for each study. Should the consistency checks betweendata.csv
andmetadata.yml
be performed? Defaults toTRUE
.
Value
A list containing:
overall_status
Character string: "PASS" if all studies validated successfully, "FAIL" otherwise.
validated_studies
Integer: The number of study directories checked.
passed_studies
Integer: The number of studies that passed validation.
failed_studies_count
Integer: The number of studies that failed validation.
failed_studies_details
A list (named by
study_id
) containing the error messages for studies that failed validation. Empty if all passed.
Prints informative messages about the validation progress and summary.
Examples
if (FALSE) { # \dontrun{
# --- Setup: Create a project, add one valid study and one template ---
proj_path <- file.path(tempdir(), "validate_world_test")
create_metawoRld(
path = proj_path,
project_name = "Validate World Test",
project_description = "Testing validate_world()"
)
# Add a valid study
meta1 <- list(
study_id = "S1", title = "Valid Study", authors = list("A"), year = 2021,
journal = "J1", study_design="Cohort", country="X", sample_type="Serum",
outcome_groups = list(g1=list(name="Case", def="..."), g2=list(name="Ctrl", def="...")),
measurement_methods = list(m1=list(unit="pg/mL", analysis_type="E"))
)
data1 <- data.frame(measurement_id="m1a", method_ref_id="m1", cytokine_name="CK1",
group_label="g1", gestational_age_timing="T1", n=10,
statistic_type="mean_sd", value1=5, value2=1)
add_study_data(proj_path, "S1", meta1, data1)
# Add a template study (which will likely fail validation initially)
add_study_template(proj_path, "TemplateStudy")
# Add an empty folder (should be skipped by validation logic within validate_study)
fs::dir_create(file.path(proj_path, "data", "EmptyFolder"))
# Add a folder with only metadata.yml (should fail in validate_study)
fs::dir_create(file.path(proj_path, "data", "MetadataOnly"))
file.copy(file.path(proj_path, "data", "S1", "metadata.yml"),
file.path(proj_path, "data", "MetadataOnly", "metadata.yml"))
# --- Run validation ---
validation_results <- validate_world(path = proj_path)
# Print the results
print(validation_results)
# --- Clean up ---
unlink(proj_path, recursive = TRUE)
} # }