Do new filtering before matching

This commit is contained in:
2022-02-18 17:28:24 -06:00
parent bf32a55e4b
commit b9ee31b64c
2 changed files with 39 additions and 5 deletions

View File

@@ -194,6 +194,16 @@ public class Simulator {
filterByOccupancyThreshold(graph, lowThreshold, highThreshold); filterByOccupancyThreshold(graph, lowThreshold, highThreshold);
if(verbose){System.out.println("Over- and under-weight edges set to 0.0");} if(verbose){System.out.println("Over- and under-weight edges set to 0.0");}
//Filter by overlap size
if(verbose){System.out.println("Eliminating edges with weights much less than occupancy values");}
filterByOverlapSize(graph, alphaWellCounts, betaWellCounts);
if(verbose){System.out.println("Edges with weights much less than occupancy values set to 0.0");}
//Filter by relative occupancy
if(verbose){System.out.println("Eliminating edges between vertices of massively different occupancy");}
filterByRelativeOccupancy(graph, alphaWellCounts, betaWellCounts);
if(verbose){System.out.println("Edges between vertices of massively different occupancy set to 0.0");}
/** /**
* This is where the maximum weighted matching is found * This is where the maximum weighted matching is found
@@ -666,6 +676,35 @@ public class Simulator {
} }
} }
//Remove edges for pairs with large occupancy discrepancy
private static void filterByRelativeOccupancy(SimpleWeightedGraph<Integer, DefaultWeightedEdge> graph,
Map<Integer, Integer> alphaWellCounts,
Map<Integer, Integer> betaWellCounts) {
for (DefaultWeightedEdge e : graph.edgeSet()) {
Integer alphaOcc = alphaWellCounts.get(graph.getEdgeSource(e));
Integer betaOcc = betaWellCounts.get(graph.getEdgeTarget(e));
//Adjust this to something cleverer later
if (Math.abs(alphaOcc - betaOcc) >= 20) {
graph.setEdgeWeight(e, 0.0);
}
}
}
//Remove edges for pairs where overlap size is significantly lower than the well occupancy
private static void filterByOverlapSize(SimpleWeightedGraph<Integer, DefaultWeightedEdge> graph,
Map<Integer, Integer> alphaWellCounts,
Map<Integer, Integer> betaWellCounts) {
for (DefaultWeightedEdge e : graph.edgeSet()) {
Integer alphaOcc = alphaWellCounts.get(graph.getEdgeSource(e));
Integer betaOcc = betaWellCounts.get(graph.getEdgeTarget(e));
//Adjust this to something cleverer later
Integer min = alphaOcc > betaOcc ? betaOcc : alphaOcc;
if (min - graph.getEdgeWeight(e) >= 15) {
graph.setEdgeWeight(e, 0.0);
}
}
}
private static Map<Integer, Integer> makePeptideToPeptideMap(List<Integer[]> cells, int keyPeptideIndex, private static Map<Integer, Integer> makePeptideToPeptideMap(List<Integer[]> cells, int keyPeptideIndex,
int valuePeptideIndex){ int valuePeptideIndex){
Map<Integer, Integer> keyPeptideToValuePeptideMap = new HashMap<>(); Map<Integer, Integer> keyPeptideToValuePeptideMap = new HashMap<>();
@@ -693,9 +732,4 @@ public class Simulator {
return inverse; return inverse;
} }
private static int bigDecimalComparator(BigDecimal bd, Integer i) {
return bd.compareTo(BigDecimal.valueOf(i));
}
} }