Make calculation of p-values optional, defaulting to off
This commit is contained in:
@@ -16,6 +16,7 @@ public class BiGpairSEQ {
|
|||||||
private static HeapType priorityQueueHeapType = HeapType.FIBONACCI;
|
private static HeapType priorityQueueHeapType = HeapType.FIBONACCI;
|
||||||
private static boolean outputBinary = true;
|
private static boolean outputBinary = true;
|
||||||
private static boolean outputGraphML = false;
|
private static boolean outputGraphML = false;
|
||||||
|
private static boolean calculatePValue = false;
|
||||||
private static final String version = "version 4.1";
|
private static final String version = "version 4.1";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -173,5 +174,9 @@ public class BiGpairSEQ {
|
|||||||
|
|
||||||
public static boolean outputGraphML() {return outputGraphML;}
|
public static boolean outputGraphML() {return outputGraphML;}
|
||||||
public static void setOutputGraphML(boolean b) {outputGraphML = b;}
|
public static void setOutputGraphML(boolean b) {outputGraphML = b;}
|
||||||
|
|
||||||
|
public static boolean calculatePValue() {return calculatePValue; }
|
||||||
|
public static void setCalculatePValue(boolean b) {calculatePValue = b; }
|
||||||
|
|
||||||
public static String getVersion() { return version; }
|
public static String getVersion() { return version; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,9 +202,12 @@ public class CommandLineInterface {
|
|||||||
else {
|
else {
|
||||||
maxOccupancyDiff = Integer.MAX_VALUE;
|
maxOccupancyDiff = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
if (line.hasOption("pv")) {
|
||||||
|
BiGpairSEQ.setCalculatePValue(true);
|
||||||
|
}
|
||||||
GraphWithMapData graph = getGraph(graphFilename);
|
GraphWithMapData graph = getGraph(graphFilename);
|
||||||
MatchingResult result = Simulator.matchCDR3s(graph, graphFilename, minThreshold, maxThreshold,
|
MatchingResult result = Simulator.matchCDR3s(graph, graphFilename, minThreshold, maxThreshold,
|
||||||
maxOccupancyDiff, minOverlapPct, false);
|
maxOccupancyDiff, minOverlapPct, false, BiGpairSEQ.calculatePValue());
|
||||||
if(outputFilename != null){
|
if(outputFilename != null){
|
||||||
MatchingFileWriter writer = new MatchingFileWriter(outputFilename, result);
|
MatchingFileWriter writer = new MatchingFileWriter(outputFilename, result);
|
||||||
writer.writeResultsToFile();
|
writer.writeResultsToFile();
|
||||||
@@ -479,12 +482,17 @@ public class CommandLineInterface {
|
|||||||
.argName("filename")
|
.argName("filename")
|
||||||
.desc("(Optional) Name of output the output file. If not present, no file will be written.")
|
.desc("(Optional) Name of output the output file. If not present, no file will be written.")
|
||||||
.build();
|
.build();
|
||||||
|
Option pValue = Option.builder("pv") //can't call the method this time, because this one's optional
|
||||||
|
.longOpt("p-value")
|
||||||
|
.desc("(Optional) Calculate p-values for sequence pairs.")
|
||||||
|
.build();
|
||||||
matchCDR3options.addOption(graphFilename)
|
matchCDR3options.addOption(graphFilename)
|
||||||
.addOption(minOccupancyOverlap)
|
.addOption(minOccupancyOverlap)
|
||||||
.addOption(maxOccupancyOverlap)
|
.addOption(maxOccupancyOverlap)
|
||||||
.addOption(minOverlapPercent)
|
.addOption(minOverlapPercent)
|
||||||
.addOption(maxOccupancyDifference)
|
.addOption(maxOccupancyDifference)
|
||||||
.addOption(outputFile);
|
.addOption(outputFile)
|
||||||
|
.addOption(pValue);
|
||||||
|
|
||||||
//options for output to System.out
|
//options for output to System.out
|
||||||
Option printAlphaCount = Option.builder().longOpt("print-alphas")
|
Option printAlphaCount = Option.builder().longOpt("print-alphas")
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ public class InteractiveInterface {
|
|||||||
}
|
}
|
||||||
//simulate matching
|
//simulate matching
|
||||||
MatchingResult results = Simulator.matchCDR3s(data, graphFilename, lowThreshold, highThreshold, maxOccupancyDiff,
|
MatchingResult results = Simulator.matchCDR3s(data, graphFilename, lowThreshold, highThreshold, maxOccupancyDiff,
|
||||||
minOverlapPercent, true);
|
minOverlapPercent, true, BiGpairSEQ.calculatePValue());
|
||||||
//write results to file
|
//write results to file
|
||||||
assert filename != null;
|
assert filename != null;
|
||||||
MatchingFileWriter writer = new MatchingFileWriter(filename, results);
|
MatchingFileWriter writer = new MatchingFileWriter(filename, results);
|
||||||
@@ -544,7 +544,8 @@ public class InteractiveInterface {
|
|||||||
System.out.println("3) Turn " + getOnOff(!BiGpairSEQ.cacheGraph()) + " graph/data file caching");
|
System.out.println("3) Turn " + getOnOff(!BiGpairSEQ.cacheGraph()) + " graph/data file caching");
|
||||||
System.out.println("4) Turn " + getOnOff(!BiGpairSEQ.outputBinary()) + " serialized binary graph output");
|
System.out.println("4) Turn " + getOnOff(!BiGpairSEQ.outputBinary()) + " serialized binary graph output");
|
||||||
System.out.println("5) Turn " + getOnOff(!BiGpairSEQ.outputGraphML()) + " GraphML graph output (for data portability to other programs)");
|
System.out.println("5) Turn " + getOnOff(!BiGpairSEQ.outputGraphML()) + " GraphML graph output (for data portability to other programs)");
|
||||||
System.out.println("6) Maximum weight matching algorithm options");
|
System.out.println("6) Turn " + getOnOff(!BiGpairSEQ.calculatePValue()) + " calculation of p-values");
|
||||||
|
System.out.println("7) Maximum weight matching algorithm options");
|
||||||
System.out.println("0) Return to main menu");
|
System.out.println("0) Return to main menu");
|
||||||
try {
|
try {
|
||||||
input = sc.nextInt();
|
input = sc.nextInt();
|
||||||
@@ -554,7 +555,8 @@ public class InteractiveInterface {
|
|||||||
case 3 -> BiGpairSEQ.setCacheGraph(!BiGpairSEQ.cacheGraph());
|
case 3 -> BiGpairSEQ.setCacheGraph(!BiGpairSEQ.cacheGraph());
|
||||||
case 4 -> BiGpairSEQ.setOutputBinary(!BiGpairSEQ.outputBinary());
|
case 4 -> BiGpairSEQ.setOutputBinary(!BiGpairSEQ.outputBinary());
|
||||||
case 5 -> BiGpairSEQ.setOutputGraphML(!BiGpairSEQ.outputGraphML());
|
case 5 -> BiGpairSEQ.setOutputGraphML(!BiGpairSEQ.outputGraphML());
|
||||||
case 6 -> algorithmOptions();
|
case 6 -> BiGpairSEQ.setCalculatePValue(!BiGpairSEQ.calculatePValue());
|
||||||
|
case 7 -> algorithmOptions();
|
||||||
case 0 -> backToMain = true;
|
case 0 -> backToMain = true;
|
||||||
default -> System.out.println("Invalid input");
|
default -> System.out.println("Invalid input");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
//match CDR3s.
|
//match CDR3s.
|
||||||
public static MatchingResult matchCDR3s(GraphWithMapData data, String dataFilename, Integer lowThreshold,
|
public static MatchingResult matchCDR3s(GraphWithMapData data, String dataFilename, Integer lowThreshold,
|
||||||
Integer highThreshold, Integer maxOccupancyDifference,
|
Integer highThreshold, Integer maxOccupancyDifference,
|
||||||
Integer minOverlapPercent, boolean verbose) {
|
Integer minOverlapPercent, boolean verbose, boolean calculatePValue) {
|
||||||
Instant start = Instant.now();
|
Instant start = Instant.now();
|
||||||
SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph = data.getGraph();
|
SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph = data.getGraph();
|
||||||
Map<Vertex[], Integer> removedEdges = new HashMap<>();
|
Map<Vertex[], Integer> removedEdges = new HashMap<>();
|
||||||
@@ -228,7 +228,7 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
header.add("Beta well count");
|
header.add("Beta well count");
|
||||||
header.add("Overlap well count");
|
header.add("Overlap well count");
|
||||||
header.add("Matched correctly?");
|
header.add("Matched correctly?");
|
||||||
header.add("P-value");
|
if(calculatePValue) { header.add("P-value"); }
|
||||||
|
|
||||||
//Results for csv file
|
//Results for csv file
|
||||||
List<List<String>> allResults = new ArrayList<>();
|
List<List<String>> allResults = new ArrayList<>();
|
||||||
@@ -265,10 +265,12 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
//overlap count
|
//overlap count
|
||||||
result.add(Double.toString(graph.getEdgeWeight(e)));
|
result.add(Double.toString(graph.getEdgeWeight(e)));
|
||||||
result.add(Boolean.toString(check));
|
result.add(Boolean.toString(check));
|
||||||
double pValue = Equations.pValue(numWells, source.getOccupancy(),
|
if (calculatePValue) {
|
||||||
|
double pValue = Equations.pValue(numWells, source.getOccupancy(),
|
||||||
target.getOccupancy(), graph.getEdgeWeight(e));
|
target.getOccupancy(), graph.getEdgeWeight(e));
|
||||||
BigDecimal pValueTrunc = new BigDecimal(pValue, mc);
|
BigDecimal pValueTrunc = new BigDecimal(pValue, mc);
|
||||||
result.add(pValueTrunc.toString());
|
result.add(pValueTrunc.toString());
|
||||||
|
}
|
||||||
allResults.add(result);
|
allResults.add(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user