Introduction
Introduction.Rmd
library(PETDiagnostics)
library(CDMConnector)
#> Warning: package 'CDMConnector' was built under R version 4.3.3
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(DT)
Here we use the mockdata for training purposes. But ideally, you use your real data, so just connect to your database (if you are not already connected). The article “Run this” depicts an example code of how to connect to the database and add the mothertable and babytable to the cdm.
The idea would be to name these new cdm tables in the future mothertable and babytable.
cdm <- PETDiagnostics::mockPregnancy(mothertable = NULL,
babytable = NULL,
pregnancy_size = 100,
fetus_size = 110,
seed = 1)
We can run all available checks at the same time using the ´executeChecks()´ function. This will return a list which contains the results of each check (information on each check available in the Checks article) You can also chose only individual checks to run (see Summary article)
PETDiagnostics::executeChecks (
mothertable = cdm$mothertable,
babytable = cdm$babytable,
checks = c("overview","annualOverview","missing", "unknown","gestationalAge","datesAgeDist","outcomeMode",
"fetusesLiveborn","fetusid","weightDist","bitSet"),
minCellCount = 5,
minGestAge_Days = 21,
verbose = FALSE)
Thecdm
is the database reference of the OMOP CDM using
the CDMConnector
package.
The mothertable
is the mothertable
in the CDM.
The babytable
is the babytable
in the CDM.
checks
allows to select the checks to be executed, by
default, all the checks will be run. The minCellCount
is
minimum number of events to report, numbers lower than this will be
obscured. The number zero will not be obscured´,
minGestAge_Days
implies the number of minimum number of
gestational age that may be the minimum for pregnancies to be
recorded.
resultList<-PETDiagnostics::executeChecks(mothertable = cdm$mothertable,
babytable = cdm$babytable)
We can then check what results available from ´executeChecks()´ by
names(resultList)
#> [1] "PETOverviewMother" "AnnualPETOverviewMother"
#> [3] "PETOverviewBaby" "missingSummaryMother"
#> [5] "missingSummaryBaby" "unknownSummaryMother"
#> [7] "gestationalAgeMatch" "valueDatesAgeDist"
#> [9] "outcomeModeMatch" "fetusesLivebornNumber"
#> [11] "fetusIdMatch" "valueWeightDist"
#> [13] "bitSetOverviewAll" "bitSetOverviewMother"
#> [15] "bitSetOverviewBaby"
Let’s take a look at the results. the missingSummaryMother contains all the variables, their count of missings, and the proportion in relation to all pregnancies recorded in the mothertable.
DT::datatable(resultList$missingSummaryMother,
rownames = FALSE
)
After running the checks, we can write the CSV files into a zip file
to disk using the writeResultToDisk()
function.
PETDiagnostics::writeResultToDisk(resultList=resultList,
databaseId = "your_database_id",
outputFolder = tempdir())