Make calculation of p-values optional, defaulting to off

This commit is contained in:
eugenefischer
2022-09-30 03:17:58 -05:00
parent 593dd6c60f
commit 457d643477
4 changed files with 27 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ public class BiGpairSEQ {
private static HeapType priorityQueueHeapType = HeapType.FIBONACCI;
private static boolean outputBinary = true;
private static boolean outputGraphML = false;
private static boolean calculatePValue = false;
private static final String version = "version 4.1";
public static void main(String[] args) {
@@ -173,5 +174,9 @@ public class BiGpairSEQ {
public static boolean outputGraphML() {return outputGraphML;}
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; }
}

View File

@@ -202,9 +202,12 @@ public class CommandLineInterface {
else {
maxOccupancyDiff = Integer.MAX_VALUE;
}
if (line.hasOption("pv")) {
BiGpairSEQ.setCalculatePValue(true);
}
GraphWithMapData graph = getGraph(graphFilename);
MatchingResult result = Simulator.matchCDR3s(graph, graphFilename, minThreshold, maxThreshold,
maxOccupancyDiff, minOverlapPct, false);
maxOccupancyDiff, minOverlapPct, false, BiGpairSEQ.calculatePValue());
if(outputFilename != null){
MatchingFileWriter writer = new MatchingFileWriter(outputFilename, result);
writer.writeResultsToFile();
@@ -479,12 +482,17 @@ public class CommandLineInterface {
.argName("filename")
.desc("(Optional) Name of output the output file. If not present, no file will be written.")
.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)
.addOption(minOccupancyOverlap)
.addOption(maxOccupancyOverlap)
.addOption(minOverlapPercent)
.addOption(maxOccupancyDifference)
.addOption(outputFile);
.addOption(outputFile)
.addOption(pValue);
//options for output to System.out
Option printAlphaCount = Option.builder().longOpt("print-alphas")

View File

@@ -422,7 +422,7 @@ public class InteractiveInterface {
}
//simulate matching
MatchingResult results = Simulator.matchCDR3s(data, graphFilename, lowThreshold, highThreshold, maxOccupancyDiff,
minOverlapPercent, true);
minOverlapPercent, true, BiGpairSEQ.calculatePValue());
//write results to file
assert filename != null;
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("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("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");
try {
input = sc.nextInt();
@@ -554,7 +555,8 @@ public class InteractiveInterface {
case 3 -> BiGpairSEQ.setCacheGraph(!BiGpairSEQ.cacheGraph());
case 4 -> BiGpairSEQ.setOutputBinary(!BiGpairSEQ.outputBinary());
case 5 -> BiGpairSEQ.setOutputGraphML(!BiGpairSEQ.outputGraphML());
case 6 -> algorithmOptions();
case 6 -> BiGpairSEQ.setCalculatePValue(!BiGpairSEQ.calculatePValue());
case 7 -> algorithmOptions();
case 0 -> backToMain = true;
default -> System.out.println("Invalid input");
}

View File

@@ -150,7 +150,7 @@ public class Simulator implements GraphModificationFunctions {
//match CDR3s.
public static MatchingResult matchCDR3s(GraphWithMapData data, String dataFilename, Integer lowThreshold,
Integer highThreshold, Integer maxOccupancyDifference,
Integer minOverlapPercent, boolean verbose) {
Integer minOverlapPercent, boolean verbose, boolean calculatePValue) {
Instant start = Instant.now();
SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph = data.getGraph();
Map<Vertex[], Integer> removedEdges = new HashMap<>();
@@ -228,7 +228,7 @@ public class Simulator implements GraphModificationFunctions {
header.add("Beta well count");
header.add("Overlap well count");
header.add("Matched correctly?");
header.add("P-value");
if(calculatePValue) { header.add("P-value"); }
//Results for csv file
List<List<String>> allResults = new ArrayList<>();
@@ -265,10 +265,12 @@ public class Simulator implements GraphModificationFunctions {
//overlap count
result.add(Double.toString(graph.getEdgeWeight(e)));
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));
BigDecimal pValueTrunc = new BigDecimal(pValue, mc);
result.add(pValueTrunc.toString());
BigDecimal pValueTrunc = new BigDecimal(pValue, mc);
result.add(pValueTrunc.toString());
}
allResults.add(result);
}