Title: | Methods and Classes for the OMOP Common Data Model |
---|---|
Description: | Provides definitions of core classes and methods used by analytic pipelines that query the OMOP (Observational Medical Outcomes Partnership) common data model. |
Authors: | Martí Català [aut, cre] , Edward Burn [aut] , Mike Du [ctb] , Yuchen Guo [ctb] , Adam Black [ctb] , Marta Alcalde-Herraiz [ctb] |
Maintainer: | Martí Català <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.4.1 |
Built: | 2024-12-05 19:41:52 UTC |
Source: | CRAN |
Subset a cdm reference object.
## S3 method for class 'cdm_reference' x[[name]]
## S3 method for class 'cdm_reference' x[[name]]
x |
A cdm reference |
name |
The name or index of the table to extract from the cdm object. |
A single cdm table reference
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdm[["person"]]
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdm[["person"]]
Assign a table to a cdm reference.
## S3 replacement method for class 'cdm_reference' cdm[[name]] <- value
## S3 replacement method for class 'cdm_reference' cdm[[name]] <- value
cdm |
A cdm reference. |
name |
Name where to assign the new table. |
value |
Table with the same source than the cdm object. |
The cdm reference.
Subset a cdm reference object.
## S3 method for class 'cdm_reference' x$name
## S3 method for class 'cdm_reference' x$name
x |
A cdm reference. |
name |
The name of the table to extract from the cdm object. |
A single cdm table reference
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdm$person
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdm$person
Assign an table to a cdm reference.
## S3 replacement method for class 'cdm_reference' cdm$name <- value
## S3 replacement method for class 'cdm_reference' cdm$name <- value
cdm |
A cdm reference. |
name |
Name where to assign the new table. |
value |
Table with the same source than the cdm object. |
The cdm reference.
library(omopgenerics) cdm <- cdmFromTables( tables = list( "person" = dplyr::tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = dplyr::tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdm$person
library(omopgenerics) cdm <- cdmFromTables( tables = list( "person" = dplyr::tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = dplyr::tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdm$person
Required columns for each of the achilles result tables
achillesColumns(table, version = "5.3", onlyRequired = lifecycle::deprecated())
achillesColumns(table, version = "5.3", onlyRequired = lifecycle::deprecated())
table |
Table for which to see the required columns. One of "achilles_analysis", "achilles_results", or "achilles_results_dist". |
version |
Version of the OMOP Common Data Model. |
onlyRequired |
deprecated. |
Character vector with the column names
library(omopgenerics) achillesColumns("achilles_analysis") achillesColumns("achilles_results") achillesColumns("achilles_results_dist")
library(omopgenerics) achillesColumns("achilles_analysis") achillesColumns("achilles_results") achillesColumns("achilles_results_dist")
Names of the tables that contain the results of achilles analyses
achillesTables(version = "5.3")
achillesTables(version = "5.3")
version |
Version of the OMOP Common Data Model. |
Names of the tables that are contain the results from the achilles analyses
library(omopgenerics) achillesTables()
library(omopgenerics) achillesTables()
Identifies and returns the unique values in additional_name column.
additionalColumns(result)
additionalColumns(result)
result |
A tibble. |
Unique values of the additional name column.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> additionalColumns() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> additionalColumns() }
<summarised_result>
objectAdd settings columns to a <summarised_result>
object
addSettings(result, settingsColumn = settingsColumns(result))
addSettings(result, settingsColumn = settingsColumns(result))
result |
A |
settingsColumn |
Settings to be added as columns, by default
|
A <summarised_result>
object with the added setting columns.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> addSettings() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> addSettings() }
Assert that an object is a character and fulfill certain conditions.
assertCharacter( x, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, minNumCharacter = 0, call = parent.frame(), msg = NULL )
assertCharacter( x, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, minNumCharacter = 0, call = parent.frame(), msg = NULL )
x |
Variable to check. |
length |
Required length. If |
na |
Whether it can contain NA values. |
null |
Whether it can be NULL. |
unique |
Whether it has to contain unique elements. |
named |
Whether it has to be named. |
minNumCharacter |
Minimum number of characters that all elements must have. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert that an object is within a certain oprtions.
assertChoice( x, choices, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
assertChoice( x, choices, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
x |
Variable to check. |
choices |
Options that x is allowed to be. |
length |
Required length. If |
na |
Whether it can contain NA values. |
null |
Whether it can be NULL. |
unique |
Whether it has to contain unique elements. |
named |
Whether it has to be named. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert that an object has a certain class.
assertClass( x, class, length = NULL, null = FALSE, all = FALSE, extra = TRUE, call = parent.frame(), msg = NULL )
assertClass( x, class, length = NULL, null = FALSE, all = FALSE, extra = TRUE, call = parent.frame(), msg = NULL )
x |
To check. |
class |
Expected class or classes. |
length |
Required length. If |
null |
Whether it can be NULL. |
all |
Whether it should have all the classes or only at least one of them. |
extra |
Whether the object can have extra classes. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert Date
assertDate( x, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
assertDate( x, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
x |
Expression to check. |
length |
Required length. |
na |
Whether it can contain NA values. |
null |
Whether it can be NULL. |
unique |
Whether it has to contain unique elements. |
named |
Whether it has to be named. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
x
Assert that an object is a list.
assertList( x, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, class = NULL, call = parent.frame(), msg = NULL )
assertList( x, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, class = NULL, call = parent.frame(), msg = NULL )
x |
Variable to check. |
length |
Required length. If |
na |
Whether it can contain NA values. |
null |
Whether it can be NULL. |
unique |
Whether it has to contain unique elements. |
named |
Whether it has to be named. |
class |
Class that the elements must have. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert that an object is a logical.
assertLogical( x, length = NULL, na = FALSE, null = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
assertLogical( x, length = NULL, na = FALSE, null = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
x |
Variable to check. |
length |
Required length. If |
na |
Whether it can contain NA values. |
null |
Whether it can be NULL. |
named |
Whether it has to be named. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert that an object is a numeric.
assertNumeric( x, integerish = FALSE, min = -Inf, max = Inf, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
assertNumeric( x, integerish = FALSE, min = -Inf, max = Inf, length = NULL, na = FALSE, null = FALSE, unique = FALSE, named = FALSE, call = parent.frame(), msg = NULL )
x |
Variable to check. |
integerish |
Whether it has to be an integer |
min |
Minimum value that the object can be. |
max |
Maximum value that the object can be. |
length |
Required length. If |
na |
Whether it can contain NA values. |
null |
Whether it can be NULL. |
unique |
Whether it has to contain unique elements. |
named |
Whether it has to be named. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert that an object is a table.
assertTable( x, class = NULL, numberColumns = NULL, numberRows = NULL, columns = character(), allowExtraColumns = TRUE, null = FALSE, unique = FALSE, call = parent.frame(), msg = NULL )
assertTable( x, class = NULL, numberColumns = NULL, numberRows = NULL, columns = character(), allowExtraColumns = TRUE, null = FALSE, unique = FALSE, call = parent.frame(), msg = NULL )
x |
Variable to check. |
class |
A class that the table must have: "tbl", "data.fram", "tbl_sql", ... |
numberColumns |
Number of columns that it has to contain. |
numberRows |
Number of rows that it has to contain. |
columns |
Name of the columns required. |
allowExtraColumns |
Whether extra columns are allowed. |
null |
Whether it can be NULL. |
unique |
Whether it has to contain unique rows. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Assert that an expression is TRUE.
assertTrue(x, null = FALSE, call = parent.frame(), msg = NULL)
assertTrue(x, null = FALSE, call = parent.frame(), msg = NULL)
x |
Expression to check. |
null |
Whether it can be NULL. |
call |
Call argument that will be passed to |
msg |
Custom error message. |
Get attrition from an object.
attrition(x)
attrition(x)
x |
An object for which to get an attrition summary. |
A table with the attrition.
Get cohort attrition from a cohort_table object.
## S3 method for class 'cohort_table' attrition(x)
## S3 method for class 'cohort_table' attrition(x)
x |
A cohort_table |
A table with the attrition.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), cohort_end_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) attrition(cdm$cohort1)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), cohort_end_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) attrition(cdm$cohort1)
Bind two or more objects of the same class.
bind(...)
bind(...)
... |
Objects to bind. |
New object.
Bind two or more cohort tables
## S3 method for class 'cohort_table' bind(..., name)
## S3 method for class 'cohort_table' bind(..., name)
... |
Generated cohort set objects to bind. At least two must be provided. |
name |
Name of the new generated cohort set. |
The cdm object with a new generated cohort set containing all of the cohorts passed.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cohort1 <- tibble( cohort_definition_id = 1, subject_id = 1:3, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") ) cohort2 <- tibble( cohort_definition_id = c(2, 2, 3, 3, 3), subject_id = c(1, 2, 3, 1, 2), cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") ) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock", cohortTables = list("cohort1" = cohort1, "cohort2" = cohort2) ) cdm <- bind(cdm$cohort1, cdm$cohort2, name = "cohort3") settings(cdm$cohort3) cdm$cohort3
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cohort1 <- tibble( cohort_definition_id = 1, subject_id = 1:3, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") ) cohort2 <- tibble( cohort_definition_id = c(2, 2, 3, 3, 3), subject_id = c(1, 2, 3, 1, 2), cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") ) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock", cohortTables = list("cohort1" = cohort1, "cohort2" = cohort2) ) cdm <- bind(cdm$cohort1, cdm$cohort2, name = "cohort3") settings(cdm$cohort3) cdm$cohort3
Bind two or summarised_result objects
## S3 method for class 'summarised_result' bind(...)
## S3 method for class 'summarised_result' bind(...)
... |
summarised_result objects |
A summarised_result object the merged objects.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock", cohortTables = list("cohort1" = tibble( cohort_definition_id = 1, subject_id = 1:3, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") )) ) result1 <- summary(cdm) result2 <- summary(cdm$cohort1) mergedResult <- bind(result1, result2) mergedResult
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock", cohortTables = list("cohort1" = tibble( cohort_definition_id = 1, subject_id = 1:3, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") )) ) result1 <- summary(cdm) result2 <- summary(cdm$cohort1) mergedResult <- bind(result1, result2) mergedResult
Create a cdm object from local tables
cdmFromTables(tables, cdmName, cohortTables = list(), cdmVersion = NULL)
cdmFromTables(tables, cdmName, cohortTables = list(), cdmVersion = NULL)
tables |
List of tables to be part of the cdm object. |
cdmName |
Name of the cdm object. |
cohortTables |
List of tables that contains cohort, cohort_set and cohort_attrition can be provided as attributes. |
cdmVersion |
Version of the cdm_reference |
A cdm_reference
object.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" )
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" )
Get the name of a cdm_reference associated object
cdmName(x)
cdmName(x)
x |
A cdm_reference or cdm_table object. |
Name of the cdm_reference.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmName(cdm) cdmName(cdm$person)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmName(cdm) cdmName(cdm$person)
cdm_reference
of a cdm_table
.Get the cdm_reference
of a cdm_table
.
cdmReference(table)
cdmReference(table)
table |
A cdm_table. |
A cdm_reference.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmReference(cdm$person)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmReference(cdm$person)
Restrict the cdm object to a subset of tables.
cdmSelect(cdm, ...)
cdmSelect(cdm, ...)
cdm |
A cdm_reference object. |
... |
Selection of tables to use, it supports tidyselect expressions. |
A cdm_reference with only the specified tables.
cdm <- emptyCdmReference("my cdm") cdm cdm |> cdmSelect("person")
cdm <- emptyCdmReference("my cdm") cdm cdm |> cdmSelect("person")
Get the cdmSource of an object.
cdmSource(x, cdm = lifecycle::deprecated())
cdmSource(x, cdm = lifecycle::deprecated())
x |
Object to obtain the cdmSource. |
cdm |
Deprecated, use x please. |
A cdm_source object.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmSource(cdm) cdmSource(cdm$person)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmSource(cdm) cdmSource(cdm$person)
cdmSourceType(cdm)
cdmSourceType(cdm)
cdm |
A cdm_reference object. |
A character vector with the type of source of the cdm_reference object.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmSourceType(cdm)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmSourceType(cdm)
This is an internal developer focused function that creates a cdm_table from a table that shares the source but it is not a cdm_table. Please use insertTable if you want to insert a table to a cdm_reference object.
cdmTableFromSource(src, value)
cdmTableFromSource(src, value)
src |
A cdm_source object. |
value |
A table that shares source with the cdm_reference object. |
A cdm_table.
Get the version of an object.
cdmVersion(x)
cdmVersion(x)
x |
Object to know the cdm version of an object. |
A character vector indicating the cdm version.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmVersion(cdm) cdmVersion(cdm$person)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) cdmVersion(cdm) cdmVersion(cdm$person)
checkCohortRequirements( cohort, checkEndAfterStart = TRUE, checkOverlappingEntries = TRUE, checkMissingValues = TRUE, checkInObservation = TRUE, type = "error", call = parent.frame() )
checkCohortRequirements( cohort, checkEndAfterStart = TRUE, checkOverlappingEntries = TRUE, checkMissingValues = TRUE, checkInObservation = TRUE, type = "error", call = parent.frame() )
cohort |
|
checkEndAfterStart |
If TRUE a check that all cohort end dates come on or after cohort start date will be performed. |
checkOverlappingEntries |
If TRUE a check that no individuals have overlapping cohort entries will be performed. |
checkMissingValues |
If TRUE a check that there are no missing values in required fields will be performed. |
checkInObservation |
If TRUE a check that cohort entries are within the individuals observation periods will be performed. |
type |
Can be either "error" or "warning". If "error" any check failure will result in an error, whereas if "warning" any check failure will result in a warning. |
call |
The call for which to return the error message. |
An error will be returned if any of the selected checks fail.
Get codelist from a cohort_table object.
cohortCodelist( cohortTable, cohortId, type = c("index event", "inclusion criteria", "exclusion criteria", "exit criteria") )
cohortCodelist( cohortTable, cohortId, type = c("index event", "inclusion criteria", "exclusion criteria", "exit criteria") )
cohortTable |
A cohort_table object. |
cohortId |
A particular cohort definition id that is present in the cohort table. |
type |
The reason for the codelist. Can be "index event", "inclusion criteria", or "exit criteria". |
A table with the codelists used.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), cohort_end_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )) ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cdm$cohort1 <- newCohortTable(table = cdm$cohort1, cohortCodelistRef = dplyr::tibble( cohort_definition_id = c(1,1,1,2,2), codelist_name =c("disease X", "disease X", "disease X", "disease Y", "disease Y"), concept_id = c(1,2,3,4,5), type = "index event" )) cohortCodelist(cdm$cohort1, cohortId = 1, type = "index event")
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), cohort_end_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )) ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cdm$cohort1 <- newCohortTable(table = cdm$cohort1, cohortCodelistRef = dplyr::tibble( cohort_definition_id = c(1,1,1,2,2), codelist_name =c("disease X", "disease X", "disease X", "disease Y", "disease Y"), concept_id = c(1,2,3,4,5), type = "index event" )) cohortCodelist(cdm$cohort1, cohortId = 1, type = "index event")
Required columns for a generated cohort set.
cohortColumns(table, version = "5.3")
cohortColumns(table, version = "5.3")
table |
Either |
version |
Version of the OMOP Common Data Model. |
Character vector with the column names
Required columns
library(omopgenerics) cohortColumns("cohort")
library(omopgenerics) cohortColumns("cohort")
Get cohort counts from a cohort_table object.
cohortCount(cohort)
cohortCount(cohort)
cohort |
A cohort_table object. |
A table with the counts.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), cohort_end_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cohortCount(cdm$cohort1)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), cohort_end_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cohortCount(cdm$cohort1)
Cohort tables that a cdm reference can contain in the OMOP Common Data Model.
cohortTables(version = "5.3")
cohortTables(version = "5.3")
version |
Version of the OMOP Common Data Model. |
cohort tables
library(omopgenerics) cohortTables()
library(omopgenerics) cohortTables()
Retrieves the cdm reference into a local cdm.
## S3 method for class 'cdm_reference' collect(x, ...)
## S3 method for class 'cdm_reference' collect(x, ...)
x |
A cdm_reference object. |
... |
For compatibility only, not used. |
A local cdm_reference.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = dplyr::tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = dplyr::tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) collect(cdm)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = dplyr::tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = dplyr::tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) collect(cdm)
cohort_table
object.To collect a cohort_table
object.
## S3 method for class 'cohort_table' collect(x, ...)
## S3 method for class 'cohort_table' collect(x, ...)
x |
|
... |
Not used (for compatibility). |
A data frame with the cohort_table
Provide all combinations of strata levels.
combineStrata(levels)
combineStrata(levels)
levels |
Vector of all strata levels to combine. |
A vector of all combinations of strata.
Store results in a table.
## S3 method for class 'cdm_table' compute( x, name = NULL, temporary = NULL, overwrite = TRUE, logPrefix = NULL, ... )
## S3 method for class 'cdm_table' compute( x, name = NULL, temporary = NULL, overwrite = TRUE, logPrefix = NULL, ... )
x |
Table in the cdm. |
name |
Name to store the table with. |
temporary |
Whether to store table temporarily (TRUE) or permanently (FALSE). |
overwrite |
Whether to overwrite previously existing table with name same. |
logPrefix |
Prefix to use when saving a log file. |
... |
For compatibility (not used). |
Reference to a table in the cdm
Drop a table from a cdm object.
dropSourceTable(cdm, name)
dropSourceTable(cdm, name)
cdm |
A cdm reference. |
name |
Name(s) of the table(s) to insert. Tidyselect statements are supported. |
The table in the cdm reference.
Drop a table from a cdm object.
dropTable(cdm, name)
dropTable(cdm, name)
cdm |
A cdm reference. |
name |
Name(s) of the table(s) to drop Tidyselect statements are supported. |
The cdm reference.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), cohort_end_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cdm cdm <- dropTable(cdm = cdm, name = "cohort1") cdm
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), cohort_end_date = as.Date(c( "2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01" )), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cdm cdm <- dropTable(cdm = cdm, name = "cohort1") cdm
Create an empty achilles table
emptyAchillesTable(cdm, name)
emptyAchillesTable(cdm, name)
cdm |
A cdm_reference to create the table. |
name |
Name of the table to create. |
The cdm_reference with an achilles empty table
library(omopgenerics) cdm <- emptyCdmReference("my_example_cdm") emptyAchillesTable(cdm = cdm, name = "achilles_results")
library(omopgenerics) cdm <- emptyCdmReference("my_example_cdm") emptyAchillesTable(cdm = cdm, name = "achilles_results")
Create an empty cdm_reference
emptyCdmReference(cdmName, cdmVersion = NULL)
emptyCdmReference(cdmName, cdmVersion = NULL)
cdmName |
Name of the cdm_reference |
cdmVersion |
Version of the cdm_reference |
An empty cdm_reference
library(omopgenerics) emptyCdmReference(cdmName = "my_example_cdm")
library(omopgenerics) emptyCdmReference(cdmName = "my_example_cdm")
codelist
object.Empty codelist
object.
emptyCodelist()
emptyCodelist()
An empty codelist object.
emptyCodelist()
emptyCodelist()
codelist
object.Empty codelist
object.
emptyCodelistWithDetails()
emptyCodelistWithDetails()
An empty codelist object.
emptyCodelistWithDetails()
emptyCodelistWithDetails()
Create an empty cohort_table object
emptyCohortTable(cdm, name, overwrite = TRUE)
emptyCohortTable(cdm, name, overwrite = TRUE)
cdm |
A cdm_reference to create the table. |
name |
Name of the table to create. |
overwrite |
Whether to overwrite an existent table. |
The cdm_reference with an empty cohort table
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) cdm <- emptyCohortTable(cdm, "my_empty_cohort") cdm cdm$my_empty_cohort settings(cdm$my_empty_cohort) attrition(cdm$my_empty_cohort) cohortCount(cdm$my_empty_cohort)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) cdm <- emptyCohortTable(cdm, "my_empty_cohort") cdm cdm$my_empty_cohort settings(cdm$my_empty_cohort) attrition(cdm$my_empty_cohort) cohortCount(cdm$my_empty_cohort)
Create an empty omop table
emptyOmopTable(cdm, name)
emptyOmopTable(cdm, name)
cdm |
A cdm_reference to create the table. |
name |
Name of the table to create. |
The cdm_reference with an empty cohort table
library(omopgenerics) person <- dplyr::tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- dplyr::tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) cdm <- emptyOmopTable(cdm, "drug_exposure") cdm$drug_exposure
library(omopgenerics) person <- dplyr::tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- dplyr::tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) cdm <- emptyOmopTable(cdm, "drug_exposure") cdm$drug_exposure
summarised_result
object.Empty summarised_result
object.
emptySummarisedResult(settings = NULL)
emptySummarisedResult(settings = NULL)
settings |
Tibble/data.frame with the settings of the empty
summarised_result. It has to contain at least |
An empty summarised_result
object.
library(omopgenerics) emptySummarisedResult()
library(omopgenerics) emptySummarisedResult()
estimate_type
column.Choices that can be present in estimate_type
column.
estimateTypeChoices()
estimateTypeChoices()
A character vector with the options that can be present in
estimate_type
column in the summarised_result objects.
library(omopgenerics) estimateTypeChoices()
library(omopgenerics) estimateTypeChoices()
Export a codelist object.
exportCodelist(x, path, type = "json")
exportCodelist(x, path, type = "json")
x |
A codelist |
path |
Path to where files will be created. |
type |
Type of files to export. Currently 'json' and 'csv' are supported. |
Files with codelists
Export a concept set expression.
exportConceptSetExpression(x, path, type = "json")
exportConceptSetExpression(x, path, type = "json")
x |
A concept set expression |
path |
Path to where files will be created. |
type |
Type of files to export. Currently 'json' and 'csv' are supported. |
Files with concept set expressions
Export a summarised_result object to a csv file.
exportSummarisedResult( ..., minCellCount = 5, fileName = "results_{cdm_name}_{date}.csv", path = getwd() )
exportSummarisedResult( ..., minCellCount = 5, fileName = "results_{cdm_name}_{date}.csv", path = getwd() )
... |
A set of summarised_result objects. |
minCellCount |
Minimum count for suppression purposes. |
fileName |
Name of the file that will be created. Use {cdm_name} to refer to the cdmName of the objects and {date} to add the export date. |
path |
Path where to create the csv file. It is ignored if fileName it is a full name with path included. |
Filter the additional_name-additional_level pair in a summarised_result
filterAdditional(result, ...)
filterAdditional(result, ...)
result |
A |
... |
Expressions that return a logical value ( |
A <summarised_result>
object with only the rows that fulfill the
required specified additional.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = c("cohort1", "cohort2", "cohort3"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = c("year", "time_step", "year &&& time_step"), "additional_level" = c("2010", "4", "2015 &&& 5") ) |> newSummarisedResult() x |> filterAdditional(year == "2010")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = c("cohort1", "cohort2", "cohort3"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = c("year", "time_step", "year &&& time_step"), "additional_level" = c("2010", "4", "2015 &&& 5") ) |> newSummarisedResult() x |> filterAdditional(year == "2010")
Filter the group_name-group_level pair in a summarised_result
filterGroup(result, ...)
filterGroup(result, ...)
result |
A |
... |
Expressions that return a logical value ( |
A <summarised_result>
object with only the rows that fulfill the
required specified group.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = c("cohort_name", "age_group &&& cohort_name", "age_group"), "group_level" = c("my_cohort", ">40 &&& second_cohort", "<40"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterGroup(cohort_name == "second_cohort")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = c("cohort_name", "age_group &&& cohort_name", "age_group"), "group_level" = c("my_cohort", ">40 &&& second_cohort", "<40"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterGroup(cohort_name == "second_cohort")
<summarised_result>
using the settingsFilter a <summarised_result>
using the settings
filterSettings(result, ...)
filterSettings(result, ...)
result |
A |
... |
Expressions that return a logical value (columns in settings are used to evaluate the expression), and are defined in terms of the variables in .data. If multiple expressions are included, they are combined with the & operator. Only rows for which all conditions evaluate to TRUE are kept. |
A <summarised_result>
object with only the result_id rows that fulfill
the required specified settings.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> filterSettings(custom == "A")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> filterSettings(custom == "A")
Filter the strata_name-strata_level pair in a summarised_result
filterStrata(result, ...)
filterStrata(result, ...)
result |
A |
... |
Expressions that return a logical value ( |
A <summarised_result>
object with only the rows that fulfill the
required specified strata.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = c("sex", "sex &&& age_group", "sex &&& year"), "strata_level" = c("Female", "Male &&& <40", "Female &&& 2010"), "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterStrata(sex == "Female")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = c("sex", "sex &&& age_group", "sex &&& year"), "strata_level" = c("Female", "Male &&& <40", "Female &&& 2010"), "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterStrata(sex == "Female")
Get the cohort definition id of a certain name
getCohortId(cohort, cohortName = NULL)
getCohortId(cohort, cohortName = NULL)
cohort |
A cohort_table object. |
cohortName |
Names of the cohort of interest. If NULL all cohort names are shown. |
Cohort definition ids
Get the cohort name of a certain cohort definition id
getCohortName(cohort, cohortId = NULL)
getCohortName(cohort, cohortId = NULL)
cohort |
A cohort_table object. |
cohortId |
Cohort definition id of interest. If NULL all cohort ids are shown. |
Cohort names
Get the column name with the person identifier from a table (either subject_id or person_id), it will throw an error if it contains both or neither.
getPersonIdentifier(x, call = parent.frame())
getPersonIdentifier(x, call = parent.frame())
x |
A table. |
call |
A call argument passed to cli functions. |
Person identifier column.
Identifies and returns the unique values in group_name column.
groupColumns(result)
groupColumns(result)
result |
A tibble. |
Unique values of the group name column.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> groupColumns() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> groupColumns() }
Import a codelist.
importCodelist(path, type = "json")
importCodelist(path, type = "json")
path |
Path to where files will be created. |
type |
Type of files to export. Currently 'json' and 'csv' are supported. |
A codelist
Import a concept set expression.
importConceptSetExpression(path, type = "json")
importConceptSetExpression(path, type = "json")
path |
Path to where files will be created. |
type |
Type of files to export. Currently 'json' and 'csv' are supported. |
A concept set expression
Import a set of summarised results.
importSummarisedResult(path, recursive = FALSE)
importSummarisedResult(path, recursive = FALSE)
path |
Path to directory with CSV files containing summarised results or to a specific CSV file with a summarised result. |
recursive |
If TRUE and path is a directory, search for files will recurse into directories |
A summarised result
insertFromSource(cdm, value)
insertFromSource(cdm, value)
cdm |
A cdm_reference object. |
value |
A table that shares source with the cdm_reference object. |
A table in the cdm_reference environment
Insert a table to a cdm object.
insertTable(cdm, name, table, overwrite = TRUE, temporary = FALSE)
insertTable(cdm, name, table, overwrite = TRUE, temporary = FALSE)
cdm |
A cdm reference or the source of a cdm reference. |
name |
Name of the table to insert. |
table |
Table to insert to the cdm. |
overwrite |
Whether to overwrite an existent table. |
temporary |
Whether to create a temporary table. |
The cdm reference. library(omopgenerics) library(dplyr, warn.conflicts = FALSE)
person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm" )
x <- tibble(a = 1)
cdm <- insertTable(cdm = cdm, name = "new_table", table = x)
cdm$new_table
isResultSuppressed
isResultSuppressed(result, minCellCount = 5)
isResultSuppressed(result, minCellCount = 5)
result |
The suppressed result to check |
minCellCount |
Minimum count of records used when suppressing |
Warning or message with check result
Check if a table is empty or not
isTableEmpty(table)
isTableEmpty(table)
table |
a table |
Boolean to indicate if a cdm_table is empty (TRUE or FALSE).
List tables that can be accessed though a cdm object.
listSourceTables(cdm)
listSourceTables(cdm)
cdm |
A cdm reference or the source of a cdm reference. |
A character vector with the names of tables.
Create an achilles table from a cdm_table.
newAchillesTable(table, version = "5.3", cast = FALSE)
newAchillesTable(table, version = "5.3", cast = FALSE)
table |
A cdm_table. |
version |
version of the cdm. |
cast |
Whether to cast columns to the correct type. |
An achilles_table object
cdm_reference
objects constructorcdm_reference
objects constructor
newCdmReference(tables, cdmName, cdmVersion = NULL, .softValidation = FALSE)
newCdmReference(tables, cdmName, cdmVersion = NULL, .softValidation = FALSE)
tables |
List of tables that are part of the OMOP Common Data Model reference. |
cdmName |
Name of the cdm object. |
cdmVersion |
Version of the cdm. Supported versions 5.3 and 5.4. |
.softValidation |
Whether to perform a soft validation of consistency. If set to FALSE, non overlapping observation periods are ensured. |
A cdm_reference
object.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdmTables <- list( "person" = tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) |> newCdmTable(newLocalSource(), "person"), "observation_period" = tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) |> newCdmTable(newLocalSource(), "observation_period") ) cdm <- newCdmReference(tables = cdmTables, cdmName = "mock") cdm
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdmTables <- list( "person" = tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) |> newCdmTable(newLocalSource(), "person"), "observation_period" = tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) |> newCdmTable(newLocalSource(), "observation_period") ) cdm <- newCdmReference(tables = cdmTables, cdmName = "mock") cdm
Create a cdm source object.
newCdmSource(src, sourceType)
newCdmSource(src, sourceType)
src |
Source to a cdm object. |
sourceType |
Type of the source object. |
A validated cdm source object.
Create an cdm table.
newCdmTable(table, src, name)
newCdmTable(table, src, name)
table |
A table that is part of a cdm. |
src |
The source of the table. |
name |
The name of the table. |
A cdm_table object
'codelist' object constructor
newCodelist(x)
newCodelist(x)
x |
A named list where each element contains a vector of concept IDs. |
A codelist object.
'codelist' object constructor
newCodelistWithDetails(x)
newCodelistWithDetails(x)
x |
A named list where each element contains a tibble with the column concept_id |
A codelist object.
cohort_table
objects constructor.cohort_table
objects constructor.
newCohortTable( table, cohortSetRef = attr(table, "cohort_set"), cohortAttritionRef = attr(table, "cohort_attrition"), cohortCodelistRef = attr(table, "cohort_codelist"), .softValidation = FALSE )
newCohortTable( table, cohortSetRef = attr(table, "cohort_set"), cohortAttritionRef = attr(table, "cohort_attrition"), cohortCodelistRef = attr(table, "cohort_codelist"), .softValidation = FALSE )
table |
cdm_table object with at least: cohort_definition_id, subject_id, cohort_start_date, cohort_end_date. |
cohortSetRef |
Table with at least: cohort_definition_id, cohort_name |
cohortAttritionRef |
Table with at least: cohort_definition_id, number_subjects, number_records, reason_id, reason, excluded_subjects, excluded_records. |
cohortCodelistRef |
Table with at least: cohort_definition_id, codelist_name, and concept_id. |
.softValidation |
Whether to perform a soft validation of consistency. If set to FALSE four additional checks will be performed: 1) a check that cohort end date is not before cohort start date, 2) a check that there are no missing values in required columns, 3) a check that cohort duration is all within observation period, and 4) that there are no overlapping cohort entries |
A cohort_table object
person <- dplyr::tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- dplyr::tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort1 <- dplyr::tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2020-01-01"), cohort_end_date = as.Date("2020-01-10") ) cdm <- cdmFromTables( tables = list( "person" = person, "observation_period" = observation_period, "cohort1" = cohort1 ), cdmName = "test" ) cdm cdm$cohort1 <- newCohortTable(table = cdm$cohort1) cdm settings(cdm$cohort1) attrition(cdm$cohort1) cohortCount(cdm$cohort1)
person <- dplyr::tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- dplyr::tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort1 <- dplyr::tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2020-01-01"), cohort_end_date = as.Date("2020-01-10") ) cdm <- cdmFromTables( tables = list( "person" = person, "observation_period" = observation_period, "cohort1" = cohort1 ), cdmName = "test" ) cdm cdm$cohort1 <- newCohortTable(table = cdm$cohort1) cdm settings(cdm$cohort1) attrition(cdm$cohort1) cohortCount(cdm$cohort1)
'conceptSetExpression' object constructor
newConceptSetExpression(x)
newConceptSetExpression(x)
x |
a named list of tibbles, each of which containing concept set definitions |
A conceptSetExpression
A new local source for the cdm
newLocalSource()
newLocalSource()
A list in the format of a cdm source
library(omopgenerics) newLocalSource()
library(omopgenerics) newLocalSource()
Create an omop table from a cdm table.
newOmopTable(table, version = "5.3", cast = FALSE)
newOmopTable(table, version = "5.3", cast = FALSE)
table |
A cdm_table. |
version |
version of the cdm. |
cast |
Whether to cast columns to the correct type. |
An omop_table object
'summarised_results' object constructor
newSummarisedResult(x, settings = attr(x, "settings"))
newSummarisedResult(x, settings = attr(x, "settings"))
x |
Table. |
settings |
Settings for the summarised_result object. |
A summarised_result
object
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "cprd", "group_name" = "cohort_name", "group_level" = "acetaminophen", "strata_name" = "sex &&& age_group", "strata_level" = c("male &&& <40", "male &&& >=40"), "variable_name" = "number_subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("5", "15"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x settings(x) summary(x) x <- tibble( "result_id" = 1L, "cdm_name" = "cprd", "group_name" = "cohort_name", "group_level" = "acetaminophen", "strata_name" = "sex &&& age_group", "strata_level" = c("male &&& <40", "male &&& >=40"), "variable_name" = "number_subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("5", "15"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( result_id = 1L, result_type = "custom_summary", mock = TRUE, value = 5 )) x settings(x) summary(x)
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "cprd", "group_name" = "cohort_name", "group_level" = "acetaminophen", "strata_name" = "sex &&& age_group", "strata_level" = c("male &&& <40", "male &&& >=40"), "variable_name" = "number_subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("5", "15"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x settings(x) summary(x) x <- tibble( "result_id" = 1L, "cdm_name" = "cprd", "group_name" = "cohort_name", "group_level" = "acetaminophen", "strata_name" = "sex &&& age_group", "strata_level" = c("male &&& <40", "male &&& >=40"), "variable_name" = "number_subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("5", "15"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( result_id = 1L, result_type = "custom_summary", mock = TRUE, value = 5 )) x settings(x) summary(x)
Required columns that the standard tables in the OMOP Common Data Model must have.
omopColumns( table, field = NULL, version = "5.3", onlyRequired = lifecycle::deprecated() )
omopColumns( table, field = NULL, version = "5.3", onlyRequired = lifecycle::deprecated() )
table |
Table to see required columns. |
field |
Name of the specific field. |
version |
Version of the OMOP Common Data Model. |
onlyRequired |
deprecated |
Character vector with the column names
library(omopgenerics) omopColumns("person")
library(omopgenerics) omopColumns("person")
Return a table of omop cdm fields informations
omopTableFields(cdmVersion = "5.3")
omopTableFields(cdmVersion = "5.3")
cdmVersion |
cdm version of the omop cdm. |
a tibble contain informations on all the different fields in omop cdm.
Standard tables that a cdm reference can contain in the OMOP Common Data Model.
omopTables(version = "5.3")
omopTables(version = "5.3")
version |
Version of the OMOP Common Data Model. |
Standard tables
library(omopgenerics) omopTables()
library(omopgenerics) omopTables()
Pivot the estimates as new columns in result table.
pivotEstimates(result, pivotEstimatesBy = "estimate_name", nameStyle = NULL)
pivotEstimates(result, pivotEstimatesBy = "estimate_name", nameStyle = NULL)
result |
A |
pivotEstimatesBy |
Names from which pivot wider the estimate values. If NULL the table will not be pivotted. |
nameStyle |
Name style (glue package specifications) to customise names when pivotting estimates. If NULL standard tidyr::pivot_wider formatting will be used. |
A tibble.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> pivotEstimates() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> pivotEstimates() }
Print a CDM reference object
## S3 method for class 'cdm_reference' print(x, ...)
## S3 method for class 'cdm_reference' print(x, ...)
x |
A cdm_reference object |
... |
Included for compatibility with generic. Not used. |
Invisibly returns the input
library(omopgenerics) cdm <- cdmFromTables( tables = list( "person" = dplyr::tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = dplyr::tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) print(cdm)
library(omopgenerics) cdm <- cdmFromTables( tables = list( "person" = dplyr::tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = dplyr::tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) print(cdm)
Print a codelist
## S3 method for class 'codelist' print(x, ...)
## S3 method for class 'codelist' print(x, ...)
x |
A codelist |
... |
Included for compatibility with generic. Not used. |
Invisibly returns the input
codes <- list("disease X" = c(1, 2, 3), "disease Y" = c(4, 5)) codes <- newCodelist(codes) print(codes)
codes <- list("disease X" = c(1, 2, 3), "disease Y" = c(4, 5)) codes <- newCodelist(codes) print(codes)
Print a codelist with details
## S3 method for class 'codelist_with_details' print(x, ...)
## S3 method for class 'codelist_with_details' print(x, ...)
x |
A codelist with details |
... |
Included for compatibility with generic. Not used. |
Invisibly returns the input
codes <- list("disease X" = dplyr::tibble( concept_id = c(1, 2, 3), other = c("a", "b", "c") )) codes <- newCodelistWithDetails(codes) print(codes)
codes <- list("disease X" = dplyr::tibble( concept_id = c(1, 2, 3), other = c("a", "b", "c") )) codes <- newCodelistWithDetails(codes) print(codes)
Print a concept set expression
## S3 method for class 'conceptSetExpression' print(x, ...)
## S3 method for class 'conceptSetExpression' print(x, ...)
x |
A concept set expression |
... |
Included for compatibility with generic. Not used. |
Invisibly returns the input
asthma_cs <- list( "asthma_narrow" = dplyr::tibble( "concept_id" = 1, "excluded" = FALSE, "descendants" = TRUE, "mapped" = FALSE ), "asthma_broad" = dplyr::tibble( "concept_id" = c(1, 2), "excluded" = FALSE, "descendants" = TRUE, "mapped" = FALSE ) ) asthma_cs <- newConceptSetExpression(asthma_cs) print(asthma_cs)
asthma_cs <- list( "asthma_narrow" = dplyr::tibble( "concept_id" = 1, "excluded" = FALSE, "descendants" = TRUE, "mapped" = FALSE ), "asthma_broad" = dplyr::tibble( "concept_id" = c(1, 2), "excluded" = FALSE, "descendants" = TRUE, "mapped" = FALSE ) ) asthma_cs <- newConceptSetExpression(asthma_cs) print(asthma_cs)
Read a table from the cdm_source and add it to to the cdm.
readSourceTable(cdm, name)
readSourceTable(cdm, name)
cdm |
A cdm reference. |
name |
Name of a table to read in the cdm_source space. |
A cdm_reference with new table.
Update cohort attrition.
recordCohortAttrition(cohort, reason, cohortId = NULL)
recordCohortAttrition(cohort, reason, cohortId = NULL)
cohort |
A cohort_table object. |
reason |
A character string. |
cohortId |
Cohort definition id of the cohort to update attrition. If NULL all cohort_definition_id are updated. |
cohort_table with updated attrition.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), cohort_end_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cdm$cohort1 attrition(cdm$cohort1) cdm$cohort1 <- cdm$cohort1 |> group_by(cohort_definition_id, subject_id) |> filter(cohort_start_date == min(cohort_start_date)) |> ungroup() |> compute(name = "cohort1", temporary = FALSE) |> recordCohortAttrition("Restrict to first observation") cdm$cohort1 attrition(cdm$cohort1)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = c(1, 1, 1, 2), subject_id = 1, cohort_start_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), cohort_end_date = as.Date(c("2020-01-01", "2021-01-01", "2022-01-01", "2022-01-01")), ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "my_example_cdm", cohortTables = list("cohort1" = cohort) ) cdm$cohort1 attrition(cdm$cohort1) cdm$cohort1 <- cdm$cohort1 |> group_by(cohort_definition_id, subject_id) |> filter(cohort_start_date == min(cohort_start_date)) |> ungroup() |> compute(name = "cohort1", temporary = FALSE) |> recordCohortAttrition("Restrict to first observation") cdm$cohort1 attrition(cdm$cohort1)
Required columns that the result tables must have.
resultColumns(table = "summarised_result")
resultColumns(table = "summarised_result")
table |
Table to see required columns. |
Required columns
library(omopgenerics) resultColumns()
library(omopgenerics) resultColumns()
Check if different packages version are used for summarise_results object
resultPackageVersion(result)
resultPackageVersion(result)
result |
a summarised results object |
a summarised results object
Get settings from an object.
settings(x)
settings(x)
x |
Object |
A table with the settings of the object.
Get cohort settings from a cohort_table object.
## S3 method for class 'cohort_table' settings(x)
## S3 method for class 'cohort_table' settings(x)
x |
A cohort_table object. |
A table with the details of the cohort settings.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2012-01-01") ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test", cohortTables = list("my_cohort" = cohort) ) settings(cdm$my_cohort) cdm$my_cohort <- cdm$my_cohort |> newCohortTable(cohortSetRef = tibble( cohort_definition_id = 1, cohort_name = "new_name" )) settings(cdm$my_cohort)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2012-01-01") ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test", cohortTables = list("my_cohort" = cohort) ) settings(cdm$my_cohort) cdm$my_cohort <- cdm$my_cohort |> newCohortTable(cohortSetRef = tibble( cohort_definition_id = 1, cohort_name = "new_name" )) settings(cdm$my_cohort)
Get settings from a summarised_result object.
## S3 method for class 'summarised_result' settings(x)
## S3 method for class 'summarised_result' settings(x)
x |
A summarised_result object. |
A table with the settings.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2012-01-01") ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test", cohortTables = list("my_cohort" = cohort) ) result <- summary(cdm$my_cohort) settings(result)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cohort <- tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2012-01-01") ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test", cohortTables = list("my_cohort" = cohort) ) result <- summary(cdm$my_cohort) settings(result)
<summarised_result>
Identifies and returns the columns of the settings table
obtained by using settings()
in a <summarised_result>
object.
settingsColumns(result, metadata = FALSE)
settingsColumns(result, metadata = FALSE)
result |
A |
metadata |
Whether to include metadata columns in settings or not. |
Vector with names of the settings columns
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> settingsColumns() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> settingsColumns() }
Get the source type of an object.
sourceType(x)
sourceType(x)
x |
Object to know the source type. |
A character vector that defines the type of cdm_source.
Pivots the input dataframe so the values of the column additional_name are transformed into columns that contain values from the additional_level column.
splitAdditional(result, keep = FALSE, fill = "overall")
splitAdditional(result, keep = FALSE, fill = "overall")
result |
A dataframe with at least the columns additional_name and additional_level. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitAdditional() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitAdditional() }
Pivots the input dataframe so any pair name-level columns are transformed into columns (name) that contain values from the corresponding level.
splitAll(result, keep = FALSE, fill = "overall", exclude = "variable")
splitAll(result, keep = FALSE, fill = "overall", exclude = "variable")
result |
A data.frame. |
keep |
Whether to keep the original name-level columns. |
fill |
A character that specifies what value should be filled in when missing. |
exclude |
Name of a column pair to exclude. |
A dataframe with group, strata and additional as columns.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitAll() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitAll() }
Pivots the input dataframe so the values of the column group_name are transformed into columns that contain values from the group_level column.
splitGroup(result, keep = FALSE, fill = "overall")
splitGroup(result, keep = FALSE, fill = "overall")
result |
A dataframe with at least the columns group_name and group_level. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitGroup() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitGroup() }
Pivots the input dataframe so the values of the column strata_name are transformed into columns that contain values from the strata_level column.
splitStrata(result, keep = FALSE, fill = "overall")
splitStrata(result, keep = FALSE, fill = "overall")
result |
A dataframe with at least the columns strata_name and strata_level. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitStrata() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> splitStrata() }
Identifies and returns the unique values in strata_name column.
strataColumns(result)
strataColumns(result)
result |
A tibble. |
Unique values of the strata name column.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> strataColumns() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> strataColumns() }
Summary a cdm reference
## S3 method for class 'cdm_reference' summary(object, ...)
## S3 method for class 'cdm_reference' summary(object, ...)
object |
A cdm reference object. |
... |
For compatibility (not used). |
A summarised_result object with a summary of the data contained in the cdm.
library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) summary(cdm)
library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) summary(cdm)
Summary a generated cohort set
## S3 method for class 'cohort_table' summary(object, ...)
## S3 method for class 'cohort_table' summary(object, ...)
object |
A generated cohort set object. |
... |
For compatibility (not used). |
A summarised_result object with a summary of a cohort_table.
library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test", cohortTables = list("cohort1" = tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") )) ) summary(cdm$cohort1)
library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test", cohortTables = list("cohort1" = tibble( cohort_definition_id = 1, subject_id = 1, cohort_start_date = as.Date("2010-01-01"), cohort_end_date = as.Date("2010-01-05") )) ) summary(cdm$cohort1)
Summary a summarised_result
## S3 method for class 'summarised_result' summary(object, ...)
## S3 method for class 'summarised_result' summary(object, ...)
object |
A summarised_result object. |
... |
For compatibility (not used). |
A summary of the result_types contained in a summarised_result object.
library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) result <- summary(cdm) summary(result)
library(dplyr, warn.conflicts = FALSE) person <- tibble( person_id = 1, gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ) observation_period <- tibble( observation_period_id = 1, person_id = 1, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) cdm <- cdmFromTables( tables = list("person" = person, "observation_period" = observation_period), cdmName = "test" ) result <- summary(cdm) summary(result)
Function to suppress counts in result objects
suppress(result, minCellCount = 5)
suppress(result, minCellCount = 5)
result |
Result object |
minCellCount |
Minimum count of records to report results. |
Table with suppressed counts
Function to suppress counts in result objects
## S3 method for class 'summarised_result' suppress(result, minCellCount = 5)
## S3 method for class 'summarised_result' suppress(result, minCellCount = 5)
result |
summarised_result object. |
minCellCount |
Minimum count of records to report results. |
summarised_result with suppressed counts.
library(dplyr, warn.conflicts = FALSE) library(omopgenerics) my_result <- tibble( "result_id" = "1", "cdm_name" = "mock", "result_type" = "summarised_characteristics", "package_name" = "omopgenerics", "package_version" = as.character(utils::packageVersion("omopgenerics")), "group_name" = "overall", "group_level" = "overall", "strata_name" = c(rep("overall", 6), rep("sex", 3)), "strata_level" = c(rep("overall", 6), "male", "female", "female"), "variable_name" = c( "number records", "age_group", "age_group", "age_group", "age_group", "my_variable", "number records", "age_group", "age_group" ), "variable_level" = c( NA, "<50", "<50", ">=50", ">=50", NA, NA, "<50", "<50" ), "estimate_name" = c( "count", "count", "percentage", "count", "percentage", "random", "count", "count", "percentage" ), "estimate_type" = c( "integer", "integer", "percentage", "integer", "percentage", "numeric", "integer", "integer", "percentage" ), "estimate_value" = c("10", "5", "50", "3", "30", "1", "3", "12", "6"), "additional_name" = "overall", "additional_level" = "overall" ) my_result <- newSummarisedResult(my_result) my_result |> glimpse() my_result <- suppress(my_result, minCellCount = 5) my_result |> glimpse()
library(dplyr, warn.conflicts = FALSE) library(omopgenerics) my_result <- tibble( "result_id" = "1", "cdm_name" = "mock", "result_type" = "summarised_characteristics", "package_name" = "omopgenerics", "package_version" = as.character(utils::packageVersion("omopgenerics")), "group_name" = "overall", "group_level" = "overall", "strata_name" = c(rep("overall", 6), rep("sex", 3)), "strata_level" = c(rep("overall", 6), "male", "female", "female"), "variable_name" = c( "number records", "age_group", "age_group", "age_group", "age_group", "my_variable", "number records", "age_group", "age_group" ), "variable_level" = c( NA, "<50", "<50", ">=50", ">=50", NA, NA, "<50", "<50" ), "estimate_name" = c( "count", "count", "percentage", "count", "percentage", "random", "count", "count", "percentage" ), "estimate_type" = c( "integer", "integer", "percentage", "integer", "percentage", "numeric", "integer", "integer", "percentage" ), "estimate_value" = c("10", "5", "50", "3", "30", "1", "3", "12", "6"), "additional_name" = "overall", "additional_level" = "overall" ) my_result <- newSummarisedResult(my_result) my_result |> glimpse() my_result <- suppress(my_result, minCellCount = 5) my_result |> glimpse()
cdm_table
.Get the table name of a cdm_table
.
tableName(table)
tableName(table)
table |
A cdm_table. |
A character with the name.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) tableName(cdm$person)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) tableName(cdm$person)
cdm_table
.Get the table source of a cdm_table
.
tableSource(table)
tableSource(table)
table |
A cdm_table. |
A cdm_source object.
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) tableSource(cdm$person)
library(omopgenerics) library(dplyr, warn.conflicts = FALSE) cdm <- cdmFromTables( tables = list( "person" = tibble( person_id = c(1, 2, 3), gender_concept_id = 0, year_of_birth = 1990, race_concept_id = 0, ethnicity_concept_id = 0 ), "observation_period" = tibble( observation_period_id = 1:3, person_id = 1:3, observation_period_start_date = as.Date("2000-01-01"), observation_period_end_date = as.Date("2023-12-31"), period_type_concept_id = 0 ) ), cdmName = "mock" ) tableSource(cdm$person)
<summarised_result>
object into a tidy tibble
Provides tools for obtaining a tidy version of a <summarised_result>
object.
This tidy version will include the settings as columns, estimate_value
will
be pivotted into columns using estimate_name
as names, and group, strata,
and additional will be splitted.
## S3 method for class 'summarised_result' tidy(x, ...)
## S3 method for class 'summarised_result' tidy(x, ...)
x |
A |
... |
For compatibility (not used). |
A tibble.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> tidy() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> tidy() }
<summarised_result>
Identifies and returns the columns that the tidy version of the
<summarised_result>
will have.
tidyColumns(result)
tidyColumns(result)
result |
A |
Table columns after applying tidy()
function to a
<summarised_result>
.
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> tidyColumns() }
{ library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> tidyColumns() }
Create a temporary prefix for tables, that contains a unique prefix that starts with tmp.
tmpPrefix()
tmpPrefix()
A temporary prefix.
library(omopgenerics) tmpPrefix()
library(omopgenerics) tmpPrefix()
Convert a character vector to snake case
toSnakeCase(x)
toSnakeCase(x)
x |
Character vector to convert |
A snake_case vector
toSnakeCase("myVariable") toSnakeCase(c("cohort1", "Cohort22b"))
toSnakeCase("myVariable") toSnakeCase(c("cohort1", "Cohort22b"))
Get a unique Identifier with a certain number of characters and a prefix.
uniqueId(n = 1, exclude = character(), nChar = 3, prefix = "id_")
uniqueId(n = 1, exclude = character(), nChar = 3, prefix = "id_")
n |
Number of identifiers. |
exclude |
Columns to exclude. |
nChar |
Number of characters. |
prefix |
A prefix for the identifiers. |
A character vector with n unique identifiers.
Create a unique table name
uniqueTableName(prefix = "")
uniqueTableName(prefix = "")
prefix |
Prefix for the table names. |
A string that can be used as a dbplyr temp table name
library(omopgenerics) uniqueTableName()
library(omopgenerics) uniqueTableName()
Unites targeted table columns into additional_name-additional_level columns.
uniteAdditional( x, cols = character(0), keep = FALSE, ignore = c(NA, "overall") )
uniteAdditional( x, cols = character(0), keep = FALSE, ignore = c(NA, "overall") )
x |
Tibble or dataframe. |
cols |
Columns to aggregate. |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteAdditional(c("sex", "age_group"))
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteAdditional(c("sex", "age_group"))
Unites targeted table columns into group_name-group_level columns.
uniteGroup(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
uniteGroup(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
x |
Tibble or dataframe. |
cols |
Columns to aggregate. |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteGroup(c("sex", "age_group"))
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteGroup(c("sex", "age_group"))
Unites targeted table columns into strata_name-strata_level columns.
uniteStrata(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
uniteStrata(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
x |
Tibble or dataframe. |
cols |
Columns to aggregate. |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteStrata(c("sex", "age_group"))
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteStrata(c("sex", "age_group"))
validateAgeGroupArgument
validateAgeGroupArgument( ageGroup, multipleAgeGroup = TRUE, overlap = FALSE, null = TRUE, ageGroupName = "age_group", call = parent.frame() )
validateAgeGroupArgument( ageGroup, multipleAgeGroup = TRUE, overlap = FALSE, null = TRUE, ageGroupName = "age_group", call = parent.frame() )
ageGroup |
age group in a list. |
multipleAgeGroup |
allow mutliple age group. |
overlap |
allow overlapping ageGroup. |
null |
null age group allowed true or false. |
ageGroupName |
Name of the default age group. |
call |
parent frame. |
validate ageGroup
validateCdmArgument
validateCdmArgument( cdm, checkOverlapObservation = FALSE, checkStartBeforeEndObservation = FALSE, checkPlausibleObservationDates = FALSE, checkPerson = FALSE, validation = "error", call = parent.frame() )
validateCdmArgument( cdm, checkOverlapObservation = FALSE, checkStartBeforeEndObservation = FALSE, checkPlausibleObservationDates = FALSE, checkPerson = FALSE, validation = "error", call = parent.frame() )
cdm |
A cdm_reference object |
checkOverlapObservation |
TRUE to perform check on no overlap observation period |
checkStartBeforeEndObservation |
TRUE to perform check on correct observational start and end date |
checkPlausibleObservationDates |
TRUE to perform check that there are no implausible observation period start dates (before 1800-01-01) or end dates (after the current date) |
checkPerson |
TRUE to perform check on person id in all clincial table are in person table |
validation |
How to perform validation: "error", "warning". |
call |
A call argument to pass to cli functions. |
A cdm_reference object
Validate a cohort table input.
validateCohortArgument( cohort, checkEndAfterStart = FALSE, checkOverlappingEntries = FALSE, checkMissingValues = FALSE, checkInObservation = FALSE, dropExtraColumns = FALSE, validation = "error", call = parent.frame() )
validateCohortArgument( cohort, checkEndAfterStart = FALSE, checkOverlappingEntries = FALSE, checkMissingValues = FALSE, checkInObservation = FALSE, dropExtraColumns = FALSE, validation = "error", call = parent.frame() )
cohort |
Object to be validated as a valid cohort input. |
checkEndAfterStart |
If TRUE a check that all cohort end dates come on or after cohort start date will be performed. |
checkOverlappingEntries |
If TRUE a check that no individuals have overlapping cohort entries will be performed. |
checkMissingValues |
If TRUE a check that there are no missing values in required fields will be performed. |
checkInObservation |
If TRUE a check that cohort entries are within the individuals observation periods will be performed. |
dropExtraColumns |
Whether to drop extra columns that are not the required ones. |
validation |
How to perform validation: "error", "warning". |
call |
A call argument to pass to cli functions. |
validateCohortIdArgument({{cohortId}}, cohort)
.Validate cohortId argument. CohortId can either be a cohort_definition_id
value, a cohort_name or a tidyselect expression referinc to cohort_names. If
you want to support tidyselect expressions please use the function as:
validateCohortIdArgument({{cohortId}}, cohort)
.
validateCohortIdArgument( cohortId, cohort, validation = "error", call = parent.frame() )
validateCohortIdArgument( cohortId, cohort, validation = "error", call = parent.frame() )
cohortId |
A cohortId vector to be validated. |
cohort |
A cohort_table object. |
validation |
How to perform validation: "error", "warning". |
call |
A call argument to pass to cli functions. |
Validate conceptSet argument.
validateConceptSetArgument( conceptSet, cdm = NULL, validation = "error", call = parent.frame() )
validateConceptSetArgument( conceptSet, cdm = NULL, validation = "error", call = parent.frame() )
conceptSet |
It can be either a named list of concepts or a codelist, codelist_with_details or conceptSetExpression object. |
cdm |
A cdm_reference object, needed if a conceptSetExpression is provided. |
validation |
How to perform validation: "error", "warning". |
call |
A call argument to pass to cli functions. |
Validate name argument.
validateNameArgument( name, cdm = NULL, validation = "error", null = FALSE, call = parent.frame() )
validateNameArgument( name, cdm = NULL, validation = "error", null = FALSE, call = parent.frame() )
name |
Name of a new table to be added to a cdm object. |
cdm |
A cdm_reference object. It will check if a table named name already exists in the cdm. |
validation |
How to perform validation: "error", "warning". |
null |
If TRUE, name can be NULL |
call |
A call argument to pass to cli functions. |
Validate if two columns are valid Name-Level pair.
validateNameLevel( x, prefix, sep = " &&& ", validation = "error", call = parent.frame() )
validateNameLevel( x, prefix, sep = " &&& ", validation = "error", call = parent.frame() )
x |
A tibble. |
prefix |
Prefix for the name-level pair, e.g. 'strata' for strata_name-strata_level pair. |
sep |
Separation pattern. |
validation |
Either 'error', 'warning' or 'message'. |
call |
Will be used by cli to report errors. |
Validate a new column of a table
validateNewColumn(table, column, validation = "warning", call = parent.frame())
validateNewColumn(table, column, validation = "warning", call = parent.frame())
table |
The table to check if the column already exists. |
column |
Character vector with the name(s) of the new column(s). |
validation |
Whether to throw warning or error. |
call |
Passed to cli functions. |
table without conflicting columns.
validateResultArgument
validateResultArguemnt(result, validation = "error", call = parent.frame())
validateResultArguemnt(result, validation = "error", call = parent.frame())
result |
summarise result object to validate |
validation |
message to return |
call |
parent.frame |
summarise result object
validateResultArgument
validateResultArgument( result, checkNoDuplicates = FALSE, checkNameLevel = FALSE, checkSuppression = FALSE, validation = "error", call = parent.frame() )
validateResultArgument( result, checkNoDuplicates = FALSE, checkNameLevel = FALSE, checkSuppression = FALSE, validation = "error", call = parent.frame() )
result |
summarised_result object to validate. |
checkNoDuplicates |
Whether there are not allowed duplicates in the result object. |
checkNameLevel |
Whether the name-level paired columns are can be correctly split. |
checkSuppression |
Whether the suppression in the result object is well defined. |
validation |
Only error is supported at the moment. |
call |
parent.frame |
summarise result object
validateWindowArgument
validateWindowArgument(window, snakeCase = TRUE, call = parent.frame())
validateWindowArgument(window, snakeCase = TRUE, call = parent.frame())
window |
time window |
snakeCase |
return default window name in snake case if TRUE |
call |
A call argument to pass to cli functions. |
time window