-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/hartwigmedical/hmftools
- Loading branch information
Showing
11 changed files
with
221 additions
and
115 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...common/src/main/java/com/hartwig/hmftools/common/cuppa/interpretation/CuppaReporting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.hartwig.hmftools.common.cuppa.interpretation; | ||
|
||
import org.immutables.value.Value; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Value.Immutable | ||
@Value.Style(passAnnotations = { NotNull.class, Nullable.class }) | ||
public abstract class CuppaReporting { | ||
|
||
@NotNull | ||
public abstract String bestCancerType(); | ||
|
||
public abstract double bestLikelihood(); | ||
|
||
@NotNull | ||
public abstract String interpretCancerType(); | ||
|
||
@Nullable | ||
public abstract Double interpretLikelihood(); | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...src/main/java/com/hartwig/hmftools/common/cuppa/interpretation/CuppaReportingFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.hartwig.hmftools.common.cuppa.interpretation; | ||
|
||
import org.apache.logging.log4j.util.Strings; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CuppaReportingFactory { | ||
|
||
private CuppaReportingFactory() { | ||
} | ||
|
||
private static final String RESULTS_INCONCLUSIVE = "results inconclusive"; | ||
|
||
@NotNull | ||
public static String curatedTumorLocation(@NotNull String cancerType) { | ||
if (cancerType.equals("Uterus: Endometrium")) { | ||
cancerType = "Endometrium"; | ||
} else if (cancerType.equals("Colorectum/Appendix/SmallIntestine")) { | ||
cancerType = "Lower GI tract"; | ||
} | ||
return cancerType; | ||
} | ||
|
||
@NotNull | ||
public static String interpretTumorLocation(double likelihood, @NotNull String cancerType) { | ||
// our cut-off is 80% likelihood. When this is below 80% then the results is inconclusive | ||
String interpretCancerType = Strings.EMPTY; | ||
if (likelihood <= 0.8) { | ||
interpretCancerType = RESULTS_INCONCLUSIVE; | ||
} else { | ||
interpretCancerType = cancerType; | ||
} | ||
return interpretCancerType; | ||
} | ||
|
||
@NotNull | ||
public static CuppaReporting createCuppaReportingData(@NotNull CuppaPrediction bestPrediction) { | ||
double likelihood = bestPrediction.likelihood(); | ||
String cancerType = curatedTumorLocation(bestPrediction.cancerType()); | ||
String interpretCancerType = interpretTumorLocation(likelihood, cancerType); | ||
Double interpretLikelihood = likelihood >= 0.5 ? likelihood : null; | ||
|
||
return ImmutableCuppaReporting.builder() | ||
.bestCancerType(cancerType) | ||
.bestLikelihood(likelihood) | ||
.interpretCancerType(interpretCancerType) | ||
.interpretLikelihood(interpretLikelihood) | ||
.build(); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...test/java/com/hartwig/hmftools/common/cuppa/interpretation/CuppaReportingFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.hartwig.hmftools.common.cuppa.interpretation; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
|
||
public class CuppaReportingFactoryTest { | ||
|
||
private static final double EPSILON = 1.0E-10; | ||
|
||
@Test | ||
public void canCreateCuppaReportingKnown() { | ||
CuppaPrediction prediction = ImmutableCuppaPrediction.builder().cancerType("Melanoma").likelihood(0.90).build(); | ||
CuppaReporting reporting = CuppaReportingFactory.createCuppaReportingData(prediction); | ||
assertEquals("Melanoma", reporting.bestCancerType()); | ||
assertEquals(0.90, reporting.bestLikelihood(), EPSILON); | ||
assertEquals("Melanoma", reporting.interpretCancerType()); | ||
assertEquals(0.90, reporting.interpretLikelihood(), EPSILON); | ||
} | ||
|
||
@Test | ||
public void canCreateCuppaReportingKnownUterus() { | ||
CuppaPrediction prediction = ImmutableCuppaPrediction.builder().cancerType("Uterus: Endometrium").likelihood(0.90).build(); | ||
CuppaReporting reporting = CuppaReportingFactory.createCuppaReportingData(prediction); | ||
assertEquals("Endometrium", reporting.bestCancerType()); | ||
assertEquals(0.90, reporting.bestLikelihood(), EPSILON); | ||
assertEquals("Endometrium", reporting.interpretCancerType()); | ||
assertEquals(0.90, reporting.interpretLikelihood(), EPSILON); | ||
} | ||
|
||
@Test | ||
public void canCreateCuppaReportingKnownColon() { | ||
CuppaPrediction prediction = ImmutableCuppaPrediction.builder().cancerType("Colorectum/Appendix/SmallIntestine").likelihood(0.90).build(); | ||
CuppaReporting reporting = CuppaReportingFactory.createCuppaReportingData(prediction); | ||
assertEquals("Lower GI tract", reporting.bestCancerType()); | ||
assertEquals(0.90, reporting.bestLikelihood(), EPSILON); | ||
assertEquals("Lower GI tract", reporting.interpretCancerType()); | ||
assertEquals(0.90, reporting.interpretLikelihood(), EPSILON); | ||
} | ||
|
||
@Test | ||
public void canCreateCuppaReportingInconclusiveWithLikelihood() { | ||
CuppaPrediction prediction = ImmutableCuppaPrediction.builder().cancerType("Melanoma").likelihood(0.60).build(); | ||
CuppaReporting reporting = CuppaReportingFactory.createCuppaReportingData(prediction); | ||
assertEquals("Melanoma", reporting.bestCancerType()); | ||
assertEquals(0.60, reporting.bestLikelihood(), EPSILON); | ||
assertEquals("results inconclusive", reporting.interpretCancerType()); | ||
assertEquals(0.60, reporting.interpretLikelihood(), EPSILON); | ||
} | ||
|
||
@Test | ||
public void canCreateCuppaReportingInconclusiveWithoutLikelihood() { | ||
CuppaPrediction prediction = ImmutableCuppaPrediction.builder().cancerType("Melanoma").likelihood(0.40).build(); | ||
CuppaReporting reporting = CuppaReportingFactory.createCuppaReportingData(prediction); | ||
assertEquals("Melanoma", reporting.bestCancerType()); | ||
assertEquals(0.40, reporting.bestLikelihood(), EPSILON); | ||
assertEquals("results inconclusive", reporting.interpretCancerType()); | ||
assertNull(reporting.interpretLikelihood()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.