implement Zipf distribution

This commit is contained in:
eugenefischer
2025-04-09 14:32:02 -05:00
parent 161a52aa89
commit a43ee469ea
8 changed files with 169 additions and 54 deletions

View File

@@ -89,14 +89,12 @@ public class InteractiveInterface {
private static void makePlate() {
String cellFile = null;
String filename = null;
Double stdDev = 0.0;
Double parameter = 0.0;
Integer numWells = 0;
Integer numSections;
Integer[] populations = {1};
Double dropOutRate = 0.0;
boolean poisson = false;
boolean exponential = false;
double lambda = 1.5;
;
try {
System.out.println("\nSimulated sample plates consist of:");
System.out.println("* a number of wells");
@@ -114,33 +112,46 @@ public class InteractiveInterface {
System.out.println("1) Poisson");
System.out.println("2) Gaussian");
System.out.println("3) Exponential");
// System.out.println("(Note: approximate distribution in original paper is exponential, lambda = 0.6)");
// System.out.println("(lambda value approximated from slope of log-log graph in figure 4c)");
System.out.println("4) Zipf");
System.out.println("(Note: wider distributions are more memory intensive to match)");
System.out.print("Enter selection value: ");
input = sc.nextInt();
switch (input) {
case 1 -> poisson = true;
case 1 -> {
BiGpairSEQ.setDistributionType(DistributionType.POISSON);
}
case 2 -> {
BiGpairSEQ.setDistributionType(DistributionType.GAUSSIAN);
System.out.println("How many distinct T-cells within one standard deviation of peak frequency?");
System.out.println("(Note: wider distributions are more memory intensive to match)");
stdDev = sc.nextDouble();
if (stdDev <= 0.0) {
parameter = sc.nextDouble();
if (parameter <= 0.0) {
throw new InputMismatchException("Value must be positive.");
}
}
case 3 -> {
exponential = true;
BiGpairSEQ.setDistributionType(DistributionType.EXPONENTIAL);
System.out.print("Please enter lambda value for exponential distribution: ");
lambda = sc.nextDouble();
if (lambda <= 0.0) {
lambda = 0.6;
System.out.println("Value must be positive. Defaulting to 0.6.");
parameter = sc.nextDouble();
if (parameter <= 0.0) {
parameter = 1.4;
System.out.println("Value must be positive. Defaulting to 1.4.");
}
}
case 4 -> {
BiGpairSEQ.setDistributionType(DistributionType.ZIPF);
System.out.print("Please enter exponent value for Zipf distribution: ");
parameter = sc.nextDouble();
if (parameter <= 0.0) {
parameter = 1.4;
System.out.println("Value must be positive. Defaulting to 1.4.");
}
}
default -> {
System.out.println("Invalid input. Defaulting to exponential.");
exponential = true;
parameter = 1.4;
BiGpairSEQ.setDistributionType(DistributionType.EXPONENTIAL);
}
}
System.out.print("\nNumber of wells on plate: ");
@@ -226,16 +237,17 @@ public class InteractiveInterface {
assert filename != null;
Plate samplePlate;
PlateFileWriter writer;
if(exponential){
samplePlate = new Plate(cells, cellFile, numWells, populations, dropOutRate, lambda, true);
writer = new PlateFileWriter(filename, samplePlate);
}
else {
if (poisson) {
stdDev = Math.sqrt(cells.getCellCount()); //gaussian with square root of elements approximates poisson
DistributionType type = BiGpairSEQ.getDistributionType();
switch(type) {
case POISSON -> {
parameter = Math.sqrt(cells.getCellCount()); //gaussian with square root of elements approximates poisson
samplePlate = new Plate(cells, cellFile, numWells, populations, dropOutRate, parameter);
writer = new PlateFileWriter(filename, samplePlate);
}
default -> {
samplePlate = new Plate(cells, cellFile, numWells, populations, dropOutRate, parameter);
writer = new PlateFileWriter(filename, samplePlate);
}
samplePlate = new Plate(cells, cellFile, numWells, populations, dropOutRate, stdDev, false);
writer = new PlateFileWriter(filename, samplePlate);
}
System.out.println("Writing Sample Plate to file");
writer.writePlateFile();
@@ -605,12 +617,13 @@ public class InteractiveInterface {
case 3 -> {
BiGpairSEQ.setAuctionAlgorithm();
System.out.println("MWM algorithm set to auction");
backToOptions = true;
}
case 4 -> {
System.out.println("Scaling integer weight MWM algorithm not yet fully implemented. Sorry.");
// BiGpairSEQ.setIntegerWeightScalingAlgorithm();
// System.out.println("MWM algorithm set to integer weight scaling algorithm of Duan and Su");
backToOptions = true;
// backToOptions = true;
}
case 0 -> backToOptions = true;
default -> System.out.println("Invalid input");