Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/*.ipynb_checkpoints
**/*.egg-info
**/__pycache__
2,023 changes: 2,023 additions & 0 deletions examples/.ipynb_checkpoints/example_simulation-checkpoint.ipynb

Large diffs are not rendered by default.

1,911 changes: 1,901 additions & 10 deletions examples/example_simulation.ipynb

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions examples/test_M1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import itertools
# get_ipython().magic(u'matplotlib inline')
import numpy as np
import matplotlib
# %matplotlib qt5
import matplotlib.pyplot as plt
from matplotlib import animation, rc
# from IPython.display import HTML
import vertex_model as model
from vertex_model.run_select import run_simulation_INM, definecolors
import vertex_model.initialisation as init
import sys

import time
import dill


type_=4

# parameters of the vertex model
G=0.075
L=0.04
K=1.0

# parameters of the nucleus A-B stochastic dynamics
# sys.argv to pass from command line
# call as, e.g.: python test_M1.py 100 0.15
try:
k=float(sys.argv[1]) # 100
D=float(sys.argv[2]) # 0.15
r=float(sys.argv[3])
except:
print("Missing command line parameters. Execute as\n")
print(" python test_M1.py <k> <D> <r = a/k>\n")
exit()

# parameters of the crowding force
s=0.2
a=r*k

# adding the nuclear movement parameters to 'params'
params = [K,G,L,k,D,s,a]

def run_sim (run_id):
timestart = time.time()
history = run_simulation_INM(params,1,rand,type_) # timend = 1 for test
timeend = time.time()

with open (f"model_1_k{k}_D{D}_run_{run_id}.pkl", "wb") as file:
dill.dump(history, file)

return timeend - timestart

np.random.seed(1999)
rand = np.random.RandomState(1999)
no_simulations = 5

for run in range(1,no_simulations+1):
run_sim(run)




44 changes: 44 additions & 0 deletions examples/test_M1_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import itertools
import numpy as np
import matplotlib.pyplot as plt
import vertex_model as model
import vertex_model.initialisation as init
from vertex_model.forces import TargetArea, Tension, Perimeter, Pressure

import dill
with open("history_model_1.pkl", "rb") as file:
history = dill.load(file)

last = history[-1]

# Cell cycle length
"""
deadcells = np.where(last.empty())[0]
cell_cycle_lengths = last.properties['age'][deadcells]
plt.hist(cell_cycle_lengths, bins = 50, density=True)
plt.title('Cell cycle length distribution Model 1')
plt.show()
"""


"""
plt.hist(last.properties['nucl_pos'], bins = 50)
plt.xlim(0,1)
plt.title("Nucleus position Model 1")
plt.show()
"""

alivecells = np.where(~last.empty())[0]


plt.hist(last.mesh.area[alivecells], bins = 50)
plt.title('Last Area Distribution Model 1')
plt.show()



print(len(alivecells))
print(len(last.mesh.area))
print(len(last.mesh.area[alivecells]))


82 changes: 82 additions & 0 deletions examples/test_M2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import itertools
# get_ipython().magic(u'matplotlib inline')
import numpy as np
import matplotlib
# %matplotlib qt5
import matplotlib.pyplot as plt
from matplotlib import animation, rc
# from IPython.display import HTML
import vertex_model as model
from vertex_model.run_select import run_simulation_INM, definecolors
import vertex_model.initialisation as init
import sys

import time
timestart = time.time()

type_=5

# parameters of the vertex model
G=0.075
L=0.04
K=1.0

# parameters of the nucleus A-B stochastic dynamics
# sys.argv to pass from command line
# call as, e.g.: python test_M1.py 100 0.15
k=float(sys.argv[1]) # 100
D=float(sys.argv[2]) # 0.15

# parameters of the crowding force
s=0.2
a=1.

# adding the nuclear movement parameters to 'params'
params = [K,G,L,k,D,s,a]

np.random.seed(1999)
rand = np.random.RandomState(1999)

no_simulations = 1
#Cell_cycle_lengths_progenitors = []
#Cell_cycle_lengths_pois = []
#final_history = []
for i in range(no_simulations):
history = run_simulation_INM(params,1,rand,type_) # timend = 1 for test
# Rows 32-49 -> copy in ANALYSIS
"""
last = history[-1] # get state of the cells object from the previous step -> this + following rows -> analysis
gone = last.empty()
divided = gone
diffntd = gone
if 'poisoned' in last.properties:
pois = last.properties['poisoned']==1
healty = last.properties['poisoned']==0
divided = gone & healty
diffntd = gone & pois
progenitor_deadcells_last = np.where(divided)[0]
differentiated_last = np.where(diffntd)[0]
correct_cell_cycle_lengths = last.properties['age'][progenitor_deadcells_last]
pois_cell_cycle_lengths = last.properties['age'][differentiated_last]

#new_cell_cycle_lengths = last.properties['age'][deadcells_last] # cell cycle lengths = age of deadcells
Cell_cycle_lengths_progenitors = np.append(Cell_cycle_lengths_progenitors, correct_cell_cycle_lengths)
Cell_cycle_lengths_pois = np.append(Cell_cycle_lengths_pois, pois_cell_cycle_lengths)
final_history = np.append(final_history, history) # get a final history array

print(last.properties['nucl_pos'])
print(min(last.properties['nucl_pos']))
print(max(last.properties['nucl_pos']))
print(last.properties['A0_final'])
print(len(last.properties['final_nucl_pos']))
"""

timeend = time.time()
print(timeend - timestart)

import dill
with open ("history_model_2.pkl", "wb") as file:
dill.dump(history, file)



37 changes: 37 additions & 0 deletions examples/test_M2_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import itertools
import numpy as np
import matplotlib.pyplot as plt
import vertex_model as model
import vertex_model.initialisation as init
from vertex_model.forces import TargetArea, Tension, Perimeter, Pressure

import dill
with open("history_model_2.pkl", "rb") as file:
history = dill.load(file)

last = history[-1]

# Cell cycle length
"""
deadcells = np.where(last.empty())[0]
cell_cycle_lengths = last.properties['age'][deadcells]
plt.hist(cell_cycle_lengths, bins = 50, density=True)
plt.title('Cell cycle length distribution Model 2')
plt.show()
"""


"""
plt.hist(last.properties['nucl_pos'], bins = 50)
plt.xlim(0,1)
plt.title("Nucleus position Model 2")
plt.show()
"""

#alivecells = np.where(~last.empty())[0]
plt.hist(last.mesh.area, bins = 50)
plt.title('Last Area Distribution Model 2')
plt.show()



Loading