Prediction Result
Contact Information for the prediction model
Article Inquiries:
- Email: jeroenvanBavel@xxx.nl
Application Support:
- Technical Support: info_prediction@amsterdamUMC.nl
OASI Prediction Tool Nulliparous womenPrediction ResultContact Information for the prediction modelArticle Inquiries: - Email: jeroenvanBavel@xxx.nl Application Support: - Technical Support: info_prediction@amsterdamUMC.nl |
library(shiny)
# Define the probability calculation function
calculate_probability <- function(inputs, intercept) {
logit <- intercept + sum(inputs)
probability <- 1 / (1 + exp(-logit))
return(probability)
}
# Define UI
ui <- fluidPage(
titlePanel("OASI Prediction Tool Nulliparous women"),
sidebarLayout(
sidebarPanel(width=6,
selectInput("delivery_type", "Choose the type of Model Spontaneous or Instrumental",
choices = c("Choose a model",
"Model 1 Spontaneous vaginal delivery",
"Model 2 Instrumental delivery")),
# ALL predictor inputs must be inside this conditionalPanel
conditionalPanel(
condition = "input.delivery_type != 'Choose a model'",
h4("Enter Predictor Values"),
selectInput("gestational_age", "Gestational Age (Weeks)",
choices = c("40.0-40.6","37.0-37.6", "38.0-38.6", "39.0-39.6", "41.0-41.6", "42.0-42.6")),
sliderInput("maternal_age", "Maternal Age (Years)", min = 14, max = 50, value = 29),
selectInput("race", "Maternal Race/Ethnicity",
choices = c("White European", "(South) Asian", "Other Non-Western")),
selectInput("induction", "Induction of Labour", choices = c("No", "Yes")),
selectInput("fetal_sex", "Fetal Sex", choices = c("Male", "Female")),
selectInput("fetal_weight", "Expected Fetal Birth Weight",
choices = c("3000-3999 grams", "< 3000 grams", "≥ 4000 grams")),
selectInput("epidural", "Epidural Analgesia", choices = c("No", "Yes")),
selectInput("fetal_presentation", "Fetal Presentation",
choices = c("Occipito-anterior and other", "Occipitoposterior")),
selectInput("duration_stage", "Duration of 2nd Stage of Labour",
choices = c("< 30 minutes", "30-59 minutes", "60-119 minutes", "≥ 120 minutes")),
selectInput("episiotomy", "Mediolateral Episiotomy (Yes/No)",
choices = c("No", "Yes")),
actionButton("predict", "Predict Probability OASI", style = "font-size: 18px; padding: 10px 20px;")
),
conditionalPanel(
condition = "input.delivery_type == 'Choose a model'",
h4("Study Overview"),
p("This study aimed to develop and validate prediction models for Obstetric Anal Sphincter Injury (OASI) in nulliparous women. The models focus on two types of deliveries:"),
p("1. Model for Spontaneous vaginal delivery"),
p("2. Model for Instrumental delivery"),
p(strong("Population:"), "Data from the Netherlands Perinatal Registry was used, which includes records from 2016-2020. The study focused on nulliparous women who delivered a singleton live-born infant in cephalic presentation at term, either through spontaneous or operative vaginal delivery.")
)
),
mainPanel(
h3("Prediction Result"),
verbatimTextOutput("result"),
hr(),
actionButton("contact", "Contact"),
conditionalPanel(
width = 4,
condition = "input.contact > 0",
h4("Contact Information for the prediction model"),
p(strong("Article Inquiries:")),
p("- Email: jeroenvanBavel@xxx.nl"),
p(strong("Application Support:")),
p("- Technical Support: info_prediction@amsterdamUMC.nl")
)
)
)
)
# Define server logic
server <- function(input, output) {
observeEvent(input$predict, {
if (input$delivery_type == "Choose a model") {
output$result <- renderPrint("Please select a model to proceed.")
return()
}
# Model 1: Spontaneous vaginal delivery
if (input$delivery_type == "Model 1 Spontaneous vaginal delivery") {
inputs <- c(
Episiotomy = if (input$episiotomy == "Yes") -1.162 else 0,
FetalWeight_less3000 = if (input$fetal_weight == "< 3000 grams") -0.677 else 0,
FetalWeight_3000_3999 = if (input$fetal_weight == "3000-3999 grams") 0 else 0,
FetalWeight_4000plus = if (input$fetal_weight == "≥ 4000 grams") 0.730 else 0,
Duration_less30 = if (input$duration_stage == "< 30 minutes") 0 else 0,
Duration_30_59 = if (input$duration_stage == "30-59 minutes") 0.192 else 0,
Duration_60_119 = if (input$duration_stage == "60-119 minutes") 0.290 else 0,
Duration_120plus = if (input$duration_stage == "≥ 120 minutes") 0.169 else 0,
Occipitoposterior = if (input$fetal_presentation == "Occipitoposterior") 0.257 else 0,
Induction = if (input$induction == "Yes") -0.142 else 0,
Epidural = if (input$epidural == "Yes") -0.353 else 0,
Race_SouthAsian = if (input$race == "(South) Asian") 0.636 else 0,
Race_NonWestern = if (input$race == "Other Non-Western") 0.087 else 0,
MaternalAge = 0.021 * input$maternal_age,
GestAge_37 = if (input$gestational_age == "37.0-37.6") -0.270 else 0,
GestAge_38 = if (input$gestational_age == "38.0-38.6") -0.174 else 0,
GestAge_39 = if (input$gestational_age == "39.0-39.6") -0.035 else 0,
GestAge_40 = if (input$gestational_age == "40.0-40.6") 0 else 0,
GestAge_41 = if (input$gestational_age == "41.0-41.6") -0.006 else 0,
GestAge_42 = if (input$gestational_age == "42.0-42.6") 0.002 else 0,
FetalSex_Boy = if (input$fetal_sex == "Male") 0.058 else 0
)
intercept <- -3.605
}
# Model 2: Instrumental delivery
else if (input$delivery_type == "Model 2 Instrumental delivery") {
inputs <- c(
Episiotomy = if (input$episiotomy == "Yes") -1.683 else 0,
FetalWeight_less3000 = if (input$fetal_weight == "< 3000 grams") -0.577 else 0,
FetalWeight_3000_3999 = if (input$fetal_weight == "3000-3999 grams") 0 else 0,
FetalWeight_4000plus = if (input$fetal_weight == "≥ 4000 grams") 0.390 else 0,
Duration_less30 = if (input$duration_stage == "< 30 minutes") 0 else 0,
Duration_30_59 = if (input$duration_stage == "30-59 minutes") 0.163 else 0,
Duration_60_119 = if (input$duration_stage == "60-119 minutes") 0.394 else 0,
Duration_120plus = if (input$duration_stage == "≥ 120 minutes") 0.420 else 0,
Occipitoposterior = if (input$fetal_presentation == "Occipitoposterior") 0.602 else 0,
Epidural = if (input$epidural == "Yes") -0.193 else 0,
Race_SouthAsian = if (input$race == "(South) Asian") 0.591 else 0,
Race_NonWestern = if (input$race == "Other Non-Western") 0.064 else 0,
GestAge_37 = if (input$gestational_age == "37.0-37.6") -0.436 else 0,
GestAge_38 = if (input$gestational_age == "38.0-38.6") -0.0543 else 0,
GestAge_39 = if (input$gestational_age == "39.0-39.6") 0.028 else 0,
GestAge_40 = if (input$gestational_age == "40.0-40.6") 0 else 0,
GestAge_41 = if (input$gestational_age == "41.0-41.6") 0.082 else 0,
GestAge_42 = if (input$gestational_age == "42.0-42.6") 0.186 else 0
)
intercept <- -2.270
}
probability <- calculate_probability(inputs, intercept)
output$result <- renderPrint({
paste("The predicted probability of OASI in% is:", round(probability * 100, 2), "%")
})
})
}
# Run the application
shinyApp(ui = ui, server = server)