Skip to content

Commit

Permalink
Update size checkpoints in potts modules (#2)
Browse files Browse the repository at this point in the history
* Separate checkpoint into checkpoint and target

* Rename apoptosis module checkpoints to targets

* Add apoptosis module checkpoint

* Update proliferation module tests

* Update apoptosis module tests
  • Loading branch information
jessicasyu authored Oct 16, 2023
1 parent eb9f83b commit 4f1a30a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 41 deletions.
22 changes: 13 additions & 9 deletions src/arcade/potts/agent/module/PottsModuleApoptosisSimple.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
*/

public class PottsModuleApoptosisSimple extends PottsModuleApoptosis {
/** Ratio of critical volume for early apoptosis size checkpoint. */
static final double EARLY_SIZE_CHECKPOINT = 0.99;
/** Threshold for critical volume size checkpoint. */
static final double SIZE_CHECKPOINT = 0.95;

/** Ratio of critical volume for late apoptosis size checkpoint. */
static final double LATE_SIZE_CHECKPOINT = 0.25;
/** Target ratio of critical volume for early apoptosis size checkpoint. */
static final double EARLY_SIZE_TARGET = 0.99;

/** Target ratio of critical volume for late apoptosis size checkpoint. */
static final double LATE_SIZE_TARGET = 0.25;

/** Event rate for early apoptosis (steps/tick). */
final double rateEarly;
Expand Down Expand Up @@ -73,11 +76,11 @@ public PottsModuleApoptosisSimple(PottsCell cell) {
@Override
void stepEarly(MersenneTwisterFast random) {
// Decrease size of cell.
cell.updateTarget(waterLossRate, EARLY_SIZE_CHECKPOINT);
cell.updateTarget(waterLossRate, EARLY_SIZE_TARGET);

// Decrease size of nucleus (if cell has regions).
if (cell.hasRegions()) {
cell.updateTarget(Region.NUCLEUS, nucleusPyknosisRate, EARLY_SIZE_CHECKPOINT);
cell.updateTarget(Region.NUCLEUS, nucleusPyknosisRate, EARLY_SIZE_TARGET);
}

// Check for phase transition.
Expand All @@ -101,7 +104,9 @@ void stepEarly(MersenneTwisterFast random) {
@Override
void stepLate(MersenneTwisterFast random, Simulation sim) {
// Decrease size of cell.
cell.updateTarget(cytoBlebbingRate, LATE_SIZE_CHECKPOINT);
cell.updateTarget(cytoBlebbingRate, LATE_SIZE_TARGET);
boolean sizeCheck = cell.getVolume() <= SIZE_CHECKPOINT
* LATE_SIZE_TARGET * cell.getCriticalVolume();

// Decrease size of nucleus (if cell has regions).
if (cell.hasRegions()) {
Expand All @@ -111,8 +116,7 @@ void stepLate(MersenneTwisterFast random, Simulation sim) {
// Check for completion of late phase.
Poisson poisson = poissonFactory.createPoisson(rateLate, random);
currentSteps += poisson.nextInt();
if (cell.getVolume() <= LATE_SIZE_CHECKPOINT * cell.getCriticalVolume()
&& currentSteps >= stepsLate) {
if (currentSteps >= stepsLate && sizeCheck) {
removeCell(sim);
setPhase(Phase.APOPTOSED);
}
Expand Down
28 changes: 16 additions & 12 deletions src/arcade/potts/agent/module/PottsModuleProliferationSimple.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
*/

public class PottsModuleProliferationSimple extends PottsModuleProliferation {
/** Ratio of critical volume for size checkpoint. */
static final double SIZE_CHECKPOINT = 2 * 0.95;
/** Threshold for critical volume size checkpoint. */
static final double SIZE_CHECKPOINT = 0.95;

/** Target ratio of critical volume for division size checkpoint. */
static final double SIZE_TARGET = 2;

/** Event rate for G1 phase (steps/tick). */
final double rateG1;
Expand Down Expand Up @@ -98,12 +101,12 @@ void stepG1(MersenneTwisterFast random) {
}

// Increase size of cell.
cell.updateTarget(cellGrowthRate, 2);
cell.updateTarget(cellGrowthRate, SIZE_TARGET);

// Increase size of nucleus (if cell has regions).
if (cell.hasRegions()
&& cell.getVolume(Region.NUCLEUS) > cell.getCriticalVolume(Region.NUCLEUS)) {
cell.updateTarget(Region.NUCLEUS, nucleusGrowthRate, 2);
cell.updateTarget(Region.NUCLEUS, nucleusGrowthRate, SIZE_TARGET);
}

// Check for phase transition.
Expand All @@ -124,11 +127,11 @@ void stepG1(MersenneTwisterFast random) {
@Override
void stepS(MersenneTwisterFast random) {
// Increase size of cell.
cell.updateTarget(cellGrowthRate, 2);
cell.updateTarget(cellGrowthRate, SIZE_TARGET);

// Increase size of nucleus (if cell has regions).
if (cell.hasRegions()) {
cell.updateTarget(Region.NUCLEUS, nucleusGrowthRate, 2);
cell.updateTarget(Region.NUCLEUS, nucleusGrowthRate, SIZE_TARGET);
}

// Check for phase transition.
Expand Down Expand Up @@ -157,15 +160,16 @@ void stepG2(MersenneTwisterFast random) {
}

// Increase size of cell.
cell.updateTarget(cellGrowthRate, 2);
boolean sizeCheck = cell.getVolume() >= SIZE_CHECKPOINT * cell.getCriticalVolume();
cell.updateTarget(cellGrowthRate, SIZE_TARGET);
boolean sizeCheck = cell.getVolume() >= SIZE_CHECKPOINT
* SIZE_TARGET * cell.getCriticalVolume();

// Increase size of nucleus (if cell has regions).
boolean sizeRegionCheck = true;
if (cell.hasRegions()) {
cell.updateTarget(Region.NUCLEUS, nucleusGrowthRate, 2);
sizeRegionCheck = cell.getVolume(Region.NUCLEUS)
>= SIZE_CHECKPOINT * cell.getCriticalVolume(Region.NUCLEUS);
cell.updateTarget(Region.NUCLEUS, nucleusGrowthRate, SIZE_TARGET);
sizeRegionCheck = cell.getVolume(Region.NUCLEUS) >= SIZE_CHECKPOINT
* SIZE_TARGET * cell.getCriticalVolume(Region.NUCLEUS);
}

// Check for phase transition.
Expand All @@ -188,7 +192,7 @@ void stepG2(MersenneTwisterFast random) {
@Override
void stepM(MersenneTwisterFast random, Simulation sim) {
// Increase size of cell.
cell.updateTarget(cellGrowthRate, 2);
cell.updateTarget(cellGrowthRate, SIZE_TARGET);

// Update size of nucleus (if cell has regions).
if (cell.hasRegions()) {
Expand Down
23 changes: 16 additions & 7 deletions test/arcade/potts/agent/module/PottsModuleApoptosisSimpleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public static void setupMocks() {
parameters.put("apoptosis/RATE_LATE", randomDoubleBetween(1, 10));
parameters.put("apoptosis/STEPS_EARLY", randomIntBetween(1, 100));
parameters.put("apoptosis/STEPS_LATE", randomIntBetween(1, 100));
parameters.put("apoptosis/WATER_LOSS_RATE", randomDoubleBetween(100, 500));
parameters.put("apoptosis/CYTOPLASMIC_BLEBBING_RATE", randomDoubleBetween(100, 500));
parameters.put("apoptosis/NUCLEUS_PYKNOSIS_RATE", randomDoubleBetween(0, 100));
parameters.put("apoptosis/NUCLEUS_FRAGMENTATION_RATE", randomDoubleBetween(0, 100));
}

@Test
Expand All @@ -67,6 +71,11 @@ public void constructor_setsParameters() {
assertEquals(parameters.getDouble("apoptosis/RATE_LATE"), module.rateLate, EPSILON);
assertEquals(parameters.getDouble("apoptosis/STEPS_EARLY"), module.stepsEarly, EPSILON);
assertEquals(parameters.getDouble("apoptosis/STEPS_LATE"), module.stepsLate, EPSILON);
assertEquals(parameters.getDouble("apoptosis/WATER_LOSS_RATE"), module.waterLossRate, EPSILON);
assertEquals(parameters.getDouble("apoptosis/CYTOPLASMIC_BLEBBING_RATE"), module.cytoBlebbingRate, EPSILON);
assertEquals(parameters.getDouble("apoptosis/NUCLEUS_PYKNOSIS_RATE"), module.nucleusPyknosisRate, EPSILON);
assertEquals(parameters.getDouble("apoptosis/NUCLEUS_FRAGMENTATION_RATE"),
module.nucleusFragmentationRate, EPSILON);
}

@Test
Expand Down Expand Up @@ -125,7 +134,7 @@ public void stepEarly_anyTransition_updatesCell() {
module.currentSteps = 0;
module.stepEarly(random);

verify(cell, times(2)).updateTarget(module.waterLossRate, EARLY_SIZE_CHECKPOINT);
verify(cell, times(2)).updateTarget(module.waterLossRate, EARLY_SIZE_TARGET);
}

@Test
Expand All @@ -144,7 +153,7 @@ public void stepEarly_anyTransitionWithRegion_updatesCell() {
module.currentSteps = 0;
module.stepEarly(random);

verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusPyknosisRate, EARLY_SIZE_CHECKPOINT);
verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusPyknosisRate, EARLY_SIZE_TARGET);
}

@Test
Expand All @@ -153,7 +162,7 @@ public void stepLate_withTransitionNotArrested_updatesPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * LATE_SIZE_CHECKPOINT) - 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * LATE_SIZE_TARGET) - 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleApoptosisSimple module = spy(new PottsModuleApoptosisSimple(cell));
Expand All @@ -179,7 +188,7 @@ public void stepLate_withoutTransitionNotArrested_maintainsPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * LATE_SIZE_CHECKPOINT) - 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * LATE_SIZE_TARGET) - 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleApoptosisSimple module = spy(new PottsModuleApoptosisSimple(cell));
Expand All @@ -206,7 +215,7 @@ public void stepLate_withTransitionArrested_maintainsPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * LATE_SIZE_CHECKPOINT) + 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * LATE_SIZE_TARGET) + 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleApoptosisSimple module = spy(new PottsModuleApoptosisSimple(cell));
Expand All @@ -232,7 +241,7 @@ public void stepLate_withoutTransitionArrested_maintainsPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * LATE_SIZE_CHECKPOINT) + 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * LATE_SIZE_TARGET) + 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleApoptosisSimple module = spy(new PottsModuleApoptosisSimple(cell));
Expand Down Expand Up @@ -269,7 +278,7 @@ public void stepLate_anyTransition_updatesCell() {
module.currentSteps = 0;
module.stepLate(random, simMock);

verify(cell, times(2)).updateTarget(module.cytoBlebbingRate, LATE_SIZE_CHECKPOINT);
verify(cell, times(2)).updateTarget(module.cytoBlebbingRate, LATE_SIZE_TARGET);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void stepG1_anyTransition_updatesCell() {
module.currentSteps = 0;
module.stepG1(random);

verify(cell, times(2)).updateTarget(module.cellGrowthRate, 2);
verify(cell, times(2)).updateTarget(module.cellGrowthRate, SIZE_TARGET);
}

@Test
Expand All @@ -205,7 +205,7 @@ public void stepG1_anyTransitionWithRegionOverThreshold_updatesCell() {
module.currentSteps = 0;
module.stepG1(random);

verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusGrowthRate, 2);
verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusGrowthRate, SIZE_TARGET);
}

@Test
Expand Down Expand Up @@ -288,7 +288,7 @@ public void stepS_anyTransition_updatesCell() {
module.currentSteps = 0;
module.stepS(random);

verify(cell, times(2)).updateTarget(module.cellGrowthRate, 2);
verify(cell, times(2)).updateTarget(module.cellGrowthRate, SIZE_TARGET);
}

@Test
Expand All @@ -307,7 +307,7 @@ public void stepS_anyTransitionWithRegion_updatesCell() {
module.currentSteps = 0;
module.stepS(random);

verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusGrowthRate, 2);
verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusGrowthRate, SIZE_TARGET);
}

@Test
Expand Down Expand Up @@ -357,7 +357,7 @@ public void stepG2_withTransitionNotArrested_updatesPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * SIZE_CHECKPOINT) + 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * SIZE_TARGET) + 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleProliferationSimple module = spy(new PottsModuleProliferationSimple(cell));
Expand All @@ -381,7 +381,7 @@ public void stepG2_withoutTransitionNotArrested_maintainsPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * SIZE_CHECKPOINT) + 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * SIZE_TARGET) + 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleProliferationSimple module = spy(new PottsModuleProliferationSimple(cell));
Expand All @@ -406,7 +406,7 @@ public void stepG2_withTransitionArrested_maintainsPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * SIZE_CHECKPOINT) - 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * SIZE_TARGET) - 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleProliferationSimple module = spy(new PottsModuleProliferationSimple(cell));
Expand All @@ -433,11 +433,11 @@ public void stepG2_withTransitionArrestedRegion_maintainsPhase() {
doReturn(true).when(cell).hasRegions();

double volume = randomDoubleBetween(0, 100);
doReturn((volume * SIZE_CHECKPOINT) + 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * SIZE_TARGET) + 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

double regionVolume = randomDoubleBetween(0, 100);
doReturn((regionVolume * SIZE_CHECKPOINT) - 1).when(cell).getVolume(Region.NUCLEUS);
doReturn((regionVolume * SIZE_CHECKPOINT * SIZE_TARGET) - 1).when(cell).getVolume(Region.NUCLEUS);
doReturn(regionVolume).when(cell).getCriticalVolume(Region.NUCLEUS);

PottsModuleProliferationSimple module = spy(new PottsModuleProliferationSimple(cell));
Expand All @@ -461,7 +461,7 @@ public void stepM_withoutTransitionArrested_maintainPhase() {
PottsCell cell = mock(PottsCell.class);
doReturn(parameters).when(cell).getParameters();
double volume = randomDoubleBetween(0, 100);
doReturn((volume * SIZE_CHECKPOINT) - 1).when(cell).getVolume();
doReturn((volume * SIZE_CHECKPOINT * SIZE_TARGET) - 1).when(cell).getVolume();
doReturn(volume).when(cell).getCriticalVolume();

PottsModuleProliferationSimple module = spy(new PottsModuleProliferationSimple(cell));
Expand Down Expand Up @@ -495,7 +495,7 @@ public void stepG2_anyTransition_updatesCell() {
module.currentSteps = 0;
module.stepG2(random);

verify(cell, times(2)).updateTarget(module.cellGrowthRate, 2);
verify(cell, times(2)).updateTarget(module.cellGrowthRate, SIZE_TARGET);
}

@Test
Expand All @@ -514,7 +514,7 @@ public void stepG2_anyTransitionWithRegion_updatesCell() {
module.currentSteps = 0;
module.stepG2(random);

verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusGrowthRate, 2);
verify(cell, times(2)).updateTarget(Region.NUCLEUS, module.nucleusGrowthRate, SIZE_TARGET);
}

@Test
Expand Down Expand Up @@ -578,7 +578,7 @@ public void stepM_anyTransition_updatesCell() {
module.currentSteps = 0;
module.stepM(random, simMock);

verify(cell, times(2)).updateTarget(module.cellGrowthRate, 2);
verify(cell, times(2)).updateTarget(module.cellGrowthRate, SIZE_TARGET);
}

@Test
Expand Down

0 comments on commit 4f1a30a

Please sign in to comment.