-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimmune_submodels.cpp
More file actions
1604 lines (1302 loc) · 55.1 KB
/
Copy pathimmune_submodels.cpp
File metadata and controls
1604 lines (1302 loc) · 55.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "./immune_submodels.h"
using namespace PhysiCell;
std::string immune_submodels_version = "0.1.2";
// Submodel_Information Immune_submodels_info; // not needed for now
Submodel_Information CD8_submodel_info;
Submodel_Information Macrophage_submodel_info;
Submodel_Information Neutrophil_submodel_info;
Submodel_Information DC_submodel_info;
Submodel_Information CD4_submodel_info;
std::vector<Cell*> cells_to_move_from_edge;
std::vector<int> vascularized_voxel_indices;
// return true if out of bounds, within a tolerance
bool check_for_out_of_bounds( Cell* pC , double tolerance )
{
static double Xmin = microenvironment.mesh.bounding_box[0];
static double Ymin = microenvironment.mesh.bounding_box[1];
static double Zmin = microenvironment.mesh.bounding_box[2];
static double Xmax = microenvironment.mesh.bounding_box[3];
static double Ymax = microenvironment.mesh.bounding_box[4];
static double Zmax = microenvironment.mesh.bounding_box[5];
static bool two_dimensions = default_microenvironment_options.simulate_2D;
static bool setup_done = false;
if( default_microenvironment_options.simulate_2D == true && setup_done == false )
{
Zmin = 0.0;
Zmax = 0.0;
setup_done = true;
}
if( pC->position[0] < Xmin + tolerance )
{ return true; }
if( pC->position[0] > Xmax - tolerance )
{ return true; }
if( pC->position[1] < Ymin + tolerance )
{ return true; }
if( pC->position[1] > Ymax - tolerance )
{ return true; }
if( two_dimensions )
{ return false; }
if( pC->position[2] < Zmin + tolerance )
{ return true; }
if( pC->position[2] > Zmax - tolerance )
{ return true; }
return false;
}
// return {push_x,push_y,push_z} of direction to nudge cell
std::vector<double> set_nudge_from_edge( Cell* pC , double tolerance )
{
static double Xmin = microenvironment.mesh.bounding_box[0];
static double Ymin = microenvironment.mesh.bounding_box[1];
static double Zmin = microenvironment.mesh.bounding_box[2];
static double Xmax = microenvironment.mesh.bounding_box[3];
static double Ymax = microenvironment.mesh.bounding_box[4];
static double Zmax = microenvironment.mesh.bounding_box[5];
static bool two_dimensions = default_microenvironment_options.simulate_2D;
static bool setup_done = false;
if( default_microenvironment_options.simulate_2D == true && setup_done == false )
{
Zmin = 0.0;
Zmax = 0.0;
setup_done = true;
}
std::vector<double> nudge = {0,0,0};
if( pC->position[0] < Xmin + tolerance )
{ nudge[0] += 1; }
if( pC->position[0] > Xmax - tolerance )
{ nudge[0] -= 1; }
if( pC->position[1] < Ymin + tolerance )
{ nudge[1] += 1; }
if( pC->position[1] > Ymax - tolerance )
{ nudge[1] -= 1; }
if( two_dimensions )
{ normalize(nudge); return nudge; }
if( pC->position[2] < Zmin + tolerance )
{ nudge[2] += 1; }
if( pC->position[2] > Zmax - tolerance )
{ nudge[2] -= 1; }
normalize(nudge);
return nudge;
}
void nudge_out_of_bounds_cell( Cell* pC , double tolerance )
{
std::vector<double> nudge = set_nudge_from_edge(pC,tolerance);
// remove attachments
pC->remove_all_attached_cells();
// set velocity away rom edge
pC->velocity = nudge;
// set new position
nudge *= tolerance;
pC->position += nudge;
// update in the data structure
pC->update_voxel_in_container();
// allow that cell to move and be movable
pC->is_out_of_domain = false;
pC->is_active = true;
pC->is_movable= true;
return;
}
void replace_out_of_bounds_cell( Cell* pC , double tolerance )
{
static double Xmin = microenvironment.mesh.bounding_box[0];
static double Ymin = microenvironment.mesh.bounding_box[1];
static double Zmin = microenvironment.mesh.bounding_box[2];
static double Xmax = microenvironment.mesh.bounding_box[3];
static double Ymax = microenvironment.mesh.bounding_box[4];
static double Zmax = microenvironment.mesh.bounding_box[5];
static bool setup_done = false;
if( setup_done == false )
{
Xmin += tolerance;
Ymin += tolerance;
Zmin += tolerance;
Xmax -= tolerance;
Ymax -= tolerance;
Zmax -= tolerance;
if( default_microenvironment_options.simulate_2D == true )
{
Zmin = 0.0;
Zmax = 0.0;
}
setup_done = true;
}
static double Xrange = Xmax - Xmin;
static double Yrange = Ymax - Ymin;
static double Zrange = Zmax - Zmin;
std::vector<double> position = {Xmin,Ymin,Zmin}; //
position[0] += Xrange * UniformRandom();
position[1] += Yrange * UniformRandom();
position[2] += Zrange * UniformRandom() + parameters.doubles("immune_z_offset");
#pragma omp critical
{
// std::cout << "moving cell from edge " << pC << " " << pC->type_name << std::endl;
// create a new cell of same type
Cell* pNewCell = create_cell( get_cell_definition(pC->type_name) );
pNewCell->assign_position( position );
// pNewCell->custom_data = pC->custom_data; // enable in next testing
// get rid of the old one
pC->lyse_cell();
}
return;
}
void process_tagged_cells_on_edge( void )
{
for( int n=0 ; n < cells_to_move_from_edge.size(); n++ )
{
Cell* pC = cells_to_move_from_edge[n];
// std::cout << "moving cell from edge " << pC << " " << pC->type_name << std::endl;
// replace_out_of_bounds_cell( cells_to_move_from_edge[n] , 10.0 );
nudge_out_of_bounds_cell( pC , 10.0 );
}
// if( cells_to_move_from_edge.size() > 0 )
// { std::cout << std::endl; }
return;
}
// not used
void move_out_of_bounds_cell( Cell* pC , double tolerance )
{
static double Xmin = microenvironment.mesh.bounding_box[0];
static double Ymin = microenvironment.mesh.bounding_box[1];
static double Zmin = microenvironment.mesh.bounding_box[2];
static double Xmax = microenvironment.mesh.bounding_box[3];
static double Ymax = microenvironment.mesh.bounding_box[4];
static double Zmax = microenvironment.mesh.bounding_box[5];
static bool setup_done = false;
if( setup_done == false )
{
Xmin += tolerance;
Ymin += tolerance;
Zmin += tolerance;
Xmax -= tolerance;
Ymax -= tolerance;
Zmax -= tolerance;
if( default_microenvironment_options.simulate_2D == true )
{
Zmin = 0.0;
Zmax = 0.0;
}
setup_done = true;
}
static double Xrange = Xmax - Xmin;
static double Yrange = Ymax - Ymin;
static double Zrange = Zmax - Zmin;
std::vector<double> position = {Xmin,Ymin,Zmin}; //
position[0] += Xrange * UniformRandom();
position[1] += Yrange * UniformRandom();
position[2] += Zrange * UniformRandom() + parameters.doubles("immune_z_offset");
#pragma omp critical
{
// create a new cell of same type
Cell* pNewCell = create_cell( get_cell_definition(pC->type_name) );
pNewCell->assign_position( position );
// pNewCell->custom_data = pC->custom_data; // enable in next testing
// get rid of the old one
pC->lyse_cell();
}
return;
}
void choose_initialized_voxels( void )
{
// read in percentage of tissue that's vascularised
double percentage_vascularised = parameters.doubles("perecentage_tissue_vascularized");
int max_voxel_index = microenvironment.mesh.voxels.size() - 1;
int number_of_vascularized_voxels = (int) ( percentage_vascularised/100.0 * ( max_voxel_index+1) );
// choose which voxels are veins
for( int n = 0 ; n < number_of_vascularized_voxels ; n++ )
{
int index_vascularised_voxel = (int) ( UniformRandom() * max_voxel_index );
vascularized_voxel_indices.push_back( index_vascularised_voxel );
}
return;
}
void create_infiltrating_immune_cell( Cell_Definition* pCD )
{
Cell* pC = create_cell( *pCD );
std::vector<double> position = choose_vascularized_position();
pC->assign_position( position );
return;
}
void create_infiltrating_immune_cell_initial( Cell_Definition* pCD )
{
Cell* pC = create_cell( *pCD );
// randomly place cell intially
double Xmin = microenvironment.mesh.bounding_box[0];
double Ymin = microenvironment.mesh.bounding_box[1];
double Zmin = microenvironment.mesh.bounding_box[2];
double Xmax = microenvironment.mesh.bounding_box[3];
double Ymax = microenvironment.mesh.bounding_box[4];
double Zmax = microenvironment.mesh.bounding_box[5];
if( default_microenvironment_options.simulate_2D == true )
{
Zmin = 0.0;
Zmax = 0.0;
}
double Xrange = (Xmax - Xmin);
double Yrange = (Ymax - Ymin);
double Zrange = (Zmax - Zmin);
// keep cells away from the outer edge
Xmin += 0.1*Xrange;
Ymin += 0.1*Yrange;
Zmin = 0;
Xrange *= 0.8;
Yrange *= 0.8;
Zrange = 0.0;
// create some of each type of cell
std::vector<double> position = {0,0,0};
position[0] = Xmin + UniformRandom()*Xrange;
position[1] = Ymin + UniformRandom()*Yrange;
pC->assign_position( position );
return;
}
std::vector<double> choose_vascularized_position( void )
{
//extern std::vector<int> vascularized_voxel_indices;
int my_voxel_index = (int) ( UniformRandom() * (vascularized_voxel_indices.size()-1) );
int n = vascularized_voxel_indices[ my_voxel_index ] ;
return microenvironment.mesh.voxels[n].center;
}
void create_infiltrating_immune_cell( std::string cell_name )
{
create_infiltrating_immune_cell( find_cell_definition( cell_name ) );
return;
}
void create_infiltrating_neutrophil(void)
{
static Cell_Definition* pCD = find_cell_definition( "neutrophil" );
create_infiltrating_immune_cell( pCD );
return;
}
void create_infiltrating_Tcell(void)
{
static Cell_Definition* pCD = find_cell_definition( "CD8 Tcell" );
create_infiltrating_immune_cell( pCD );
return;
}
// (Adrianne) creating infiltrating CD4 cells
void create_infiltrating_CD4Tcell(void)
{
static Cell_Definition* pCD = find_cell_definition( "CD4 Tcell" );
create_infiltrating_immune_cell( pCD );
return;
}
// (Adrianne) creating infiltrating DCs
void create_infiltrating_DC(void)
{
static Cell_Definition* pCD = find_cell_definition( "DC" );
create_infiltrating_immune_cell( pCD );
return;
}
void create_infiltrating_macrophage(void)
{
static Cell_Definition* pCD = find_cell_definition( "macrophage" );
create_infiltrating_immune_cell( pCD );
return;
}
void CD8_Tcell_contact_function( Cell* pC1, Phenotype& p1, Cell* pC2, Phenotype& p2 , double dt )
{
// std::cout << pC1 << " " << pC1->type_name
// << " contact with " << pC2 << " " << pC2->type_name << std::endl;
// elastic adhesions
standard_elastic_contact_function( pC1,p1, pC2, p2, dt );
// increase contact time of cell you are attacking
#pragma omp critical
{ pC2->custom_data["TCell_contact_time"] += dt; }
return;
}
void CD8_Tcell_phenotype( Cell* pCell, Phenotype& phenotype, double dt )
{
static int debris_index = microenvironment.find_density_index( "debris");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
return;
}
void CD8_Tcell_mechanics( Cell* pCell, Phenotype& phenotype, double dt )
{
static int debris_index = microenvironment.find_density_index( "debris");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// bounds check
if( check_for_out_of_bounds( pCell , 10.0 ) )
{
#pragma omp critical
{ cells_to_move_from_edge.push_back( pCell ); }
// replace_out_of_bounds_cell( pCell, 10.0 );
// return;
}
// if I am not adhered to a cell, turn motility on
if( pCell->state.neighbors.size() == 0 )
{ phenotype.motility.is_motile = true; }
else
{ phenotype.motility.is_motile = false; }
// check for contact with infected cell
// if I'm adhered to something ...
if( pCell->state.number_of_attached_cells() > 0 ) // pCell->state.neighbors.size() > 0 )
{
// decide whether to detach
bool detach_me = false;
if( UniformRandom() < dt / ( pCell->custom_data["cell_attachment_lifetime"] + 1e-15 ) )
{ detach_me = true; }
// if I detach, go through the process
if( detach_me )
{
pCell->remove_all_attached_cells();
// resume motile behavior
phenotype.motility.is_motile = true;
}
return;
}
// I'm not attached, look for cells nearby and try to attach
// if this returns non-NULL, we're now attached to a cell
if( immune_cell_check_neighbors_for_attachment( pCell , dt) )
{
// set motility off
phenotype.motility.is_motile = false;
return;
}
phenotype.motility.is_motile = true; // I suggest eliminating this.
return;
}
void immune_cell_motility_direction( Cell* pCell, Phenotype& phenotype , double dt )
{
if( phenotype.death.dead == true )
{
phenotype.motility.migration_speed = 0.0;
return;
}
static int chemokine_index = microenvironment.find_density_index( "chemokine");
static int debris_index = microenvironment.find_density_index( "debris");
// if not activated, chemotaxis along debris
phenotype.motility.migration_bias_direction = pCell->nearest_gradient(debris_index);
normalize( &phenotype.motility.migration_bias_direction );
if( pCell->custom_data["activated_immune_cell"] < 0.5 )
{ return; }
// if activated, follow the weighted direction
phenotype.motility.migration_bias_direction *= pCell->custom_data["sensitivity_to_debris_chemotaxis"];
std::vector<double> gradC = pCell->nearest_gradient(chemokine_index);
normalize( &gradC );
gradC *= pCell->custom_data["sensitivity_to_chemokine_chemotaxis"];
phenotype.motility.migration_bias_direction += gradC;
normalize( &( phenotype.motility.migration_bias_direction) );
/*
#pragma omp critical
{
std::cout << phenotype.motility.migration_speed << " : " << pCell->custom_data["sensitivity_to_debris_chemotaxis"]
<< " " << pCell->custom_data["sensitivity_to_chemokine_chemotaxis"] << " : [" << phenotype.motility.migration_bias_direction << "] vs ["
<< pCell->nearest_gradient(chemokine_index) << "]" << std::endl;
}
*/
return;
}
void macrophage_phenotype( Cell* pCell, Phenotype& phenotype, double dt )
{
static int apoptosis_index = phenotype.death.find_death_model_index( "Apoptosis" );
static Cell_Definition* pCD = find_cell_definition( "macrophage" );
static int proinflammatory_cytokine_index = microenvironment.find_density_index( "pro-inflammatory cytokine");
static int chemokine_index = microenvironment.find_density_index( "chemokine");
static int debris_index = microenvironment.find_density_index( "debris");
// no apoptosis until activation (resident macrophages in constant number for homeostasis)
if( pCell->custom_data["activated_immune_cell"] < 0.5 )
{ phenotype.death.rates[apoptosis_index] = 0.0; }
else
{ phenotype.death.rates[apoptosis_index] = pCD->phenotype.death.rates[apoptosis_index]; }
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// make changes to volume change rate??
// if too much debris, comit to apoptosis
/* // remove in v 3.2
double relative_volume = ( phenotype.volume.total/pCD->phenotype.volume.total );
if( relative_volume > pCell->custom_data[ "relative_maximum_volume" ] )
{
pCell->start_death( apoptosis_index );
pCell->phenotype.secretion.secretion_rates[proinflammatory_cytokine_index] = 0;
pCell->phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
*/
// check for cells to eat
std::vector<Cell*> neighbors = pCell->cells_in_my_container();
// at least one of the cells is pCell
if( neighbors.size() < 2 )
{ return; }
// (Adrianne) get type of CD8+ T cell and CD4+ t CELL
static int CD8_Tcell_type = get_cell_definition( "CD8 Tcell" ).type;
static int CD4_Tcell_type = get_cell_definition( "CD4 Tcell" ).type;
// (Adrianne) if there is a T cell in a mac's neighbourhood AND a mac has already begin phagocytosing, then mac will stop secretion of pro-inflam cytokine (until it re-phagocytoses something)
int n = 0;
Cell* pContactCell = neighbors[n];
while( n < neighbors.size() )
{
pContactCell = neighbors[n];
// (Adrianne) if it is not me, not dead and is a T cell
if( pContactCell != pCell && pContactCell->phenotype.death.dead == false && pContactCell->type == CD8_Tcell_type && pCell->custom_data["activated_immune_cell"] > 0.5)
{
phenotype.secretion.secretion_rates[proinflammatory_cytokine_index] = 0;// (Adrianne) contact with CD8 T cell turns off pro-inflammatory cytokine secretion
n=neighbors.size();
}
else if( pContactCell != pCell && pContactCell->phenotype.death.dead == false && pContactCell->type == CD4_Tcell_type && pCell->custom_data["activated_immune_cell"] > 0.5)
{
pCell->custom_data["ability_to_phagocytose_infected_cell"] = 1; // (Adrianne) contact with CD4 T cell induces macrophage's ability to phagocytose infected cells
n=neighbors.size();
}
n++;
}
// (Adrianne) if macrophage volume exceeds a threshold value we say it is "exhausted" and unable to phagocytose until it's volume drops below this threshold
if( pCell->phenotype.volume.total> pCell->custom_data["threshold_macrophage_volume"])
{
// (Adrianne) when a macrophage is in an exhausted state it has a death rate 2.1e-4
phenotype.death.rates[apoptosis_index] = pCell->custom_data["exhausted_macrophage_death_rate"];
return;
}
// (Adrianne) obtain index for tracking time when next phagocytosis event is possible
int time_to_next_phagocytosis_index = pCell->custom_data.find_variable_index( "time_to_next_phagocytosis" );
// (Adrianne) check if still phagocytosing something, added if statement to say that if cell is still internalising current material not to phagocytose anything else
if( pCell->custom_data.variables[time_to_next_phagocytosis_index].value>PhysiCell_globals.current_time )
{return;}
double probability_of_phagocytosis = pCell->custom_data["phagocytosis_rate"] * dt;
/* // remove in v 3.2
double max_phagocytosis_volume = pCell->custom_data["phagocytosis_relative_target_cutoff_size" ] * pCD->phenotype.volume.total;
*/
// (Adrianne) add an additional variable that is the time taken to ingest material
double material_internalisation_rate = pCell->custom_data["material_internalisation_rate"];
n = 0;
Cell* pTestCell = neighbors[n];
while( n < neighbors.size() )
{
pTestCell = neighbors[n];
int nP = pTestCell->custom_data.find_variable_index( "viral_protein" ); //(Adrianne) finding the viral protein inside cells
// if it is not me and not a macrophage
if( pTestCell != pCell && pTestCell->phenotype.death.dead == true &&
UniformRandom() < probability_of_phagocytosis ) // && // remove in v 3.2
// pTestCell->phenotype.volume.total < max_phagocytosis_volume ) / remove in v 3.2
{
{
// (Adrianne) obtain volume of cell to be ingested
double volume_ingested_cell = pTestCell->phenotype.volume.total;
pCell->ingest_cell( pTestCell );
// (Adrianne)(assume neutrophils same as macrophages) neutrophils phagocytose material 1micron3/s so macrophage cannot phagocytose again until it has elapsed the time taken to phagocytose the material
double time_to_ingest = volume_ingested_cell*material_internalisation_rate;// convert volume to time taken to phagocytose
// (Adrianne) update internal time vector in macrophages that tracks time it will spend phagocytosing the material so they can't phagocytose again until this time has elapsed
pCell->custom_data.variables[time_to_next_phagocytosis_index].value = PhysiCell_globals.current_time+time_to_ingest;
}
// activate the cell
phenotype.secretion.secretion_rates[proinflammatory_cytokine_index] =
pCell->custom_data["activated_cytokine_secretion_rate"]; // 10;
phenotype.secretion.saturation_densities[proinflammatory_cytokine_index] = 1;
phenotype.secretion.uptake_rates[proinflammatory_cytokine_index] = 0.0;
phenotype.motility.migration_speed = pCell->custom_data["activated_speed"];
pCell->custom_data["activated_immune_cell"] = 1.0;
return;
}
else if( pTestCell != pCell && pCell->custom_data["ability_to_phagocytose_infected_cell"]== 1 && pTestCell->custom_data[nP]>1 &&
UniformRandom() < probability_of_phagocytosis ) // (Adrianne) macrophages that have been activated by T cells can phagocytose infected cells that contain at least 1 viral protein
{
{
// (Adrianne) obtain volume of cell to be ingested
double volume_ingested_cell = pTestCell->phenotype.volume.total;
pCell->ingest_cell( pTestCell );
// (Adrianne)(assume neutrophils same as macrophages) neutrophils phagocytose material 1micron3/s so macrophage cannot phagocytose again until it has elapsed the time taken to phagocytose the material
double time_to_ingest = volume_ingested_cell*material_internalisation_rate;// convert volume to time taken to phagocytose
// (Adrianne) update internal time vector in macrophages that tracks time it will spend phagocytosing the material so they can't phagocytose again until this time has elapsed
pCell->custom_data.variables[time_to_next_phagocytosis_index].value = PhysiCell_globals.current_time+time_to_ingest;
}
// activate the cell
phenotype.secretion.secretion_rates[proinflammatory_cytokine_index] =
pCell->custom_data["activated_cytokine_secretion_rate"]; // 10;
phenotype.secretion.saturation_densities[proinflammatory_cytokine_index] = 1;
phenotype.secretion.uptake_rates[proinflammatory_cytokine_index] = 0.0;
phenotype.motility.migration_speed = pCell->custom_data["activated_speed"];
pCell->custom_data["activated_immune_cell"] = 1.0;
return;
}
n++;
}
return;
}
void macrophage_mechanics( Cell* pCell, Phenotype& phenotype, double dt )
{
static int debris_index = microenvironment.find_density_index( "debris");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// bounds check
if( check_for_out_of_bounds( pCell , 10.0 ) )
{
#pragma omp critical
{ cells_to_move_from_edge.push_back( pCell ); }
// replace_out_of_bounds_cell( pCell, 10.0 );
// return;
}
// // death check
// if( phenotype.death.dead == true )
// { remove_all_adhesions( pCell ); }
return;
}
void neutrophil_phenotype( Cell* pCell, Phenotype& phenotype, double dt )
{
// std::cout << __FUNCTION__ << " " << __LINE__ << std::endl;
static int apoptosis_index = phenotype.death.find_death_model_index( "apoptosis" );
static Cell_Definition* pCD = find_cell_definition( "neutrophil" );
static int proinflammatory_cytokine_index = microenvironment.find_density_index( "pro-inflammatory cytokine");
static int debris_index = microenvironment.find_density_index( "debris" );
static int chemokine_index = microenvironment.find_density_index( "chemokine");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// check for cells to eat
std::vector<Cell*> neighbors = pCell->cells_in_my_container();
// at least one of the cells is pCell
if( neighbors.size() < 2 )
{ return; }
// (Adrianne) if neutrophil volume exceeds a threshold value we say it is "exhausted" and unable to phagocytose until it's volume drops below this threshold
if( pCell->phenotype.volume.total> pCell->custom_data["threshold_neutrophil_volume"])
{return;}
// (Adrianne) obtain index for tracking time to next phagocytosis event is possible
int time_to_next_phagocytosis_index = pCell->custom_data.find_variable_index( "time_to_next_phagocytosis" );
// (Adrianne) check if still phagocytosing something, added if statement to say that if cell is still internalising current material not to phagocytose anything else
if( pCell->custom_data.variables[time_to_next_phagocytosis_index].value>PhysiCell_globals.current_time )
{return;}
int n = 0;
Cell* pTestCell = neighbors[n];
double probability_of_phagocytosis = pCell->custom_data["phagocytosis_rate"] * dt;
double max_phagocytosis_volume = pCell->custom_data["phagocytosis_relative_target_cutoff_size" ] * pCD->phenotype.volume.total;
// (Adrianne) add an additional variable that is the time taken to ingest material
double material_internalisation_rate = pCell->custom_data["material_internalisation_rate"];
while( n < neighbors.size() )
{
pTestCell = neighbors[n];
// if it is not me and the target is dead
if( pTestCell != pCell && pTestCell->phenotype.death.dead == true &&
UniformRandom() < probability_of_phagocytosis &&
pTestCell->phenotype.volume.total < max_phagocytosis_volume )
{
// #pragma omp critical(neutrophil_eat)
{
// (Adrianne) obtain volume of cell to be ingested
double volume_ingested_cell = pTestCell->phenotype.volume.total;
// remove_all_adhesions( pTestCell ); // debug
pCell->ingest_cell( pTestCell );
// (Adrianne)(assume neutrophils same as macrophages) neutrophils phagocytose material 1micron3/s so macrophage cannot phagocytose again until it has elapsed the time taken to phagocytose the material
double time_to_ingest = volume_ingested_cell*material_internalisation_rate;// convert volume to time taken to phagocytose
// (Adrianne) update internal time vector in macrophages that tracks time it will spend phagocytosing the material so they can't phagocytose again until this time has elapsed
pCell->custom_data.variables[time_to_next_phagocytosis_index].value = PhysiCell_globals.current_time+time_to_ingest;
}
// activate the cell
phenotype.secretion.secretion_rates[proinflammatory_cytokine_index] =
pCell->custom_data["activated_cytokine_secretion_rate"]; // 10;
phenotype.secretion.saturation_densities[proinflammatory_cytokine_index] = 1;
phenotype.motility.migration_speed = pCell->custom_data["activated_speed"];
pCell->custom_data["activated_immune_cell"] = 1.0;
return;
}
n++;
}
// if neutrophil isn't killing any cell then return to normal speed
// pCell->phenotype.motility.migration_speed =
// pCell->custom_data["normal_neutrophil_speed"];
return;
}
void neutrophil_mechanics( Cell* pCell, Phenotype& phenotype, double dt )
{
static int debris_index = microenvironment.find_density_index( "debris");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// bounds check
if( check_for_out_of_bounds( pCell , 10.0 ) )
{
#pragma omp critical
{ cells_to_move_from_edge.push_back( pCell ); }
// replace_out_of_bounds_cell( pCell, 10.0 );
// return;
}
// // death check
// if( phenotype.death.dead == true )
// { remove_all_adhesions( pCell ); }
return;
}
// (Adrianne) DC phenotype function
void DC_phenotype( Cell* pCell, Phenotype& phenotype, double dt )
{
// (Adrianne) probability of activated DC departing after activation
double time_of_DC_departure = pCell->custom_data["time_of_DC_departure"];
// (Adrianne) get type of CD8+ T cell
static int CD8_Tcell_type = get_cell_definition( "CD8 Tcell" ).type;
// (Adrianne) if DC is already activated, then check whether it leaves the tissue
if( pCell->custom_data["activated_immune_cell"] == 1 && PhysiCell_globals.current_time >= time_of_DC_departure)
{
// (Adrianne) DC leaves the tissue and so we delete that DC
delete_cell( pCell );
std::cout<<"DC leaves tissue"<<std::endl;
return;
}
else if( pCell->custom_data["activated_immune_cell"] == 1 && PhysiCell_globals.current_time < time_of_DC_departure) // (Adrianne) activated DCs that don't leave the tissue can further activate CD8s increasing their proliferation rate and attachment rates
{
std::vector<Cell*> neighbors = pCell->cells_in_my_container(); // (Adrianne) find cells in a neighbourhood of DCs
int n = 0;
Cell* pTestCell = neighbors[n];
while( n < neighbors.size() )
{
pTestCell = neighbors[n];
// if it is not me and the target is dead
if( pTestCell != pCell && pTestCell->phenotype.death.dead == false && pTestCell->type == CD8_Tcell_type ) // (Adrianne) check if any neighbour cells are live T cells
{
pTestCell-> custom_data["cell_attachment_rate"] = parameters.doubles("DC_induced_CD8_attachment"); // (Adrianne) DC induced T cell attachement rate
// (Adrianne) finding the G0G1 and S phase index and setting the transition rate to be non zero so that CD8 T cells start proliferating after interacting with DC
int cycle_G0G1_index = Ki67_basic.find_phase_index( PhysiCell_constants::G0G1_phase );
int cycle_S_index = Ki67_basic.find_phase_index( PhysiCell_constants::S_phase );
pCell->phenotype.cycle.data.transition_rate(cycle_G0G1_index,cycle_S_index) = parameters.doubles("DC_induced_CD8_proliferation");
//(Adrianne) double proliferation rate
std::cout<<"DC further activates T cell"<<std::endl;
return;
}
n++;
}
return;
}
else
{
// (adrianne) DCs become activated if there is an infected cell in their neighbour with greater 1 viral protein or if the local amount of virus is greater than 10
static int virus_index = microenvironment.find_density_index("virion");
double virus_amount = pCell->nearest_density_vector()[virus_index];
if( virus_amount*microenvironment.mesh.voxels[1].volume > 10) // (Adrianne) amount of virus in local voxel with DC is greater than 10
{
pCell->custom_data["activated_immune_cell"] = 1.0; // (Adrianne) DC becomes activated
std::cout<<"DC becomes activated by virus"<<std::endl;
}
else //(Adrianne) check for infected cells nearby
{
std::vector<Cell*> neighbors = pCell->cells_in_my_container();
int n = 0;
Cell* pTestCell = neighbors[n];
int nP = pTestCell->custom_data.find_variable_index( "viral_protein" ); //(Adrianne) finding the viral protein inside cells
while( n < neighbors.size() )
{
pTestCell = neighbors[n];
// if it is not me and the target is dead
if( pTestCell != pCell && pTestCell->phenotype.death.dead == false && pTestCell->custom_data[nP]>1 )
{
pCell->custom_data["activated_immune_cell"] = 1.0;
pCell->custom_data["time_of_DC_departure"] = PhysiCell_globals.current_time+(23*UniformRandom()+1)*60; // (Adrianne) calculating the time till DC exits the tissue uniform random vairable between 1 and 24
std::cout<<"DC becomes activated by infected cell and leaves at "<<pCell->custom_data["time_of_DC_departure"]<<std::endl;
return;
}
n++;
}
}
}
return;
}
// (Adrianne) DC mechanics function
void DC_mechanics( Cell* pCell, Phenotype& phenotype, double dt )
{
static int debris_index = microenvironment.find_density_index( "debris");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// bounds check
if( check_for_out_of_bounds( pCell , 10.0 ) )
{
#pragma omp critical
{ cells_to_move_from_edge.push_back( pCell ); }
// replace_out_of_bounds_cell( pCell, 10.0 );
// return;
}
// // death check
// if( phenotype.death.dead == true )
// { remove_all_adhesions( pCell ); }
return;
}
// (Adrianne CD4 phenotype function
void CD4_Tcell_phenotype( Cell* pCell, Phenotype& phenotype, double dt )
{
//(Adrianne) currently CD4's don't have any rules
return;
}
// (Adrianne) CD4 mechanics function
void CD4_Tcell_mechanics( Cell* pCell, Phenotype& phenotype, double dt )
{
static int debris_index = microenvironment.find_density_index( "debris");
if( phenotype.death.dead == true )
{
pCell->functions.update_phenotype = NULL;
pCell->functions.custom_cell_rule = NULL;
phenotype.secretion.secretion_rates[debris_index] = pCell->custom_data["debris_secretion_rate"];
return;
}
// bounds check
if( check_for_out_of_bounds( pCell , 10.0 ) )
{
#pragma omp critical
{ cells_to_move_from_edge.push_back( pCell ); }
// replace_out_of_bounds_cell( pCell, 10.0 );
// return;
}
// // death check
// if( phenotype.death.dead == true )
// { remove_all_adhesions( pCell ); }
return;
}
void immune_submodels_setup( void )
{
Cell_Definition* pCD;
//
// set up CD8 Tcells
// set version info
CD8_submodel_info.name = "CD8 Tcell model";
CD8_submodel_info.version = immune_submodels_version;
// set functions
CD8_submodel_info.main_function = NULL;
CD8_submodel_info.phenotype_function = CD8_Tcell_phenotype;
CD8_submodel_info.mechanics_function = CD8_Tcell_mechanics;
// what microenvironment variables do you expect?
CD8_submodel_info.microenvironment_variables.push_back( "virion" );
CD8_submodel_info.microenvironment_variables.push_back( "interferon 1" );
CD8_submodel_info.microenvironment_variables.push_back( "pro-inflammatory cytokine" );
CD8_submodel_info.microenvironment_variables.push_back( "chemokine" );
// what custom data do I need?
//CD8_submodel_info.cell_variables.push_back( "something" );
// register the submodel
CD8_submodel_info.register_model();
// set functions for the corresponding cell definition
pCD = find_cell_definition( "CD8 Tcell" );
pCD->functions.update_phenotype = CD8_submodel_info.phenotype_function;
pCD->functions.custom_cell_rule = CD8_submodel_info.mechanics_function;
pCD->functions.contact_function = CD8_Tcell_contact_function;
// set up macrophages
Macrophage_submodel_info = CD8_submodel_info; // much shared information
// set version info
Macrophage_submodel_info.name = "macrophage model";
Macrophage_submodel_info.version = immune_submodels_version;
// set functions
Macrophage_submodel_info.main_function = NULL;