Skip to content

Commit

Permalink
ACTIN-1057: Filter NaN likelihoods from CUPPA when converting in ORAN…
Browse files Browse the repository at this point in the history
…GE (#569)

* ACTIN-1057: Filter NaN likelihoods from CUPPA when converting in ORANGE

* ACTIN-1057: Remove reference to ticket from comment
  • Loading branch information
kduyvesteyn authored Jun 22, 2024
1 parent c97a47e commit 65fbdf1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 31 deletions.
4 changes: 3 additions & 1 deletion orange/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ investigate potential causes for QC failure.

## Version History and Download Links

- Upcoming
- Cuppa predictions with NaN likelihood are filtered in the ORANGE conversion of CUPPA results
- [3.5.1](https://github.com/hartwigmedical/hmftools/releases/tag/orange-v3.5.1)
- Workaround added for bug with mapping various ORANGE cohorts to non-existing ISOFOX cohorts.
- Workaround added for bug with mapping various ORANGE cohorts to non-existing ISOFOX cohorts.
- [3.5.0](https://github.com/hartwigmedical/hmftools/releases/tag/orange-v3.5.0)
- Add `PurpleTranscriptImpact.reported` and make `PurpleVariant.reported` a derived field. This
uses the REPORTABLE_TRANSCRIPTS vcf field introduced in PURPLE 4.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static CuppaData create(@NotNull String cuppaVisDataTsv) throws Exception
@NotNull
private static CuppaData createFromPredictions(@NotNull CuppaPredictions cuppaPredictions) throws Exception
{
List<CuppaPrediction> predictions = extractSortedProbabilities(cuppaPredictions);
List<CuppaPrediction> predictions = convertCuppaPredictions(cuppaPredictions);

if(predictions.isEmpty())
{
Expand All @@ -53,27 +53,23 @@ private static CuppaData createFromPredictions(@NotNull CuppaPredictions cuppaPr
}

@NotNull
private static List<CuppaPrediction> extractSortedProbabilities(@NotNull CuppaPredictions cuppaPredictions)
private static List<CuppaPrediction> convertCuppaPredictions(@NotNull CuppaPredictions cuppaPredictions)
{
CuppaPredictions probabilitiesAllClassifiers = cuppaPredictions
.subsetByDataType(DataType.PROB)
.sortByRank();
CuppaPredictions probabilitiesAllClassifiers = cuppaPredictions.subsetByDataType(DataType.PROB).sortByRank();

List<CuppaPrediction> cuppaPredictionsOrangeFormat = new ArrayList<>();
List<CuppaPrediction> convertedCuppaPredictions = new ArrayList<>();
for(String cancerType : probabilitiesAllClassifiers.CancerTypes)
{
CuppaPredictions probabilitiesOneCancerType = probabilitiesAllClassifiers.subsetByCancerType(cancerType);

Map<ClassifierName, Double> probabilitiesByClassifier = new HashMap<>();
for(int i = 0; i < probabilitiesOneCancerType.size(); i++)
{
probabilitiesByClassifier.put(
probabilitiesOneCancerType.get(i).ClassifierName,
probabilitiesOneCancerType.get(i).DataValue
);
probabilitiesByClassifier.put(probabilitiesOneCancerType.get(i).ClassifierName,
probabilitiesOneCancerType.get(i).DataValue);
}

CuppaPrediction prediction = ImmutableCuppaPrediction.builder()
CuppaPrediction convertedPrediction = ImmutableCuppaPrediction.builder()
.cancerType(cancerType)
.likelihood(probabilitiesByClassifier.get(probabilitiesAllClassifiers.MainCombinedClassifierName))
.genomicPositionClassifier(probabilitiesByClassifier.get(ClassifierName.GEN_POS))
Expand All @@ -83,9 +79,13 @@ private static List<CuppaPrediction> extractSortedProbabilities(@NotNull CuppaPr
.altSjCohortClassifier(probabilitiesByClassifier.get(ClassifierName.ALT_SJ))
.build();

cuppaPredictionsOrangeFormat.add(prediction);
// If a classifier has no data for a specific cancer type we should remove it completely.
if(!Double.isNaN(convertedPrediction.likelihood()))
{
convertedCuppaPredictions.add(convertedPrediction);
}
}
return cuppaPredictionsOrangeFormat;
return convertedCuppaPredictions;
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ public void canExtractPredictionsFromCuppaIncludingRna() throws Exception
.build();

Map<String, CuppaPrediction> expectedPredictionsByCancerType = new HashMap<>();
expectedPredictionsByCancerType.put("Skin: Melanoma", expectedPredictionMelanoma);
expectedPredictionsByCancerType.put("Skin: Other", expectedPredictionSkinOther);
expectedPredictionsByCancerType.put("Prostate", expectedPredictionProstate);
expectedPredictionsByCancerType.put(expectedPredictionMelanoma.cancerType(), expectedPredictionMelanoma);
expectedPredictionsByCancerType.put(expectedPredictionSkinOther.cancerType(), expectedPredictionSkinOther);
expectedPredictionsByCancerType.put(expectedPredictionProstate.cancerType(), expectedPredictionProstate);
expectedPredictionsByCancerType.put("Bone/Soft tissue: Cartilaginous neoplasm", null);

assertCuppaPredictions(CUPPA_VIS_DATA_WITH_RNA_TSV, expectedPredictionsByCancerType);
assertCuppaPredictions(CUPPA_VIS_DATA_WITH_RNA_TSV, 33, expectedPredictionsByCancerType);
}

@Test
Expand All @@ -89,13 +90,21 @@ public void canExtractPredictionsFromCuppaExcludingRna() throws Exception
.snvPairwiseClassifier(9.922426122823756e-16)
.featureClassifier(0.00012385594573787126)
.build();
CuppaPrediction expectedPredictionCartilaginousNeoplasm = ImmutableCuppaPrediction.builder()
.cancerType("Bone/Soft tissue: Cartilaginous neoplasm")
.likelihood(3.289402919513386e-05)
.genomicPositionClassifier(4.107161442240924e-10)
.snvPairwiseClassifier(4.414947168645547e-16)
.featureClassifier(1.4125023004735242e-09)
.build();

Map<String, CuppaPrediction> expectedPredictionsByCancerType = new HashMap<>();
expectedPredictionsByCancerType.put("Skin: Melanoma", expectedPredictionMelanoma);
expectedPredictionsByCancerType.put("Skin: Other", expectedPredictionSkinOther);
expectedPredictionsByCancerType.put("Prostate", expectedPredictionProstate);
expectedPredictionsByCancerType.put(expectedPredictionMelanoma.cancerType(), expectedPredictionMelanoma);
expectedPredictionsByCancerType.put(expectedPredictionSkinOther.cancerType(), expectedPredictionSkinOther);
expectedPredictionsByCancerType.put(expectedPredictionProstate.cancerType(), expectedPredictionProstate);
expectedPredictionsByCancerType.put(expectedPredictionCartilaginousNeoplasm.cancerType(), expectedPredictionCartilaginousNeoplasm);

assertCuppaPredictions(CUPPA_VIS_DATA_WITHOUT_RNA_TSV, expectedPredictionsByCancerType);
assertCuppaPredictions(CUPPA_VIS_DATA_WITHOUT_RNA_TSV, 40, expectedPredictionsByCancerType);
}

@Test
Expand All @@ -117,12 +126,13 @@ public void canGetCorrectSvFeatureValueFromFileWithoutRna() throws Exception
}

private static void assertCuppaPredictions(@NotNull String inputFileName,
int expectedPredictionSize,
@NotNull Map<String, CuppaPrediction> expectedPredictionsByCancerType) throws Exception
{
CuppaData cuppaData = CuppaDataFactory.create(inputFileName);
List<CuppaPrediction> predictionEntries = cuppaData.predictions();

assertEquals(40, predictionEntries.size());
assertEquals(expectedPredictionSize, predictionEntries.size());
assertEquals("Skin: Melanoma", cuppaData.bestPrediction().cancerType());

Map<String, CuppaPrediction> actualPredictionsByCancerType = new HashMap<>();
Expand All @@ -135,13 +145,19 @@ private static void assertCuppaPredictions(@NotNull String inputFileName,
{
CuppaPrediction expectedPrediction = expectedPredictionsByCancerType.get(cancerType);
CuppaPrediction actualPrediction = actualPredictionsByCancerType.get(cancerType);

assertEquals(expectedPrediction.likelihood(), actualPrediction.likelihood(), EPSILON);
assertEqualsNullableDouble(expectedPrediction.genomicPositionClassifier(), actualPrediction.genomicPositionClassifier());
assertEqualsNullableDouble(expectedPrediction.snvPairwiseClassifier(), actualPrediction.snvPairwiseClassifier());
assertEqualsNullableDouble(expectedPrediction.featureClassifier(), actualPrediction.featureClassifier());
assertEqualsNullableDouble(expectedPrediction.expressionPairwiseClassifier(), actualPrediction.expressionPairwiseClassifier());
assertEqualsNullableDouble(expectedPrediction.altSjCohortClassifier(), actualPrediction.altSjCohortClassifier());
if(expectedPrediction == null)
{
assertNull(actualPrediction);
}
else
{
assertEquals(expectedPrediction.likelihood(), actualPrediction.likelihood(), EPSILON);
assertEqualsNullableDouble(expectedPrediction.genomicPositionClassifier(), actualPrediction.genomicPositionClassifier());
assertEqualsNullableDouble(expectedPrediction.snvPairwiseClassifier(), actualPrediction.snvPairwiseClassifier());
assertEqualsNullableDouble(expectedPrediction.featureClassifier(), actualPrediction.featureClassifier());
assertEqualsNullableDouble(expectedPrediction.expressionPairwiseClassifier(), actualPrediction.expressionPairwiseClassifier());
assertEqualsNullableDouble(expectedPrediction.altSjCohortClassifier(), actualPrediction.altSjCohortClassifier());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<lilac.version>1.7</lilac.version>
<linx.version>2.0</linx.version>
<neo.version>1.2</neo.version>
<orange.version>3.5.1</orange.version>
<orange.version>3.6.0</orange.version>
<orange-datamodel.version>2.6.0</orange-datamodel.version>
<paddle.version>1.1</paddle.version>
<patient-db.version>6.0</patient-db.version>
Expand Down

0 comments on commit 65fbdf1

Please sign in to comment.