NetLogo host versus pathogens model
Model was written in NetLogo 5.0.4
•
Viewed 608 times
•
Downloaded 31 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Click to Run Model
breed [ circles circle ] ;; Host cells breed [ flags flag ] ;; Key host cells breed [ triangles triangle ] ;; Pathogens A breed [ stars star ] ;; Pathogens B turtles-own [energy max-energy start-energy birth-energy] ;; All turtles have energy and a maximum amount of energy they can take on. patches-own [countdown patch-energy] ;; Countdown makes it run. Patch-energy is new to the program. circles-own [circle-energy-to-survive] flags-own [flag-energy-to-survive] triangles-own [triangle-energy-to-survive] stars-own [star-energy-to-survive] globals [cumulative-energy-deficit pathB report-pathogen-eliminated-ticks report-pathogens-overrun-host] to setup clear-all set pathB 1 ;; Turns the pathB switch in the code to "on" in the setup. The user must still physically turn on the switch at the interface screen. set report-pathogen-eliminated-ticks 1 ;; Needed to have the Results display be able to display "Pathogens eliminated in ____ ticks." only once instead of repeatedly. set report-pathogens-overrun-host 1 ;; Needed to have the Results display be able to display "Pathogens overrun host." only once instead of repeatedly. ;; The latter two lines are used in the code for the Go buttons. set systemic-host-stressor 0 ;; Always starts it at 0 so you don't have to remember to manually reset it. ADDED MAY 23 set upper-systemic-stressor-threshold 30 ;; ditto, May 23 set lower-systemic-stressor-threshold 5 ;; ditto, May23 ask patches [ set pcolor green set patch-energy 100] set-default-shape circles "circle" ;; Host cells ask patches [ sprout-circles 1 [set color blue set start-energy 300 set birth-energy 90 set max-energy 300 set circle-energy-to-survive 40] ] ;; START-ENERGY HAD BEEN 120 FOR ALL CELLS set-default-shape flags "flag" ;; key host cells such as heart cells ask patches with [(pycor < 3) and (pycor > -3 ) and (pxcor < 3) and (pxcor > 0)] [sprout-flags 1 [ set color orange set start-energy 300 set max-energy 300 set flag-energy-to-survive 30] ] ;; Can store lots of energy; not prone to apoptosis since irreplaceable. ask circles with [ (pycor < 3) and (pycor > -3 ) and (pxcor < 3) and (pxcor > 0)] [ die ] ;; This clears out the circles underneath the flags. ;; for the flag area (the "heart"), I've divided it into 3 domains, so each of these 3 sets of code are needed to create it so that host cells can migrate in if needed. set-default-shape flags "flag" ;; Needed to make sure that host cells could always have a chance of replacing dead key host cells, so needed to "hollow out" the core of the key host organ. ;; There were rare instances when, with a solid key host organ, a central key host cell died but it couldn't be rplaced by a host cell. ;; In those instances, the host could never regenerate the full 1089 cells and recovery would never occur. ask patches with [(pycor < 3) and (pycor > -3 ) and (pxcor < 0) and (pxcor > -3)] [sprout-flags 1 [ set color orange set start-energy 300 set max-energy 300 set flag-energy-to-survive 30] ] ;; Can store lots of energy; not prone to apoptosis since irreplaceable. ask circles with [ (pycor < 3) and (pycor > -3 ) and (pxcor < 0) and (pxcor > -3)] [ die ] ;; This clears out the circles underneath the flags. set-default-shape flags "flag" ;; This lets host cells always be adjacent to a key host cell so recovery is possible. ask patches with [(pycor < 3) and (pycor > 0) and (pxcor = 0)] [sprout-flags 1 [ set color orange set start-energy 300 set max-energy 300 set flag-energy-to-survive 30] ] ;; Can store lots of energy; not prone to apoptosis since irreplaceable. ask circles with [ (pycor < 3) and (pycor > 0) and (pxcor = 0)] [ die ] ;; This clears out the circles underneath the flags. set-default-shape triangles "triangle" ;; Pathogens A (these are like large extracellular pathogens) ask circles with [ (pycor <= start-upper-pathogen-pycor) and (pycor > start-lower-pathogen-pycor) and (pxcor <= start-upper-pathogen-pxcor) and (pxcor > start-lower-pathogen-pxcor) ] [ die ] ;; This clears out the circles underneath where the triangles will be. ask patches with [ (pycor <= start-upper-pathogen-pycor) and (pycor > start-lower-pathogen-pycor) and (pxcor <= start-upper-pathogen-pxcor) and (pxcor > start-lower-pathogen-pxcor)] [sprout-triangles 1 [ set color red set start-energy 300 set birth-energy 60 set max-energy 300 set triangle-energy-to-survive 40] ] ;; Low energy storage compared to host cells is a vulnerability; same energy to survive as host cells. ;; The pathogens' energy to survive can be modified by the slider (see below). ask turtles [ set energy start-energy ] ;; Even though start-energy is mentioned above for each breed, this code is needed to actually impart the energy. reset-ticks end to go set cumulative-energy-deficit 326700 - ((sum [energy] of circles) + (sum [energy] of flags)) + cumulative-energy-deficit ;; There are 1089 potential host cells and key host cell x 300 max energy units per cell. ;; Note that the host starts with a deficit of 3000 because the of the initial infection (e.g. a bite wound). ;; The host must recover to its full 1089 cells. ;; Also changed the formula from 323700 to 326700 in the instantaneous-energy-deficit monitor on the interface. stop-adding-energy keep-turtles-still invoke-pathogen-harm invoke-pathogen-take-energy invoke-pathogen-low-energy invoke-pathogen-wander if auto-infect-with-pathogenB? and pathB = 1 ;; This is a switch in the code that permits turning off the secondary infection (pathogen B) after one tick. [if count circles <= 1000 ;;and mean [energy] of circles <= 90 ;; I added the mean energy statement, but this could have been instantaneoud-energy-deficit. [invoke-auto-infection-pathogenB] ] ;; This code for pathogenB, the secondary infection, is farther down. invoke-pathogenB-harm invoke-pathogenB-take-energy invoke-pathogenB-low-energy invoke-pathogenB-wander invoke-local-directed invoke-local-stressor invoke-clot-stressor invoke-amputation invoke-amputationB invoke-hostcell-wander invoke-auto-systemic-stressor-hostcell# invoke-auto-systemic-stressor-pathogen# invoke-auto-systemic-stressor-combined replicate check-death tick end to stop-adding-energy ;; Limits the amount of energy each cell can store, but there can be temporary overshooting of the amount. ask turtles [ if energy >= max-energy [set energy max-energy ]] end to keep-turtles-still ;; This sets the action. The switches on the interface screen allow movement to adjacent vacant spacesfor either pathogens or host cells. ask turtles [ right random 360 forward 0 ;; This gets the turtles, especially the flags, to move in place; therefore no visible movement but it lets time occur (ticks go). ;; All turtles derive energy from the patches as patch-energy at each tick and lose a little less energy (metabolic energy) with each tick. set energy (random-normal 1 0.02) * (energy + ((patch-energy * 0.14) * ((100 - systemic-host-stressor) / 100))) ;; The systemic host stressor is here. ; set energy (random-normal 1 0.02) * (energy + (14 * (100 - systemic-host-stressor) / 100)) ;; This was old code where the turtles were simply given energy at each tick. set energy (random-normal 1 0.02) * (energy - 10) ;; Every tick costs the turtles about 10 units of energy. ;; This is the energy gain and loss per tick; the random-normal (mean of 1 and SD of 0.02) gives a bit of randomness to the whole program. ;; I don't want too much randomness since all turtles are bathed in the same fluid of patch-energy and are superficially identical ;; There's additional randomness in the pathogen damage routine and in the host defense routines. ;; The systemic host stressor represents the acute-phase response: fever, iron & zinc sequestration, anorexia/nutrient restriction, anemia/hypoxia, systemic acidosis, etc. ifelse show-energy? ;; This is for the switch on the interface screen. Best to have it on. [ set label round energy] ;; "round" rounds the energy value on the screen to a readable integer. [ set label ""] ;; If set to "No", no energy values show on the screen ] end ;; PATHOGEN PHENOTYPE SLIDERS & SWITCH to invoke-pathogen-harm ;; This acts like a toxin to harm adjacent host cells. ask triangles [ ask circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogen-harm-hostcells) ]] ask triangles [ ask flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogen-harm-hostcells) ]] end to invoke-pathogen-take-energy ;; This gives the pathogen energy when it's adjacent to a host cell. ask triangles [ if any? circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogen-take-up-energy) ]] ask triangles [ if any? flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogen-take-up-energy) ]] end to invoke-pathogen-low-energy ;; Lowering the "pathogen-survive-low-energy" number lets them survive better. They still need 120 energy units to reproduce (2 * birth-energy). ask triangles [ set triangle-energy-to-survive pathogen-survive-low-energy ] ask triangles [ set max-energy pathogen-survive-low-energy + 260 ] ;; As a minor handicap for enhanced survival, I've also reduced the max-energy they can store. end to invoke-pathogen-wander ;; In this model, letting the pathogens move to free spaces helps them only if they are more lethal than host cells; otherwise they're more vulnerable. ifelse pathogen-wander? [ ask triangles [ let empty-patches neighbors with [ not any? turtles-here ] if pcolor = green [ if any? empty-patches [ let target one-of empty-patches face target move-to target ]] if pcolor = 43 and random (clot-restrict-motion + 1) = 0 ;; When pathogen-wander? is on this lets the clot restrict the motion. ;; "random 1" makes one random number which is always 0; random 2 makes either a 0 or 1; ... ; random 5 makes 0,1,2,3 or 4. ;; Therefore the slider set at 0 makes random 1, which always produces 0, so there is no motion restriction. ;; When the slider is set to 1, the turtle moves approx. 50% of the time; when slider is set to 4, the turtle moves 20% of the time (1 tick in 5). [ if any? empty-patches [ let target one-of empty-patches face target move-to target ]] ] ] [ ] end ;; PATHOGEN B PHENOTYPE SLIDERS & SWITCH to invoke-auto-infection-pathogenB ;; The parameters needed to start this secondary infection are coded earlier in the program. ask circles with [ (pycor <= start-upper-pathogenB-pycor) and (pycor > start-lower-pathogenB-pycor) and (pxcor <= start-upper-pathogenB-pxcor) and (pxcor > start-lower-pathogenB-pxcor)] [die] ;; This clears out the host cells at the site before pathogen B comes along (otherwise the pathogens and the host cells are on the same patch and most pathogens die). ask patches with [ (pycor <= start-upper-pathogenB-pycor) and (pycor > start-lower-pathogenB-pycor) and (pxcor <= start-upper-pathogenB-pxcor) and (pxcor > start-lower-pathogenB-pxcor)] [sprout-stars 1 [ set color red set start-energy 300 set birth-energy 60 set max-energy 300 set star-energy-to-survive 40] ] ask stars [ set energy start-energy ] set pathB 0 ;; This turns off the infection with pathogen B after a single round. end to invoke-pathogenB-harm ;; This acts like a toxin to harm adjacent host cells ask stars [ ask circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogenB-harm-hostcells) ]] ask stars [ ask flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogenB-harm-hostcells) ]] end to invoke-pathogenB-take-energy ;; This gives pathogen B energy when adjacent to host cell ask stars [ if any? circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogenB-take-up-energy) ]] ask stars [ if any? flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogenB-take-up-energy) ]] end to invoke-pathogenB-low-energy ;; Lowering the "pathogenB-survive-low-energy" number lets them survive better ask stars [ set star-energy-to-survive pathogenB-survive-low-energy ] ask stars [set max-energy pathogenB-survive-low-energy + 160 ] ;; I've linked the max-energy they can use to the survival energy threshold as a minor handicap end to invoke-pathogenB-wander ;; In this model, letting the pathogens move to free spaces helps them only if they are more lethal than host cells; otherwise they're more vulnerable. ifelse pathogenB-wander? [ ask stars [ let empty-patches neighbors with [ not any? turtles-here ] if pcolor = green [ if any? empty-patches [ let target one-of empty-patches face target move-to target ]] if pcolor = 43 and random (clot-restrict-motion + 1) = 0 ;; When pathogenB-wander? is on this lets the clot restrict the motion. ;; "random 1" makes one random number which is always 0; random 2 makes either a 0 or 1; ... ; random 5 makes 0,1,2,3 or 4. ;; Therefore the slider set at 0 makes random 1, which always produces 0, so there is no motion restriction. ;; When the slider is set to 1, the turtle moves approx. 50% of the time; when slider is set to 4, the turtle moves 20% of the time (1 tick in 5). [ if any? empty-patches [ let target one-of empty-patches face target move-to target ]] ] ] [ ] end ;; HOST DEFENSES: SLIDERS & SWITCHES (Systemic stressor slider is already incorporated above) to invoke-local-directed ;; Host cells directly harm adjacent pathogens (as if injecting a toxin). ask circles [ ask triangles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-directed) ]] ask circles [ ask stars in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-directed) ]] end to invoke-local-stressor ;; Harms all adjacent cells if the host cell is in contact with a pathogen as if depriving the area of nutrients or causing acidosis. ask triangles [ ask circles in-radius 1 [ ask turtles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-stressor) ]]] ask stars [ ask circles in-radius 1 [ ask turtles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-stressor) ]]] end to invoke-clot-stressor ;; Makes a "clot" at the inflammatory site to reduce patch energy (blood replacement) and reduce cell movement. ;; The effect of the clot on energy is controlled by the slider "%-reduced-clot-patch-energy", though I'm not sure exactly what it's doing. ;; The effect on motion (so far on the pathogen) is set at "invoke-pathogen-wander" above. Need a switch or slider for that and do the same for pathogen B and host cells. ask circles [if any? triangles in-radius 1 [ask patches in-radius 2 [set pcolor 43]]] ask circles [if any? stars in-radius 1 [ask patches in-radius 2 [set pcolor 43]]] ask patches [ifelse pcolor = 43 [ set patch-energy (100 - %-reduced-clot-patch-energy)] [ set patch-energy 100]] ask circles [if not any? triangles in-radius 4 and not any? stars in-radius 4 [ask patches in-radius 1 [set pcolor green]]] ;; Lets recovering host cells clear the clot, allowing host recovery. end to invoke-amputation ;; This code harms all cells in the lower right region as if using a tourniquet (or hypersensitive reaction in plants). ask turtles with [ (pycor < 0) and (pxcor > 10)] [ set energy (random-normal 1 0.02) * (energy * ((100 - regional-amputation) / 100)) ] end to invoke-amputationB ;; This code harms all cells in the lower left region as if using a tourniquet (or hypersensitive reaction in plants). ask turtles with [ (pycor < 0) and (pxcor < -10)] [ set energy (random-normal 1 0.02) * (energy * ((100 - regional-amputationB) / 100)) ] end to invoke-hostcell-wander ;; Lets the host cells move to free spaces. ifelse hostcell-wander? ;; This slightly helps the host IF the host cells can harm the pathogens either directly or by local stressing. [ ask circles [ let empty-patches neighbors with [ not any? turtles-here ] if pcolor = green [ if any? empty-patches [ let target one-of empty-patches face target move-to target ]] if pcolor = 43 and random (clot-restrict-motion + 1) = 0 ;; When hostcell-wander? is on this lets the clot restrict the motion. ;; "random 1" makes one random number which is always 0; random 2 makes either a 0 or 1; ... ; random 5 makes 0,1,2,3 or 4. ;; Therefore the slider set at 0 makes random 1, which always produces 0, so there is no motion restriction. ;; When the slider is set to 1, the turtle moves approx. 50% of the time; when slider is set to 4, the turtle moves 20% of the time (1 tick in 5). ;; When the slider is set to 9, the turtle moves 1 tick in 10 or 10% of the time. [ if any? empty-patches [ let target one-of empty-patches face target move-to target ]] ] ] [ ] end to invoke-auto-systemic-stressor-hostcell# ;; An automatic device that quickly turns the systemic stressor on and then off, etc. Lots of overshooting with this strategy. ifelse auto-systemic-stressor-hostcell#? ;; However, once the pathogen invades enough that there are less than 925 host cells, it won't turn on anymore. [ if count circles <= 1030 ;;and (count triangles + count stars) >= 5 ;; This works better with it in (allows more recovery), BUT IT'S A DIFFERENT MODEL. -May 23 2013 [ set systemic-host-stressor 60 ] if (count circles <= 925) ;; and count triangles < 5) ;;This lets the stress continue below 925 if pathogens still present (better defense) [ set systemic-host-stressor 0 ]] [ ] if (count triangles + count stars) = 0 ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at 60). [set systemic-host-stressor 0] end ;; This defense is helpless if the number of host cells can't get back up tp 925, unlike the cycling that depends on pathogen numbers (below). to invoke-auto-systemic-stressor-pathogen# ;; Based on pathogen numbers. The lower threshold guarantees the systemic stressing will cycle. ifelse auto-systemic-stressor-pathogen#? [ if (count triangles + count stars) >= upper-systemic-stressor-threshold ;; threshold is set with a slider (recommend a setting of 30 [comparable to having 1030 host cells]) [ set systemic-host-stressor 60 ] if (count triangles + count stars) <= lower-systemic-stressor-threshold ;; threshold is set with a slider (recommmend a setting of 5) [ set systemic-host-stressor 0 set upper-systemic-stressor-threshold 0.5 * upper-systemic-stressor-threshold set lower-systemic-stressor-threshold 0.5 * lower-systemic-stressor-threshold]] [ ] if (count triangles + count stars) = 0 ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at 60). [set systemic-host-stressor 0] end ;;May 23, 2013. THIS WORKS FAIRLY WELL BECAUSE OF THE "AND" 5 LINES DOWN. to invoke-auto-systemic-stressor-combined ;; An automatic device that combines knowledge of pathogen numbers and host status to balance death due to sepsis and due to pathogen overgrowth. ifelse auto-systemic-stressor-combined? ;; [ if (count circles <= 1030 and (count triangles + count stars) >= 15) or ((count triangles + count stars) >= upper-systemic-stressor-threshold) ;;This requires host damage as well as pathogens to set it off (rather than just host damage alone). It works better and is more biologically relevant. [ set systemic-host-stressor 60 ] if ((count triangles + count stars) <= lower-systemic-stressor-threshold) or (count circles <= 925) ;; PUTTING "and" here is more aggressive; putting "or" should make it less aggressive--better for host ;; The systemic stressor stays on longer (well below 925 host cells) so sepsis can eventually be due to not enough host cells (as well as key host cells). [ set systemic-host-stressor 0 set upper-systemic-stressor-threshold 0.5 * upper-systemic-stressor-threshold set lower-systemic-stressor-threshold 0.5 * lower-systemic-stressor-threshold]] [ ] if (count triangles + count stars) = 0 ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at 60). [set systemic-host-stressor 0] end ;; This defense is helpless if the number of host cells can't get back up tp 925, unlike the cycling that depends on pathogen numbers (below). to replicate ask triangles ;; Pathogens replicate if they have 2x birth-energy (60 units) and a vacant patch for the hatchling to move to. [ if energy > 2 * birth-energy and any? neighbors with [not any? turtles-here] [ set energy energy / 2 ;; This cuts the energy in half before hatching. hatch 1 [set energy birth-energy ;; There's a little lost energy since mother may have more than 2x birth-energy, let target one-of neighbors with [not any? turtles-here] ;; but daughter cell (hatchling) only gets the birth-energy. face target move-to target ] ] ] ask stars [ ;; Pathogen B replicate if they have 2x birth-energy (60 units) and a vacant patch for the hatchling to move to. if energy > 2 * birth-energy and any? neighbors with [not any? turtles-here] [ set energy energy / 2 ;; This cuts the energy in half before hatching. hatch 1 [set energy birth-energy ;; There's a little lost energy since mother may have more than 2x birth-energy, let target one-of neighbors with [not any? turtles-here] ;; but daughter cell (hatchling) only gets the birth-energy. face target move-to target ] ] ] ask circles [ if energy > 2 * birth-energy and any? neighbors with [not any? turtles-here] ;; Host cells replicate if they have 2x birth-energy (90 units) and a vacant patch for the hatchling to move to. [ set energy energy / 2 ;; This cuts the energy before hatching. hatch 1 [set energy birth-energy ;; There's a little lost energy since mother may have more than 2x birth-energy, let target one-of neighbors with [not any? turtles-here] ;; but daughter cell (hatchling) only gets the birth-energy. face target move-to target ] ] ] ;; Flags (key host cells) don't replicate end to check-death ask circles [ if energy <= circle-energy-to-survive [ die ]] ask flags [ if energy <= flag-energy-to-survive [ die ]] ask triangles [ if energy <= triangle-energy-to-survive [ die ]] ask stars [ if energy <= star-energy-to-survive [ die ]] end
There is only one version of this model, created almost 11 years ago by Edmund LeGrand.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
NetLogo host versus pathogens model.png | preview | Red pathogens invading the host (host cells as gray circles) | almost 11 years ago, by Edmund LeGrand | Download |
Edmund LeGrand
Extra features on far right side of interface
Note that on the extreme right side of the interface screen of the model there are additional sliders and settings that have been hidden to make a clean interface. These features, such as making an additional pathogen and moving the starting location of the pathogens, are functional.
Posted almost 11 years ago