library(Hmisc) #mtd <- read.csv("../data/SI-NET-MTD-updated for stat.csv") mtd <- read.csv("../data/SINET-MTD-stats-04-02-13.csv") # Three patients (mrn = c(11, 12, 31)) have been switched from DOD to D other. #mtd <- read.csv("../data/newSI-NET-MTD.csv") mtd <- upData(mtd, lowernames = TRUE, drop = c("x", "x.1", "x.2"), rename = list(m.f = "gender", lesion.size = "tumorSize", lesion.number = "numberTumors", ln = "lymphNodeMet", dos = "surgeryDate", liver = "liverMet", t.stage = "tStage", fu = "followupDate", x.liver.lesions.at.surgery = "numLiverLesSurg", liver.progression = "liverProgression", dod = "deathDate", date.of.progression = "progressionDate", # Is this only progressions after surgery?? date.of.1st.liver.lesion = "firstLiverLesionDate", a.d = "status"), tumorSize = as.numeric(as.character(tumorSize)), multipleLesions = factor(numberTumors), lymphNodeMet = factor(lymphNodeMet), liverMetAtSurgery = factor(numLiverLesSurg), mtd = factor(mtd), liverMet = factor(liverMet), lvi = factor(lvi), tStageCat = factor(tStage), logTumorSize = log(tumorSize), surgeryDate = as.Date(as.character(surgeryDate), format = "%m/%d/%Y"), followupDate = as.Date(as.character(followupDate), format = "%m/%d/%Y"), # per Chanjuan, follow up date is date of death for those who died. progressionDate = as.Date(as.character(progressionDate), format = "%m/%d/%Y"), deathDate = as.Date(as.character(deathDate), format = "%m/%d/%Y"), firstLiverLesionDate = as.Date(as.character(firstLiverLesionDate), format = "%m/%d/%Y"), osTime = as.numeric(followupDate - surgeryDate)*12/365.25, firstLiverLesionTimeSurg = as.numeric(firstLiverLesionDate - surgeryDate)*12/365.25, osStatus = factor(status), osStatusCensorDOC = factor(status), crStatus = factor(status), crPfsStatus = factor(ifelse(status %in% c("ANED", "AWD") & liverProgression %in% "0", "Progression-free, alive", ifelse(status == "DOD" | liverProgression %in% "1", "Progressed or died of disease", ifelse(status == "D other", "Died of other causes", NA)))), levels = list(gender = list("Male" = "M", "Female" = "F"), osStatus = list("Alive" = c("ANED", "AWD"), "Dead" = c("DOD", "D other")), osStatusCensorDOC = list("Alive or censored" = c("ANED", "AWD", "D other"), "Dead" = "DOD"), crStatus = list("Alive" = c("ANED", "AWD"), "Dead: disease" = "DOD", "Dead: other cause" = "D other"), crPfsStatus = list("Progression-free, alive" = "Progression-free, alive", "Progressed or died of disease" = "Progressed or died of disease", "Died of other causes" = "Died of other causes"), #need to check how to treat AWD and liverProgression tStageCat = list("T-stages 1, 2" = c("1", "2"), "T-stages 3, 4" = c("3", "4")), liverMet = list("No" = "0", "Yes" = "1"), liverProgression = list("No" = "0", "Yes" = "1"), mtd = list("No MTD" = "0", "MTD" = "1"), lvi = list("No LVI" = "0", "LVI" = "1"), multipleLesions = list("One" = "1", "Multiple" = c("2", "3", "4", "5", "6", "7", "multiple")), liverMetAtSurgery = list("No" = "0", "Yes" = c("1", "2", "3", "4", "5", "multiple", "numerous")), lymphNodeMet = list("No lymph node met" = "0", "Lymph node met" = "1")), labels = list(gender = "Gender", age = "Age", tumorSize = "Tumor size", logTumorSize = "Log tumor size", numberTumors = "Number of tumors", multipleLesions = "Number of tumors", lymphNodeMet = "Lymph node metastasis", mtd = "Mesenteric tumor deposits", liverMet = "Liver metastasis", liverMetAtSurgery = "Liver metastasis at time of surgery", liverProgression = "Liver progression after surgery", lvi = "Lymphovascular invasion", tStage = "T stage", firstLiverLesionTimeSurg = "Time from surgery to first liver lesion (months)", status = "Status", tStageCat = "T stage", osTime = "Overall survival follow up time (months)", crStatus = "Survival status", crPfsStatus = "Progression-free survival status", osStatus = "Overall survival status")) mtd <- upData(mtd, mtdLnm = interaction(mtd, lymphNodeMet), crStatusNum = as.numeric(crStatus) - 1, crPfsStatusNum = as.numeric(crPfsStatus) - 1, pfsStatus = factor(osStatus %in% "Dead" | liverProgression %in% "Yes"), pfsStatusCensorDOC = factor(osStatusCensorDOC %in% "Dead" | liverProgression %in% "Yes"), pfsTime = as.numeric(as.Date(ifelse(liverProgression == "Yes", progressionDate, followupDate), origin = "1970-01-01") - surgeryDate)*12/365.25, levels = list(pfsStatus = list("Progression-free, alive" = "FALSE", "Progressed or died" = "TRUE"), pfsStatusCensorDOC = list("Progression-free and alive or DOC," = "FALSE", "Progressed or died of disease" = "TRUE")), labels = list(pfsStatus = "Progression-free survival status", pfsStatusCensorDOC = "Progression-free survival status", pfsTime = "Progression-free survival follow up time (months)"))