knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
options(timeout = 600)
As seen in other vignettes omock provides you with functionality to build. synthetic datasets. omock also provides some prebuilt synthetics datasets, those datasets are widely available and were created by the OHDSI community.
library(omock)
The available datasets are listed below:
niceSize <- function(x) { purrr::map_chr(x, \(x) { if (x < 1024) { x <- fprintf("%i B", x) } else if (x < 1024**2) { x <- x / 1024 x <- paste(formatC(x, digits = 3, format = "fg", flag = "#"), "kB") } else if (x < 1024**3) { x <- x / 1024**2 x <- paste(formatC(x, digits = 3, format = "fg", flag = "#"), "MB") } else { x <- x / 1024**3 x <- paste(formatC(x, digits = 3, format = "fg", flag = "#"), "GB") } stringr::str_squish(x) }) } mockDatasets |> dplyr::mutate( size = niceSize(.data$size), link = paste0("[🔗](", .data$url, ")"), dplyr::across( c("number_individuals", "number_records", "number_concepts"), \(x) format(x, big.mark = ",") ) ) |> dplyr::select( "datasetName" = "dataset_name", "CDM name" = "cdm_name", "CDM version" = "cdm_version", "Size" = "size", "Number individuals" = "number_individuals", "Number records" = "number_records", "Number concepts" = "number_concepts", "Link" = "link" ) |> gt::gt() |> gt::fmt_markdown("Link")
For more details on those synthetic datasets you can check the OmopSketch ShinyApp: https://dpa-pde-oxford.shinyapps.io/OmopSketchCharacterisation/ that characterise those datasets.
You can also check programatically which are the synthetic datasets that you can use with:
availableMockDatasets()
To prevent having to download the dataset everytime that you want to use a dataset, it is recommended to set up a permanent folder where the synthetic datasets are stored. This allows the user to have to download each dataset only once. To set up a permanent location for your dataset please create an environmental variable (usethis::edit_r_environ()) pointing to an existing folder like:
OMOP_DATA_FOLDER="path/to/my/folder"
This folder is in fact defined by omopgenerics and it is used also by other packages. You can check the folder by using the following function:
omopDataFolder()
Note that if you would have set up an environment variable the message of temporary folder would not appear and you would see the path to you folder.
You can download a dataset using downloadMockDataset():
downloadMockDataset(datasetName = "GiBleed")
This will download the dataset and store it as a zip file in you OMOP_DATA_FOLDER:
list.files(path = omopDataFolder(), recursive = TRUE)
Note datasets are stored in a subfolder named mockDatasets to account for the fact that this folder is used also by other packages to store data.
You can easily create a mock dataset reference using the mockCdmFromDataset() function:
cdm <- mockCdmFromDataset(datasetName = "GiBleed") cdm
Downloading the dataset before hand was not needed and that if you try to create a reference of a dataset that is not downloaded it will be downloaded in the process (in interactive sessions you will be asked):
cdm <- mockCdmFromDataset(datasetName = "GiBleed") cdm
Finally, you can also insert the local dataset into a duckdb connection using the source argument:
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm
Note the local datasets can be inserted in many different sources using the function insertCdmTo() from omopgenerics.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.