Debuting with MIMIC 3 and R - Part II: Working Around Albumine
One of the question we get interested in is the influence of the albumine on the survival rate.
First, we find all the items related to albumine.
query <- "select * from mimiciii.D_ITEMS where label ~~* '%albumin%';"
item.albumin <- sqldf(query)
query <- "select * from mimiciii.D_ITEMS where label ~~* '%albumin%';"
item.albumin <- sqldf(query)
## row_id itemid label fluid
## 1 269 51069 ALBUMIN, URINE URINE
## 2 270 51070 ALBUMIN/CREATININE, URINE URINE
## 3 755 51555 SURFACTANT ALBUMIN RATIO OTHER BODY FLUID
## 4 36 50835 ALBUMIN, ASCITES ASCITES
## 5 63 50862 ALBUMIN BLOOD
## 6 211 51011 <ALBUMIN> CEREBROSPINAL FLUID (CSF)
## 7 219 51019 ALBUMIN, JOINT FLUID JOINT FLUID
## 8 225 51025 ALBUMIN, BODY FLUID OTHER BODY FLUID
## 9 246 51046 ALBUMIN, PLEURAL PLEURAL
## category loinc_code
## 1 CHEMISTRY 1754-1
## 2 CHEMISTRY 14958-3
## 3 CHEMISTRY
## 4 CHEMISTRY 1749-1
## 5 CHEMISTRY 1751-7
## 6 CHEMISTRY 1746-7
## 7 CHEMISTRY
## 8 CHEMISTRY 1747-5
## 9 CHEMISTRY 1748-3
In the end, only the lab event interest us, with blood fluid.
Get Albumine patients data
The question of the day is to study the effect of Albumine on a bunch of patients.
The query may seems a little bit complicated, but do the job. At the patient * admission level, we compile: - the gender of the patient. - if the patient died during the admission time. - the minimum value of albumin in the two days after the admission. - the minimum time between the admission and the first albumin dose. - the length of stay in ICU. - if the patient went in one of this three care unit: – CVICU – SICU – CSICU
# The query:
query.albumine.patient <- "select tab1.*, tab2.los
, tab2.intime
, tab2.num_cvicu
, tab2.num_sicu
, tab2.num_csicu
from ( select i.*
, a.gender
, a.dob
, a.hospital_expire_flag
, b.deathtime
, b.admittime
, b.dischtime
from ( select a.subject_id
, b.hadm_id
, min(case when DATE_PART('day', c.charttime - b.admittime) <3 then c.valuenum else NULL end) as min_value_two_day_after_admission
, min(DATE_PART('day', c.charttime - b.admittime) * 24 + DATE_PART('hour', c.charttime - b.admittime)) as min_diff_hours_admin_treatment
from mimiciii.patients as a
inner join mimiciii.admissions as b
on a.subject_id = b.subject_id
left join mimiciii.labevents as c
on a.subject_id = c.subject_id and c.charttime between b.admittime and b.dischtime
where c.itemid = 50862 -- Albumine only
group by a.subject_id, b.hadm_id ) as i
left join mimiciii.patients as a
on a.subject_id = i.subject_id
left join mimiciii.admissions as b
on i.subject_id = b.subject_id and i.hadm_id = b.hadm_id ) as tab1
left join ( select a.subject_id
, b.hadm_id
, c.los
, c.intime
, j.num_cvicu
, j.num_sicu
, j.num_csicu
from mimiciii.patients as a
inner join mimiciii.admissions as b
on a.subject_id = b.subject_id
left join (
select subject_id
, hadm_id
, min(intime) as min_intime
, sum(case when first_careunit = 'CVICU' then 1 else 0 end) as num_cvicu
, sum(case when first_careunit = 'SICU' then 1 else 0 end) as num_sicu
, sum(case when first_careunit = 'CSICU' then 1 else 0 end) as num_csicu
from mimiciii.icustayevents group by subject_id
, hadm_id) j
on a.subject_id = j.subject_id and b.hadm_id = j.hadm_id
left join mimiciii.icustayevents as c
on a.subject_id = c.subject_id and b.hadm_id = c.hadm_id and j.min_intime = c.intime ) as tab2
on tab1.subject_id = tab2.subject_id and tab1.hadm_id = tab2.hadm_id ;"
# Now, import the data
albumine.patients <- sqldf(query.albumine.patient)
# tighten the table:
albumine.patients.dt <- data.table(albumine.patients)
setnames(albumine.patients.dt, names(albumine.patients.dt), tolower(names(albumine.patients.dt)))
Taking only the last admission among all.
albumine.patients.dt2[, list(count = format(.N, big.mark = ",")), by = c("gender")]
## gender count
## 1: M 12,777
## 2: F 9,781
There is more men than women which add been their albumin measured in laboratory.
ggplot(data = albumine.patients.dt2, aes(x = hospital_expire_flag, y = min_value_two_day_after_admission)) +
geom_boxplot(color = "blue", fill = "cyan") +
facet_wrap(~age, nrow = 4)
Low albumin is linked to a death in hospital at all ages.
Surgical intensive care unit
ggplot(data = albumine.patients.dt2, aes(x = hospital_expire_flag, y = min_value_two_day_after_admission)) +
geom_boxplot(color = "blue", fill = "cyan") +
facet_wrap(~flg_sicu, nrow = 1)
Cardiovascular Intensive Care Unit
ggplot(data = albumine.patients.dt2, aes(x = hospital_expire_flag, y = min_value_two_day_after_admission)) +
geom_boxplot(color = "blue", fill = "cyan") +
facet_wrap(~flg_cvicu, nrow = 1)
Cardiac Surgery Intensive Care Unit
ggplot(data = albumine.patients.dt2, aes(x = hospital_expire_flag, y = min_value_two_day_after_admission)) +
geom_boxplot(color = "blue", fill = "cyan") +
facet_wrap(~flg_csicu, nrow = 1)
People admitted in cardiac surgery dont have a death linked to a low rate of albumine, looking at the current data.
Leave a Comment