Skip to content

Commit

Permalink
fix linting and add news
Browse files Browse the repository at this point in the history
  • Loading branch information
egillax committed Nov 1, 2024
1 parent 0eb5da8 commit 2d8f225
Show file tree
Hide file tree
Showing 13 changed files with 557 additions and 586 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, develop, broken_links]
branches: [main, develop]
release:
types: [published]
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
PatientLevelPrediction develop
======================
- Fixed linting errors and R codestyle in docs to conform to HADES style
- Remove links to pdf's, point to website instead.
- Fix broken links in Readme and BuildingPredictiveModels vignette
- Added an action to detect broken links in repo
- Official maintainer updated to Egill Fridgeirsson


Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ install Python 3.9 or higher using Anaconda (https://www.continuum.io/downloads)
Getting Started
===============

- To install the package please read the [Package Installation guide](https://github.com/OHDSI/PatientLevelPrediction/blob/main/inst/doc/InstallationGuide.pdf)
- To install the package please read the [Package Installation guide](https://ohdsi.github.io/PatientLevelPrediction/articles/InstallationGuide.html)

- Have a look at the video below for an extensive demo of the package.

Expand All @@ -93,24 +93,22 @@ alt="Video Vignette PLP Package" width="240" height="180" border="10" /></a>

Please read the main vignette for the package:

- [Building Single Patient-Level Predictive Models](https://github.com/OHDSI/PatientLevelPrediction/blob/main/inst/doc/BuildingPredictiveModels.pdf)
- [Building Single Patient-Level Predictive Models](https://ohdsi.github.io/PatientLevelPrediction/articles/BuildingPredictiveModels.html)

In addition we have created vignettes that describe advanced functionality in more detail:

- [Building Multiple Patient-Level Predictive Models](https://github.com/OHDSI/PatientLevelPrediction/blob/main/inst/doc/BuildingMultiplePredictiveModels.pdf)
- [Adding Custom Machine Learning Algorithms](https://github.com/OHDSI/PatientLevelPrediction/blob/main/inst/doc/AddingCustomModels.pdf)
- [Building Multiple Patient-Level Predictive Models](https://ohdsi.github.io/PatientLevelPrediction/articles/BuildingMultiplePredictiveModels.html)
- [Adding Custom Machine Learning Algorithms](https://ohdsi.github.io/PatientLevelPrediction/articles/AddingCustomModels.html)
- [Building Deep Learning Models](https://github.com/OHDSI/DeepPatientLevelPrediction)
- [Building Ensemble Models](https://github.com/OHDSI/EnsemblePatientLevelPrediction)
- [Creating Learning Curves](https://github.com/OHDSI/PatientLevelPrediction/blob/main/inst/doc/CreatingLearningCurves.pdf)
- [Creating Learning Curves](https://ohdsi.github.io/PatientLevelPrediction/articles/CreatingLearningCurves.html)

Package manual: [PatientLevelPrediction.pdf](https://github.com/OHDSI/PatientLevelPrediction/blob/main/extras/PatientLevelPrediction.pdf)
Package function reference: [Reference](https://ohdsi.github.io/PatientLevelPrediction/reference/index.html)

User Documentation
==================
Documentation can be found on the [package website](https://ohdsi.github.io/PatientLevelPrediction).

PDF versions of the documentation are also available, as mentioned above.

Support
=======
* Developer questions/comments/feedback: <a href="http://forums.ohdsi.org/c/developers">OHDSI Forum</a>
Expand All @@ -132,5 +130,5 @@ PatientLevelPrediction is being developed in R Studio.
# Acknowledgements

- The package is maintained by Egill Fridgeirsson and Jenna Reps and has been developed with major contributions from Peter Rijnbeek, Martijn Schuemie, Patrick Ryan, and Marc Suchard.
- We like to thank the following persons for their contributions to the package: Seng Chan You, Ross Williams, Henrik John, Xiaoyong Pan, James Wiggins, Alex Rekkas
- We like to thank the following persons for their contributions to the package: Seng Chan You, Ross Williams, Henrik John, Xiaoyong Pan, James Wiggins, Alexandros Rekkas
- This project is supported in part through the National Science Foundation grant IIS 1251151.
60 changes: 29 additions & 31 deletions vignettes/AddingCustomFeatureEngineering.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ library(PatientLevelPrediction)

# Introduction

This vignette describes how you can add your own custom function for feature engineering in the Observational Health Data Sciences and Informatics (OHDSI) [`PatientLevelPrediction`](http://github.com/OHDSI/PatientLevelPrediction) package. This vignette assumes you have read and are comfortable with building single patient level prediction models as described in the [`BuildingPredictiveModels` vignette](https://github.com/OHDSI/PatientLevelPrediction/blob/main/inst/doc/BuildingPredictiveModels.pdf).
This vignette describes how you can add your own custom function for feature engineering in the Observational Health Data Sciences and Informatics (OHDSI) [`PatientLevelPrediction`](http://github.com/OHDSI/PatientLevelPrediction) package. This vignette assumes you have read and are comfortable with building single patient level prediction models as described in the `vignette('BuildingPredictiveModels')`.

**We invite you to share your new feature engineering functions with the OHDSI community through our [GitHub repository](http://github.com/OHDSI/PatientLevelPrediction).**

Expand Down Expand Up @@ -65,22 +65,18 @@ Let's consider the situation where we wish to create an age spline feature. To m
Our age spline feature function will create a new feature using the `plpData$cohorts$ageYear` column. We will implement a restricted cubic spline that requires specifying the number of knots. Therefore, the inputs for this are: `knots` - an integer/double specifying the number of knots.

```{r, echo = TRUE, eval=FALSE}
createAgeSpline <- function(
knots = 5
){
createAgeSpline <- function(knots = 5) {
# create list of inputs to implement function
featureEngineeringSettings <- list(
knots = knots
)
)
# specify the function that will implement the sampling
attr(featureEngineeringSettings, "fun") <- "implementAgeSplines"
# make sure the object returned is of class "sampleSettings"
class(featureEngineeringSettings) <- "featureEngineeringSettings"
return(featureEngineeringSettings)
}
```

Expand All @@ -93,65 +89,67 @@ All 'implement' functions must take as input the `trainData` and the `featureEng
In our example, the `createAgeSpline()` will return a list with 'knots'. The `featureEngineeringSettings` therefore contains this.

```{r tidy=FALSE,eval=FALSE}
implementAgeSplines <- function(trainData, featureEngineeringSettings, model=NULL) {
implementAgeSplines <- function(trainData, featureEngineeringSettings, model = NULL) {
# if there is a model, it means this function is called through applyFeatureengineering, meaning it # should apply the model fitten on training data to the test data
if (is.null(model)) {
knots <- featureEngineeringSettings$knots
ageData <- trainData$labels
y <- ageData$outcomeCount
X <- ageData$ageYear
model <- mgcv::gam(
y ~ s(X, bs='cr', k=knots, m=2)
y ~ s(X, bs = "cr", k = knots, m = 2)
)
newData <- data.frame(
rowId = ageData$rowId,
covariateId = 2002,
covariateValue = model$fitted.values
)
}
else {
} else {
ageData <- trainData$labels
X <- trainData$labels$ageYear
y <- ageData$outcomeCount
newData <- data.frame(y=y, X=X)
newData <- data.frame(y = y, X = X)
yHat <- predict(model, newData)
newData <- data.frame(
rowId = trainData$labels$rowId,
covariateId = 2002,
covariateValue = yHat
)
}
# remove existing age if in covariates
trainData$covariateData$covariates <- trainData$covariateData$covariates |>
dplyr::filter(!covariateId %in% c(1002))
# remove existing age if in covariates
trainData$covariateData$covariates <- trainData$covariateData$covariates |>
dplyr::filter(!.data$covariateId %in% c(1002))
# update covRef
Andromeda::appendToTable(trainData$covariateData$covariateRef,
data.frame(covariateId=2002,
covariateName='Cubic restricted age splines',
analysisId=2,
conceptId=2002))
Andromeda::appendToTable(
trainData$covariateData$covariateRef,
data.frame(
covariateId = 2002,
covariateName = "Cubic restricted age splines",
analysisId = 2,
conceptId = 2002
)
)
# update covariates
Andromeda::appendToTable(trainData$covariateData$covariates, newData)
featureEngineering <- list(
funct = 'implementAgeSplines',
funct = "implementAgeSplines",
settings = list(
featureEngineeringSettings = featureEngineeringSettings,
model = model
)
)
attr(trainData$covariateData, 'metaData')$featureEngineering = listAppend(
attr(trainData$covariateData, 'metaData')$featureEngineering,
attr(trainData$covariateData, "metaData")$featureEngineering <- listAppend(
attr(trainData$covariateData, "metaData")$featureEngineering,
featureEngineering
)
return(trainData)
}
```

# Acknowledgments
Expand Down
Loading

0 comments on commit 2d8f225

Please sign in to comment.