From ba0ea1d21032e6e05bc87280104fc361c0934c8e Mon Sep 17 00:00:00 2001 From: "Zhaoyuan (Ryan) Fu" Date: Thu, 7 Nov 2024 13:24:41 -0500 Subject: [PATCH] Patient level filtering works for non-NA --- .../helper/StudyViewFilterHelper.java | 18 +++-- .../StudyViewFilterMapper.xml | 79 +++++++++++++------ .../mybatisclickhouse/StudyViewMapper.xml | 4 +- 3 files changed, 72 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/cbioportal/persistence/helper/StudyViewFilterHelper.java b/src/main/java/org/cbioportal/persistence/helper/StudyViewFilterHelper.java index d10d85d98c4..2a06b059d42 100644 --- a/src/main/java/org/cbioportal/persistence/helper/StudyViewFilterHelper.java +++ b/src/main/java/org/cbioportal/persistence/helper/StudyViewFilterHelper.java @@ -63,11 +63,7 @@ private CategorizedGenericAssayDataCountFilter extractGenericAssayDataCountFilte CategorizedGenericAssayDataCountFilter.Builder builder = CategorizedGenericAssayDataCountFilter.getBuilder(); - // TODO: Support patient level profiles and data filtering - List sampleCategoricalProfileTypes = genericAssayProfilesMap.get(DataSource.SAMPLE) - .stream().filter(profile -> profile.getDatatype().equals("CATEGORICAL") || profile.getDatatype().equals("BINARY")) - .map(profile -> profile.getStableId().replace(profile.getCancerStudyIdentifier() + "_", "")) - .toList(); + // TODO: Support data filtering List sampleNumericalProfileTypes = genericAssayProfilesMap.get(DataSource.SAMPLE) .stream().filter(profile -> profile.getDatatype().equals("LIMIT-VALUE")) .map(profile -> profile.getStableId().replace(profile.getCancerStudyIdentifier() + "_", "")) @@ -75,9 +71,21 @@ private CategorizedGenericAssayDataCountFilter extractGenericAssayDataCountFilte builder.setSampleNumericalGenericAssayDataFilters(studyViewFilter.getGenericAssayDataFilters().stream() .filter(genericAssayDataFilter -> sampleNumericalProfileTypes.contains(genericAssayDataFilter.getProfileType())) .toList()); + List sampleCategoricalProfileTypes = genericAssayProfilesMap.get(DataSource.SAMPLE) + .stream().filter(profile -> profile.getDatatype().equals("CATEGORICAL") || profile.getDatatype().equals("BINARY")) + .map(profile -> profile.getStableId().replace(profile.getCancerStudyIdentifier() + "_", "")) + .toList(); builder.setSampleCategoricalGenericAssayDataFilters(studyViewFilter.getGenericAssayDataFilters().stream() .filter(genericAssayDataFilter -> sampleCategoricalProfileTypes.contains(genericAssayDataFilter.getProfileType())) .toList()); + // Patient level profiles only have CATEGORICAL datatype for now + List patientCategoricalProfileTypes = genericAssayProfilesMap.get(DataSource.PATIENT) + .stream().filter(profile -> profile.getDatatype().equals("CATEGORICAL")) + .map(profile -> profile.getStableId().replace(profile.getCancerStudyIdentifier() + "_", "")) + .toList(); + builder.setPatientCategoricalGenericAssayDataFilters(studyViewFilter.getGenericAssayDataFilters().stream() + .filter(genericAssayDataFilter -> patientCategoricalProfileTypes.contains(genericAssayDataFilter.getProfileType())) + .toList()); return builder.build(); } diff --git a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml index 841fd4abf6a..f7d34a34b03 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml @@ -138,7 +138,6 @@ - ( @@ -154,25 +153,9 @@ - - - ( - - - - - ) - - - - - - - - - - - + + + @@ -549,9 +532,61 @@ + + + + ( + + + + + ) + + + + + ( + + + + + ) + + + -- patient level profile only have category for now + + + ( + SELECT sample_unique_id + FROM sample_derived + WHERE patient_unique_id IN ( + + + + + ) + ) + + + + + ( + SELECT sample_unique_id + FROM sample_derived + WHERE patient_unique_id IN ( + + + + + ) + ) + + + + - SELECT sample_unique_id, value, datatype - FROM generic_assay_data_derived + SELECT sample_unique_id, patient_unique_id, value, datatype + FROM generic_assay_data_derived_patient WHERE profile_type = #{genericAssayDataFilter.profileType} AND entity_stable_id = #{genericAssayDataFilter.stableId} diff --git a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml index d714eedfc20..2ae5ced9a2b 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml @@ -315,7 +315,7 @@ entity_stable_id AS stableId, value, cast(count(*) AS INTEGER) AS count - FROM generic_assay_data_derived + FROM generic_assay_data_derived_patient @@ -723,7 +723,7 @@ AS value, cast(count(value) as INTEGER) AS count - FROM generic_assay_data_derived + FROM generic_assay_data_derived_patient