From c028f13519a4f60ae41b9418e230a72552db39b3 Mon Sep 17 00:00:00 2001 From: Onur Sumer Date: Fri, 25 Oct 2024 14:51:37 -0400 Subject: [PATCH] make clinical data sample/patient ids match legacy ids, and use stable ids to count samples when internal id is null --- .../impl/ClinicalDataDensityPlotServiceImpl.java | 2 +- .../service/impl/ViolinPlotServiceImpl.java | 12 ++++++++---- .../columnar/util/ClinicalDataViolinPlotUtil.java | 4 ++-- .../mybatisclickhouse/StudyViewMapper.xml | 6 +++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java b/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java index b6e4a55e679..10e4d588397 100644 --- a/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java @@ -33,7 +33,7 @@ public DensityPlotData getDensityPlotData(List sampleClinicalData, result.setBins(new ArrayList<>()); Map> clinicalDataGroupedBySampleId = sampleClinicalData.stream(). - collect(Collectors.groupingBy(ClinicalData::getSampleId)); + collect(Collectors.groupingBy(c -> c.getStudyId() + "_" + c.getSampleId())); List extractedXYClinicalData = clinicalDataGroupedBySampleId.entrySet().stream() .filter(entry -> entry.getValue().size() == 2 && diff --git a/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java b/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java index 53e7f620874..dc12a2400ec 100644 --- a/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java @@ -37,9 +37,11 @@ public ClinicalViolinPlotData getClinicalViolinPlotData( result.setRows(new ArrayList<>()); // collect filtered samples into a set for quick lookup - Set samplesForSampleCountsIds = + Set samplesForSampleCountsIds = samplesForSampleCounts.stream() - .map(Sample::getInternalId) + .map(s -> s.getInternalId() == null ? + s.getCancerStudyIdentifier() + "_" + s.getStableId(): s.getInternalId().toString() + ) .collect(Collectors.toSet()); // clinicalDataMap is a map sampleId->studyId->data @@ -212,12 +214,14 @@ public ClinicalViolinPlotData getClinicalViolinPlotData( @SafeVarargs private static int countFilteredSamples( - Set filteredSampleIds, + Set filteredSampleIds, List... dataLists ) { return (int) Arrays.stream(dataLists) .flatMap(Collection::stream) - .map(ClinicalData::getInternalId) + .map(c -> c.getInternalId() == null ? + c.getStudyId() + "_" + c.getSampleId() : c.getInternalId().toString() + ) .filter(filteredSampleIds::contains) .count(); } diff --git a/src/main/java/org/cbioportal/web/columnar/util/ClinicalDataViolinPlotUtil.java b/src/main/java/org/cbioportal/web/columnar/util/ClinicalDataViolinPlotUtil.java index 271d0745f25..597845db2ef 100644 --- a/src/main/java/org/cbioportal/web/columnar/util/ClinicalDataViolinPlotUtil.java +++ b/src/main/java/org/cbioportal/web/columnar/util/ClinicalDataViolinPlotUtil.java @@ -25,7 +25,7 @@ public static List convertPatientClinicalDataToSampleClinicalData( Map>> patientToSamples = samplesWithoutNumericalFilter .stream() .collect(Collectors.groupingBy( - s -> s.getCancerStudyIdentifier() + "_" + s.getPatientStableId(), + Sample::getPatientStableId, Collectors.groupingBy(Sample::getCancerStudyIdentifier) )); @@ -41,7 +41,7 @@ public static List convertPatientClinicalDataToSampleClinicalData( newData.setPatientId(d.getPatientId()); newData.setStudyId(d.getStudyId()); newData.setAttrValue(d.getAttrValue()); - newData.setSampleId(s.getCancerStudyIdentifier() + "_" + s.getStableId()); + newData.setSampleId(s.getStableId()); sampleClinicalDataList.add(newData); } diff --git a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml index 7ed1c05f8d3..fd7d37b6d6f 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml @@ -91,8 +91,8 @@ SELECT - patient_unique_id as patientId, + replaceOne(patient_unique_id, concat(cancer_study_identifier, '_'), '') as patientId, attribute_name as attrId, attribute_value as attrValue, cancer_study_identifier as studyId