Skip to content

Commit

Permalink
Enable log scale for all clinical attributes with data type as number
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilBtara committed Dec 10, 2024
1 parent 18599b2 commit 5a8678d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/org/cbioportal/web/StudyViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,10 @@ public List<GenomicDataCount> cacheableFetchMolecularProfileSampleCounts(StudyVi
return genomicDataCounts;
}

private static boolean isLogScalePossibleForAttribute(String clinicalAttributeId) {
return clinicalAttributeId.equals("MUTATION_COUNT");
private static boolean isLogScalePossibleForAttribute(String clinicalAttributeId, List<ClinicalAttribute> clinicalAttributeList) {
return clinicalAttributeList.stream().
filter(attribute -> attribute.getAttrId().equals(clinicalAttributeId)).
anyMatch(attribute -> attribute.getDatatype().equals("NUMBER"));
}

private static double logScale(double val) {
Expand Down Expand Up @@ -643,8 +645,8 @@ public ResponseEntity<DensityPlotData> fetchClinicalDataDensityPlot(
Map<Boolean, List<ClinicalData>> 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
Expand Down Expand Up @@ -854,7 +856,7 @@ public ResponseEntity<ClinicalViolinPlotData> fetchClinicalDataViolinPlots(
sampleClinicalDataList = clinicalDataList;
}

boolean useLogScale = logScale && StudyViewController.isLogScalePossibleForAttribute(numericalAttributeId);
boolean useLogScale = logScale && StudyViewController.isLogScalePossibleForAttribute(numericalAttributeId, clinicalAttributes);


result = violinPlotService.getClinicalViolinPlotData(
Expand Down

0 comments on commit 5a8678d

Please sign in to comment.