Relocate overlap threshold filters
This commit is contained in:
Binary file not shown.
@@ -14,8 +14,6 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
private Integer[] wellConcentrations;
|
||||
private Integer alphaCount;
|
||||
private Integer betaCount;
|
||||
private Integer lowThreshold;
|
||||
private Integer highThreshold;
|
||||
private final Map<Integer, Integer> distCellsMapAlphaKey;
|
||||
private final Map<Integer, Integer> plateVtoAMap;
|
||||
private final Map<Integer, Integer> plateVtoBMap;
|
||||
@@ -26,7 +24,7 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
private final Duration time;
|
||||
|
||||
public GraphWithMapData(SimpleWeightedGraph graph, Integer numWells, Integer[] wellConcentrations,
|
||||
Integer alphaCount, Integer betaCount, Integer lowThreshold, Integer highThreshold,
|
||||
Integer alphaCount, Integer betaCount,
|
||||
Map<Integer, Integer> distCellsMapAlphaKey, Map<Integer, Integer> plateVtoAMap,
|
||||
Map<Integer,Integer> plateVtoBMap, Map<Integer, Integer> plateAtoVMap,
|
||||
Map<Integer, Integer> plateBtoVMap, Map<Integer, Integer> alphaWellCounts,
|
||||
@@ -36,8 +34,6 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
this.wellConcentrations = wellConcentrations;
|
||||
this.alphaCount = alphaCount;
|
||||
this.betaCount = betaCount;
|
||||
this.lowThreshold = lowThreshold;
|
||||
this.highThreshold = highThreshold;
|
||||
this.distCellsMapAlphaKey = distCellsMapAlphaKey;
|
||||
this.plateVtoAMap = plateVtoAMap;
|
||||
this.plateVtoBMap = plateVtoBMap;
|
||||
@@ -68,14 +64,6 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
return betaCount;
|
||||
}
|
||||
|
||||
public Integer getLowThreshold() {
|
||||
return lowThreshold;
|
||||
}
|
||||
|
||||
public Integer getHighThreshold() {
|
||||
return highThreshold;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getDistCellsMapAlphaKey() {
|
||||
return distCellsMapAlphaKey;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ public class Simulator {
|
||||
}
|
||||
|
||||
//Make the graph needed for matching CDR3s
|
||||
public static GraphWithMapData makeGraph(List<Integer[]> distinctCells, Plate samplePlate, Integer lowThreshold,
|
||||
Integer highThreshold, boolean verbose) {
|
||||
public static GraphWithMapData makeGraph(List<Integer[]> distinctCells, Plate samplePlate, boolean verbose) {
|
||||
Instant start = Instant.now();
|
||||
int[] alphaIndex = {cdr3AlphaIndex};
|
||||
int[] betaIndex = {cdr3BetaIndex};
|
||||
@@ -70,9 +69,9 @@ public class Simulator {
|
||||
//Remove saturating-occupancy sequences because they have no signal value.
|
||||
//Remove sequences with total occupancy below minimum pair overlap threshold
|
||||
if(verbose){System.out.println("Removing sequences present in all wells.");}
|
||||
if(verbose){System.out.println("Removing sequences with occupancy below the minimum overlap threshold");}
|
||||
filterByOccupancyThreshold(allAlphas, lowThreshold, numWells - 1);
|
||||
filterByOccupancyThreshold(allBetas, lowThreshold, numWells - 1);
|
||||
//if(verbose){System.out.println("Removing sequences with occupancy below the minimum overlap threshold");}
|
||||
filterByOccupancyThreshold(allAlphas, 1, numWells - 1);
|
||||
filterByOccupancyThreshold(allBetas, 1, numWells - 1);
|
||||
if(verbose){System.out.println("Sequences removed");}
|
||||
int pairableAlphaCount = allAlphas.size();
|
||||
if(verbose){System.out.println("Remaining alphas count: " + pairableAlphaCount);}
|
||||
@@ -130,25 +129,20 @@ public class Simulator {
|
||||
graphGenerator.generateGraph(graph);
|
||||
if(verbose){System.out.println("Graph created");}
|
||||
|
||||
//remove weights outside given overlap thresholds
|
||||
if(verbose){System.out.println("Eliminating edges with weights outside overlap threshold values");}
|
||||
filterByOccupancyThreshold(graph, lowThreshold, highThreshold);
|
||||
if(verbose){System.out.println("Over- and under-weight edges set to 0.0");}
|
||||
Instant stop = Instant.now();
|
||||
Duration time = Duration.between(start, stop);
|
||||
//return GraphWithMapData object
|
||||
return new GraphWithMapData(graph, numWells, samplePlate.getConcentrations(), alphaCount, betaCount, lowThreshold, highThreshold,
|
||||
return new GraphWithMapData(graph, numWells, samplePlate.getConcentrations(), alphaCount, betaCount,
|
||||
distCellsMapAlphaKey, plateVtoAMap, plateVtoBMap, plateAtoVMap,
|
||||
plateBtoVMap, alphaWellCounts, betaWellCounts, time);
|
||||
}
|
||||
|
||||
//match CDR3s.
|
||||
public static MatchingResult matchCDR3s(GraphWithMapData data, Integer maxOccupancyDifference,
|
||||
Integer minOverlapPercent, boolean verbose) {
|
||||
public static MatchingResult matchCDR3s(GraphWithMapData data, Integer lowThreshold, Integer highThreshold,
|
||||
Integer maxOccupancyDifference, Integer minOverlapPercent,
|
||||
boolean verbose) {
|
||||
Instant start = Instant.now();
|
||||
int numWells = data.getNumWells();
|
||||
Integer highThreshold = data.getHighThreshold();
|
||||
Integer lowThreshold = data.getLowThreshold();
|
||||
Integer alphaCount = data.getAlphaCount();
|
||||
Integer betaCount = data.getBetaCount();
|
||||
Map<Integer, Integer> distCellsMapAlphaKey = data.getDistCellsMapAlphaKey();
|
||||
@@ -158,6 +152,11 @@ public class Simulator {
|
||||
Map<Integer, Integer> betaWellCounts = data.getBetaWellCounts();
|
||||
SimpleWeightedGraph<Integer, DefaultWeightedEdge> graph = data.getGraph();
|
||||
|
||||
//remove weights outside given overlap thresholds
|
||||
if(verbose){System.out.println("Eliminating edges with weights outside overlap threshold values");}
|
||||
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 less than " + minOverlapPercent.toString() +
|
||||
" percent of vertex occupancy value.");}
|
||||
|
||||
@@ -303,10 +303,10 @@ public class UserInterface {
|
||||
System.out.println("\nThe cells will be written to a CSV file.");
|
||||
System.out.print("Please enter a file name: ");
|
||||
filename = sc.next();
|
||||
System.out.println("CDR3 sequences are more diverse than CDR1 sequences.");
|
||||
System.out.println("\nCDR3 sequences are more diverse than CDR1 sequences.");
|
||||
System.out.println("Please enter the factor by which distinct CDR3s outnumber CDR1s: ");
|
||||
cdr1Freq = sc.nextInt();
|
||||
System.out.print("Please enter the number of T-cells to generate: ");
|
||||
System.out.print("\nPlease enter the number of T-cells to generate: ");
|
||||
numCells = sc.nextInt();
|
||||
if(numCells <= 0){
|
||||
throw new InputMismatchException("Number of cells must be a positive integer.");
|
||||
@@ -380,7 +380,7 @@ public class UserInterface {
|
||||
System.out.println("\nThe sample plate will be written to a CSV file");
|
||||
System.out.print("Please enter a name for the output file: ");
|
||||
filename = sc.next();
|
||||
System.out.println("Select T-cell frequency distribution function");
|
||||
System.out.println("\nSelect T-cell frequency distribution function");
|
||||
System.out.println("1) Poisson");
|
||||
System.out.println("2) Gaussian");
|
||||
System.out.println("3) Exponential");
|
||||
@@ -413,12 +413,12 @@ public class UserInterface {
|
||||
System.out.println("Invalid input. Defaulting to exponential.");
|
||||
exponential = true;
|
||||
}
|
||||
System.out.print("Number of wells on plate: ");
|
||||
System.out.print("\nNumber of wells on plate: ");
|
||||
numWells = sc.nextInt();
|
||||
if(numWells < 1){
|
||||
throw new InputMismatchException("No wells on plate");
|
||||
}
|
||||
System.out.println("The plate can be evenly sectioned to allow multiple concentrations of T-cells/well");
|
||||
System.out.println("\nThe plate can be evenly sectioned to allow multiple concentrations of T-cells/well");
|
||||
System.out.println("How many sections would you like to make (minimum 1)?");
|
||||
numSections = sc.nextInt();
|
||||
if(numSections < 1) {
|
||||
@@ -435,7 +435,7 @@ public class UserInterface {
|
||||
i++;
|
||||
numSections--;
|
||||
}
|
||||
System.out.println("Errors in amplification can induce a well dropout rate for sequences");
|
||||
System.out.println("\nErrors in amplification can induce a well dropout rate for sequences");
|
||||
System.out.print("Enter well dropout rate (0.0 to 1.0): ");
|
||||
dropOutRate = sc.nextDouble();
|
||||
if(dropOutRate < 0.0 || dropOutRate > 1.0) {
|
||||
@@ -468,26 +468,18 @@ public class UserInterface {
|
||||
String filename = null;
|
||||
String cellFile = null;
|
||||
String plateFile = null;
|
||||
Integer lowThreshold = 0;
|
||||
Integer highThreshold = Integer.MAX_VALUE;
|
||||
|
||||
try {
|
||||
String str = "\nGenerating bipartite weighted graph encoding occupancy overlap data ";
|
||||
str = str.concat("\nrequires a cell sample file and a sample plate file.");
|
||||
System.out.println(str);
|
||||
System.out.print("Please enter name of an existing cell sample file: ");
|
||||
System.out.print("\nPlease enter name of an existing cell sample file: ");
|
||||
cellFile = sc.next();
|
||||
System.out.print("Please enter name of an existing sample plate file: ");
|
||||
System.out.print("\nPlease enter name of an existing sample plate file: ");
|
||||
plateFile = sc.next();
|
||||
System.out.println("The graph and occupancy data will be written to a serialized binary file.");
|
||||
System.out.println("\nThe graph and occupancy data will be written to a serialized binary file.");
|
||||
System.out.print("Please enter a name for the output file: ");
|
||||
filename = sc.next();
|
||||
System.out.println("What is the minimum number of CDR3 alpha/beta overlap wells to include in graph?");
|
||||
lowThreshold = sc.nextInt();
|
||||
if(lowThreshold < 1){
|
||||
throw new InputMismatchException("Minimum value for low threshold set to 1");
|
||||
}
|
||||
System.out.println("What is the maximum number of CDR3 alpha/beta overlap wells to include in graph?");
|
||||
highThreshold = sc.nextInt();
|
||||
|
||||
} catch (InputMismatchException ex) {
|
||||
System.out.println(ex);
|
||||
sc.next();
|
||||
@@ -504,11 +496,9 @@ public class UserInterface {
|
||||
System.out.println("Returning to main menu.");
|
||||
}
|
||||
else{
|
||||
if(highThreshold >= plate.getSize()){
|
||||
highThreshold = plate.getSize() - 1;
|
||||
}
|
||||
|
||||
List<Integer[]> cells = cellReader.getCells();
|
||||
GraphWithMapData data = Simulator.makeGraph(cells, plate, lowThreshold, highThreshold, true);
|
||||
GraphWithMapData data = Simulator.makeGraph(cells, plate, true);
|
||||
GraphDataObjectWriter dataWriter = new GraphDataObjectWriter(filename, data);
|
||||
System.out.println("Writing graph and occupancy data to file. This may take some time.");
|
||||
System.out.println("File I/O time is not included in results.");
|
||||
@@ -520,6 +510,8 @@ public class UserInterface {
|
||||
private static void matchCDR3s() throws IOException {
|
||||
String filename = null;
|
||||
String dataFile = null;
|
||||
Integer lowThreshold = 0;
|
||||
Integer highThreshold = Integer.MAX_VALUE;
|
||||
Integer maxOccupancyDiff = Integer.MAX_VALUE;
|
||||
Integer minOverlapPercent = 0;
|
||||
try {
|
||||
@@ -529,13 +521,18 @@ public class UserInterface {
|
||||
System.out.println("The matching results will be written to a file.");
|
||||
System.out.print("Please enter a name for the output file: ");
|
||||
filename = sc.next();
|
||||
System.out.println("Bipartite graph can be pre-filtered for relative alpha/beta occupancy.");
|
||||
System.out.println("(To skip pre-filtering: enter number of wells on the plate used to make graph)");
|
||||
System.out.println("What is the maximum difference in alpha/beta occupancy to attempt matching?");
|
||||
filename = sc.next();
|
||||
System.out.println("\nWhat is the minimum number of CDR3 alpha/beta overlap wells to attempt matching?");
|
||||
lowThreshold = sc.nextInt();
|
||||
if(lowThreshold < 1){
|
||||
throw new InputMismatchException("Minimum value for low threshold set to 1");
|
||||
}
|
||||
System.out.println("\nWhat is the maximum number of CDR3 alpha/beta overlap wells to attempt matching?");
|
||||
highThreshold = sc.nextInt();
|
||||
System.out.println("\nWhat is the maximum difference in alpha/beta occupancy to attempt matching?");
|
||||
maxOccupancyDiff = sc.nextInt();
|
||||
System.out.println("Bipartite graph can be pre-filtered for pair well overlap percentage");
|
||||
System.out.println("(To skip pre-filtering: enter 0)");
|
||||
System.out.println("What is the minimum overlap percentage to attempt matching? (0 - 100)");
|
||||
System.out.println("\nWell overlap percentage = pair overlap / sequence occupancy");
|
||||
System.out.println("What is the minimum well overlap percentage to attempt matching? (0 to 100)");
|
||||
minOverlapPercent = sc.nextInt();
|
||||
if (minOverlapPercent < 0 || minOverlapPercent > 100) {
|
||||
throw new InputMismatchException("Value outside range. Minimum percent set to 0");
|
||||
@@ -552,7 +549,8 @@ public class UserInterface {
|
||||
//set source file name
|
||||
data.setSourceFilename(dataFile);
|
||||
//simulate matching
|
||||
MatchingResult results = Simulator.matchCDR3s(data, maxOccupancyDiff, minOverlapPercent, true);
|
||||
MatchingResult results = Simulator.matchCDR3s(data, lowThreshold, highThreshold, maxOccupancyDiff,
|
||||
minOverlapPercent, true);
|
||||
//write results to file
|
||||
MatchingFileWriter writer = new MatchingFileWriter(filename, results);
|
||||
System.out.println("Writing results to file");
|
||||
|
||||
Reference in New Issue
Block a user