private List<String> initializeList(int size) { List<String> os = new ArrayList<String>(size); for (int lc = 0; lc < size; lc++) { os.add(lc, ""); } return os; }
private List<String> convertFollowupPatientIds(List<String> patientIds) { List<String> convertedPatientIds = new ArrayList<String>(); for (String patientId : patientIds) { Matcher patientIdMatcher = FOLLOW_UP_PATIENT_ID_REGEX.matcher(patientId); convertedPatientIds.add(patientIdMatcher.find() ? patientIdMatcher.group(1) : patientId); } return convertedPatientIds; }
private Map<String, DiseaseFreeData> getDiseaseFreeDataForMatrix(DataMatrix dataMatrix) { Map<String, DiseaseFreeData> diseaseFreeDataMap = new HashMap<String, DiseaseFreeData>(); List<String> patientIds = getPatientIds(dataMatrix); for (int lc = 0; lc < patientIds.size(); lc++) { String patientId = patientIds.get(lc); DiseaseFreeData df = getDiseaseFreeDataForPatient(lc, dataMatrix); if (diseaseFreeDataMap.containsKey(patientId)) { df = mergeDiseaseFreeData(diseaseFreeDataMap.get(patientId), df); } diseaseFreeDataMap.put(patientId, df); } return diseaseFreeDataMap; }
private Map<String, SurvivalData> getSurvivalDataForMatrix(DataMatrix dataMatrix) { Map<String, SurvivalData> survivalDataMap = new HashMap<String, SurvivalData>(); List<String> patientIds = getPatientIds(dataMatrix); for (int lc = 0; lc < patientIds.size(); lc++) { String patientId = patientIds.get(lc); SurvivalData sd = getSurvivalDataForPatient(lc, dataMatrix); if (survivalDataMap.containsKey(patientId)) { sd = mergeSurvivalData(survivalDataMap.get(patientId), sd); } survivalDataMap.put(patientId, sd); } return survivalDataMap; }
/** * The list is in ascending (time) order, i.e., patient matrix would come before follow-up * matrices. */ @Override public SurvivalStatus computeSurvivalData(List<DataMatrix> dataMatrices) { canonicalPatientList = getPatientIds(dataMatrices.get(0)); SurvivalStatus oss = new SurvivalStatus(); computeSurvivalData(oss, getSurvivalData(dataMatrices)); computeDiseaseFreeData(oss, getDiseaseFreeData(dataMatrices)); return oss; }
private void printList(List<String> list) { System.out.print("("); int ct = 0; for (String value : list) { if (value.isEmpty()) { value = "[]"; } System.out.print(value); if (++ct < list.size()) { System.out.print(", "); } } System.out.print(")\t\t"); }
private List<String> computeOverallSurvivalStatus(Map<String, SurvivalData> survivalData) { List<String> osStatus = initializeList(canonicalPatientList.size()); for (String patientId : survivalData.keySet()) { int osStatusIndex = canonicalPatientList.indexOf(patientId); SurvivalData sd = survivalData.get(patientId); if (VitalStatusAlive.has(sd.vitalStatus)) { osStatus.set(osStatusIndex, VitalStatusAlive.LIVING.toString()); } else if (VitalStatusDead.has(sd.vitalStatus)) { osStatus.set(osStatusIndex, VitalStatusDead.DECEASED.toString()); } else { osStatus.set(osStatusIndex, ClinicalAttribute.NA); } } return osStatus; }
private List<String> computeOverallSurvivalMonths(Map<String, SurvivalData> survivalData) { List<String> osStatusMonths = initializeList(canonicalPatientList.size()); for (String patientId : survivalData.keySet()) { int osStatusMonthsIndex = canonicalPatientList.indexOf(patientId); SurvivalData sd = survivalData.get(patientId); if (VitalStatusAlive.has(sd.vitalStatus)) { osStatusMonths.set( osStatusMonthsIndex, convertDaysToMonths(sd.lastFollowUp, sd.lastKnownAlive)); } else if (VitalStatusDead.has(sd.vitalStatus)) { osStatusMonths.set(osStatusMonthsIndex, convertDaysToMonths(sd.daysToDeath)); } else { osStatusMonths.set(osStatusMonthsIndex, ClinicalAttribute.NA); } } return osStatusMonths; }
private List<String> computeDiseaseFreeStatus(Map<String, DiseaseFreeData> diseaseFreeData) { List<String> dfStatus = initializeList(canonicalPatientList.size()); for (String patientId : diseaseFreeData.keySet()) { int dfStatusIndex = canonicalPatientList.indexOf(patientId); DiseaseFreeData df = diseaseFreeData.get(patientId); if (patientIsDiseaseFree(df)) { dfStatus.set(dfStatusIndex, DiseaseFreeStatus.DISEASE_FREE.toString()); } else { try { Integer.parseInt(df.daysToNewTumorEventAfterInitialTreatment); dfStatus.set(dfStatusIndex, DiseaseFreeStatus.DISEASED.toString()); } catch (NumberFormatException e) { dfStatus.set(dfStatusIndex, ClinicalAttribute.NA); } } } return dfStatus; }
private List<String> computeDiseaseFreeMonths(Map<String, DiseaseFreeData> diseaseFreeData) { List<String> dfStatusMonths = initializeList(canonicalPatientList.size()); for (String patientId : diseaseFreeData.keySet()) { int dfStatusMonthsIndex = canonicalPatientList.indexOf(patientId); DiseaseFreeData df = diseaseFreeData.get(patientId); try { if (patientIsDiseaseFree(df)) { dfStatusMonths.set( dfStatusMonthsIndex, convertDaysToMonths(df.lastFollowUp, df.lastKnownAlive)); } else { int dfStatusDays = Integer.parseInt(df.daysToNewTumorEventAfterInitialTreatment); dfStatusMonths.set( dfStatusMonthsIndex, convertDaysToMonths(Integer.toString(dfStatusDays))); } } catch (NumberFormatException e) { dfStatusMonths.set(dfStatusMonthsIndex, ClinicalAttribute.NA); } } return dfStatusMonths; }
private void dumpSurvivalData(Map<String, List<SurvivalData>> survivalData) { List<String> daysToDeath = new ArrayList<String>(); List<String> lastFollowUp = new ArrayList<String>(); List<String> lastKnownAlive = new ArrayList<String>(); List<String> vitalStatus = new ArrayList<String>(); for (String patientId : new TreeSet<String>(survivalData.keySet())) { for (SurvivalData sd : survivalData.get(patientId)) { daysToDeath.add(sd.daysToDeath); lastFollowUp.add(sd.lastFollowUp); lastKnownAlive.add(sd.lastKnownAlive); vitalStatus.add(sd.vitalStatus); } System.out.print(patientId + "\t\t"); printList(daysToDeath); printList(lastFollowUp); printList(lastKnownAlive); printList(vitalStatus); System.out.println(); daysToDeath.clear(); lastFollowUp.clear(); lastKnownAlive.clear(); vitalStatus.clear(); } }