-
Notifications
You must be signed in to change notification settings - Fork 1
/
spaceless.sim.py
executable file
·71 lines (60 loc) · 1.77 KB
/
spaceless.sim.py
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
#!/usr/bin/env python
from spaceless import Toys
from spaceless.Model import pDivisionFunction
from spaceless import Post
import time
import matplotlib.pyplot as plt
import numpy as np
import csv
import sys
if len(sys.argv) < 6:
print """
You must supply the following:
MODEL_TYPE: {CSCSD, MD, SD, CSCMD}
INIT_STEPS: INT
POST_STEPS: INT
AUTO_REDUCE_MAGNITUDE
SAVE_DIR: DIRECTOR
"""
else:
MODEL_TYPE = str(sys.argv[1])
INIT_STEPS = int(sys.argv[2])
POST_STEPS = int(sys.argv[3])
AUTO_REDUCE_MAGNITUDE = float(sys.argv[4])
SAVE_DIR = str(sys.argv[5])
arguments = {
'mean_mutations': 50,
'update_mean_mutations':120,
'init_steps': INIT_STEPS,
'post_steps': POST_STEPS,
'auto_reduce_magnitude': AUTO_REDUCE_MAGNITUDE
}
print 'MODEL_TYPE',MODEL_TYPE
print 'ARGUMENTS',arguments
if MODEL_TYPE == 'SD':
builder = Toys.build_SD
elif MODEL_TYPE == 'MD':
builder = Toys.build_MD
elif MODEL_TYPE == 'CSCMD':
builder = Toys.build_CSC_reg
arguments.update({
'p_division_function': pDivisionFunction.sigmoid()
})
elif MODEL_TYPE == 'CSCSD':
builder = Toys.build_CSC_reg
sim = builder(**arguments)
sim.sort_genomes()
file_name = './spaceless_data/'+MODEL_TYPE+'.'+str(INIT_STEPS)+'.'+str(POST_STEPS)+'.'+str(AUTO_REDUCE_MAGNITUDE)+'.'+time.ctime()
vals = Toys.regular_processor(sim, subsample=100, max_iteration=150, iteration_magnitude=100, thresholds=[0, 0.00001, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1])
# print sim.sorted_genomes
print '-----'
print vals
with open(file_name+'stats.csv', 'w') as f:
writer = csv.writer(f)
for val in vals:
writer.writerow(val)
print '----'
print 'total_cells:',len(sim.cells)
print 'cancer_cells:',len(sim.sorted_genomes['cancer'])
print 'normal_cells:',len(sim.sorted_genomes['normal'])
print '-----'