diff --git a/out/artifacts/TCellSim_jar/TCellSim.jar b/out/artifacts/TCellSim_jar/TCellSim.jar index e6c75de..705ce0a 100644 Binary files a/out/artifacts/TCellSim_jar/TCellSim.jar and b/out/artifacts/TCellSim_jar/TCellSim.jar differ diff --git a/src/main/java/Simulator.java b/src/main/java/Simulator.java index 0471e1b..c3b83c8 100644 --- a/src/main/java/Simulator.java +++ b/src/main/java/Simulator.java @@ -194,6 +194,16 @@ public class Simulator { filterByOccupancyThreshold(graph, lowThreshold, highThreshold); 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 @@ -666,6 +676,35 @@ public class Simulator { } } + //Remove edges for pairs with large occupancy discrepancy + private static void filterByRelativeOccupancy(SimpleWeightedGraph graph, + Map alphaWellCounts, + Map 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 graph, + Map alphaWellCounts, + Map 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 makePeptideToPeptideMap(List cells, int keyPeptideIndex, int valuePeptideIndex){ Map keyPeptideToValuePeptideMap = new HashMap<>(); @@ -693,9 +732,4 @@ public class Simulator { return inverse; } - private static int bigDecimalComparator(BigDecimal bd, Integer i) { - return bd.compareTo(BigDecimal.valueOf(i)); - } - - }