
Turn a sparse concept matrix into a PatientLevelPrediction plpData
Source: R/hades_bridge.R
as_plp_data.RdBridges extract_sparse_concept_matrix() to PatientLevelPrediction and DeepPatientLevelPrediction: the
same matrix you would feed to glmnet or scikit-learn (and, through Python, omop-learn) becomes a
plpData object that createStudyPopulation(), runPlp() and the DeepPLP models accept. Rows keep the
parquet's order (rowId is the 1-based row position).
Usage
as_plp_data(
sparse_result,
con,
target_id = 1L,
outcome_id = 1L,
days_to_event = 1,
cohort_end_days = 0
)Arguments
- sparse_result
A result of
extract_sparse_concept_matrix()that includes an outcome (y).- con
DuckDB connection holding
observation_periodandperson(used fordaysFromObsStart,daysToObsEnd, age and gender).- target_id
Cohort definition id recorded as
targetId.- outcome_id
Outcome id recorded in
outcomes.- days_to_event
Day (relative to index) at which a positive label is placed: a scalar, or one value per row. Binary labels carry no timing, so the default
1puts events inside PLP's default risk window (day 1 to 365); pass real times if you have them.- cohort_end_days
Days from index to cohort end (scalar or per row; default 0).
Details
Covariate ids follow the OHDSI convention concept_id * 1000 + analysis_id, using FeatureExtraction's
long-term analysis ids (condition 102, drug 302, procedure 502), so they coincide with natively extracted
covariates when the window is 365 days. Rows with no observation period around their index date are
dropped (PatientLevelPrediction requires one), with a warning.
This produces the non-temporal covariate layout (patient x covariate). Temporal sequence models
(DeepPLP's temporal transformer) take FeatureExtraction::createTemporalSequenceCovariateSettings()
through plp_database_details() instead.