Critical Data Marathon: Team SAPS

References

Load packages

library(ggplot2)

Load data

## Load ICU stay detail (most important)
dataIcuStayDetail <- read.csv("~/mimic2/data_ICUSTAY_DETAIL-merge_final.txt")

## Check units
table(dataIcuStayDetail$ICUSTAY_FIRST_CAREUNIT)
## 
##     CCU    CSRU    FICU    MICU    NICU    SICU UNKNOWN 
##    7048   10898    3462    9180    8080    1753       4

SAPS distribution: study cohort

ggplot(data = subset(dataIcuStayDetail, ICUSTAY_EXPIRE_FLG %in% c("Y","N")),
       mapping = aes(x = SAPSI_FIRST, fill = ICUSTAY_EXPIRE_FLG)) +
    layer(geom = "histogram", position = "dodge", binwidth = 1) +
    theme_bw() +
    theme(legend.key = element_blank())

plot of chunk unnamed-chunk-4

Checking each cohort assembly step

## Check total number: 40425
nrow(dataIcuStayDetail)
## [1] 40425

## subset to SAPS > 20: 2996
dataIcuStayDetail <- subset(dataIcuStayDetail,
                            !is.na(SAPSI_FIRST) &
                            SAPSI_FIRST > 20
                            )
nrow(dataIcuStayDetail)
## [1] 2996

## subset to first ICU stay: 2787
dataIcuStayDetail <- subset(dataIcuStayDetail,
                            !is.na(SAPSI_FIRST) &
                            SAPSI_FIRST > 20 &
                            ICUSTAY_FIRST_FLG == "Y"
                            )
nrow(dataIcuStayDetail)
## [1] 2787


## subset to first hospital stay: 2309
dataIcuStayDetail <- subset(dataIcuStayDetail,
                            !is.na(SAPSI_FIRST) &
                            SAPSI_FIRST > 20 &
                            ICUSTAY_FIRST_FLG == "Y" &
                            HOSPITAL_FIRST_FLG == "Y"   # 2014-01-05
                            )
nrow(dataIcuStayDetail)
## [1] 2309

## subset to MICU: 497
dataIcuStayDetail <- subset(dataIcuStayDetail,
                            !is.na(SAPSI_FIRST) &
                            SAPSI_FIRST > 20 &
                            ICUSTAY_FIRST_FLG == "Y" &
                            HOSPITAL_FIRST_FLG == "Y" &
                            ICUSTAY_FIRST_CAREUNIT == "MICU"
                            )
nrow(dataIcuStayDetail)
## [1] 497

In-hospital death

table(dataIcuStayDetail$ICUSTAY_EXPIRE_FLG)
## 
##   N   Y 
## 291 206

SAPS distribution: study cohort

ggplot(data = dataIcuStayDetail,
       mapping = aes(x = SAPSI_FIRST, fill = ICUSTAY_EXPIRE_FLG)) +
    layer(geom = "histogram", position = "dodge", binwidth = 1) +
    theme_bw() +
    theme(legend.key = element_blank())

plot of chunk unnamed-chunk-7