From 5a8678d624353ba3bac4b015455bd7ced5e1f12f Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Tue, 10 Dec 2024 23:10:36 +0530 Subject: [PATCH] Enable log scale for all clinical attributes with data type as number --- .../java/org/cbioportal/web/StudyViewController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cbioportal/web/StudyViewController.java b/src/main/java/org/cbioportal/web/StudyViewController.java index 55d93d4f430..a4558953264 100644 --- a/src/main/java/org/cbioportal/web/StudyViewController.java +++ b/src/main/java/org/cbioportal/web/StudyViewController.java @@ -498,8 +498,10 @@ public List cacheableFetchMolecularProfileSampleCounts(StudyVi return genomicDataCounts; } - private static boolean isLogScalePossibleForAttribute(String clinicalAttributeId) { - return clinicalAttributeId.equals("MUTATION_COUNT"); + private static boolean isLogScalePossibleForAttribute(String clinicalAttributeId, List clinicalAttributeList) { + return clinicalAttributeList.stream(). + filter(attribute -> attribute.getAttrId().equals(clinicalAttributeId)). + anyMatch(attribute -> attribute.getDatatype().equals("NUMBER")); } private static double logScale(double val) { @@ -643,8 +645,8 @@ public ResponseEntity fetchClinicalDataDensityPlot( Map> partition = filteredClinicalDataList.stream().collect( Collectors.partitioningBy(c -> c.getAttrId().equals(xAxisAttributeId))); - boolean useXLogScale = xAxisLogScale && StudyViewController.isLogScalePossibleForAttribute(xAxisAttributeId); - boolean useYLogScale = yAxisLogScale && StudyViewController.isLogScalePossibleForAttribute(yAxisAttributeId); + boolean useXLogScale = xAxisLogScale && StudyViewController.isLogScalePossibleForAttribute(xAxisAttributeId, clinicalAttributes); + boolean useYLogScale = yAxisLogScale && StudyViewController.isLogScalePossibleForAttribute(yAxisAttributeId, clinicalAttributes); double[] xValues = partition.get(true).stream().mapToDouble( useXLogScale ? StudyViewController::parseValueLog : StudyViewController::parseValueLinear @@ -854,7 +856,7 @@ public ResponseEntity fetchClinicalDataViolinPlots( sampleClinicalDataList = clinicalDataList; } - boolean useLogScale = logScale && StudyViewController.isLogScalePossibleForAttribute(numericalAttributeId); + boolean useLogScale = logScale && StudyViewController.isLogScalePossibleForAttribute(numericalAttributeId, clinicalAttributes); result = violinPlotService.getClinicalViolinPlotData(