pyLoopSage 1.1.0__tar.gz → 1.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyloopsage-1.1.0/pyLoopSage.egg-info → pyloopsage-1.1.3}/PKG-INFO +5 -4
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/README.md +3 -2
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/__init__.py +1 -1
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/args_definition.py +1 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/run.py +2 -1
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/stochastic_simulation.py +36 -28
- {pyloopsage-1.1.0 → pyloopsage-1.1.3/pyLoopSage.egg-info}/PKG-INFO +5 -4
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/pyLoopSage.egg-info/requires.txt +1 -1
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/setup.py +2 -2
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/LICENSE +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/MANIFEST.in +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/em.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/forcefields/classic_sm_ff.xml +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/initial_structures.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/md.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/plots.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/preproc.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/utils.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/loopsage/vizualization_tools.py +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/pyLoopSage.egg-info/SOURCES.txt +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/pyLoopSage.egg-info/dependency_links.txt +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/pyLoopSage.egg-info/entry_points.txt +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/pyLoopSage.egg-info/top_level.txt +0 -0
- {pyloopsage-1.1.0 → pyloopsage-1.1.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyLoopSage
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
4
4
|
Summary: An energy-based stochastic model of loop extrusion in chromatin.
|
|
5
5
|
Home-page: https://github.com/SFGLab/pyLoopSage
|
|
6
6
|
Author: Sebastian Korsak
|
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: POSIX :: Linux
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: numpy<2.0,>1.2
|
|
16
16
|
Requires-Dist: numba
|
|
17
17
|
Requires-Dist: scipy
|
|
18
18
|
Requires-Dist: pandas
|
|
@@ -304,6 +304,8 @@ An example, illustrated with Chimera software, simulated trajectory of structure
|
|
|
304
304
|
| LEF_DRIFT | True if LEFs are pushed back when they encounter other LEFs. | bool | False |
|
|
305
305
|
| N_LEF | Number of loop extrusion factors. | int | None |
|
|
306
306
|
| N_LEF2 | Number of second family loop extrusion factors. | int | 0 |
|
|
307
|
+
| CROSS_LOOP | True if the penalty is applied when mi<mj<ni<nj. False if it applies only when mj=ni. When false it is better to enable LEF_DRIFT as well. | bool |True |
|
|
308
|
+
| BETWEEN_FAMILIES_PENALTY | Penalty applied when loops from different LEF families cross. | bool | True |
|
|
307
309
|
|
|
308
310
|
#### Energy Coefficients
|
|
309
311
|
| Argument Name | Description | Type | Default Value |
|
|
@@ -311,9 +313,8 @@ An example, illustrated with Chimera software, simulated trajectory of structure
|
|
|
311
313
|
| FOLDING_COEFF | Folding coefficient. | float | 1.0 |
|
|
312
314
|
| FOLDING_COEFF2 | Folding coefficient for the second family of LEFs. | float | 0.0 |
|
|
313
315
|
| CROSS_COEFF | LEF crossing coefficient. | float | 1.0 |
|
|
314
|
-
| CROSS_LOOP | True if the penalty is applied when mi<mj<ni<nj. False if it applies only when mj=ni. When false it is better to enable LEF_DRIFT as well. | bool |True |
|
|
315
316
|
| BIND_COEFF | CTCF binding coefficient. | float | 1.0 |
|
|
316
|
-
| BW_STRENGTHS | List of strengths corresponding to each
|
|
317
|
+
| BW_STRENGTHS | List of strengths of the energy (floats) corresponding to each BW file. This equivalent to the `r` parameter in the LoopSage paper. | list | None |
|
|
317
318
|
|
|
318
319
|
#### Molecular Dynamics Simulation
|
|
319
320
|
| Argument Name | Description | Type | Default Value |
|
|
@@ -258,6 +258,8 @@ An example, illustrated with Chimera software, simulated trajectory of structure
|
|
|
258
258
|
| LEF_DRIFT | True if LEFs are pushed back when they encounter other LEFs. | bool | False |
|
|
259
259
|
| N_LEF | Number of loop extrusion factors. | int | None |
|
|
260
260
|
| N_LEF2 | Number of second family loop extrusion factors. | int | 0 |
|
|
261
|
+
| CROSS_LOOP | True if the penalty is applied when mi<mj<ni<nj. False if it applies only when mj=ni. When false it is better to enable LEF_DRIFT as well. | bool |True |
|
|
262
|
+
| BETWEEN_FAMILIES_PENALTY | Penalty applied when loops from different LEF families cross. | bool | True |
|
|
261
263
|
|
|
262
264
|
#### Energy Coefficients
|
|
263
265
|
| Argument Name | Description | Type | Default Value |
|
|
@@ -265,9 +267,8 @@ An example, illustrated with Chimera software, simulated trajectory of structure
|
|
|
265
267
|
| FOLDING_COEFF | Folding coefficient. | float | 1.0 |
|
|
266
268
|
| FOLDING_COEFF2 | Folding coefficient for the second family of LEFs. | float | 0.0 |
|
|
267
269
|
| CROSS_COEFF | LEF crossing coefficient. | float | 1.0 |
|
|
268
|
-
| CROSS_LOOP | True if the penalty is applied when mi<mj<ni<nj. False if it applies only when mj=ni. When false it is better to enable LEF_DRIFT as well. | bool |True |
|
|
269
270
|
| BIND_COEFF | CTCF binding coefficient. | float | 1.0 |
|
|
270
|
-
| BW_STRENGTHS | List of strengths corresponding to each
|
|
271
|
+
| BW_STRENGTHS | List of strengths of the energy (floats) corresponding to each BW file. This equivalent to the `r` parameter in the LoopSage paper. | list | None |
|
|
271
272
|
|
|
272
273
|
#### Molecular Dynamics Simulation
|
|
273
274
|
| Argument Name | Description | Type | Default Value |
|
|
@@ -192,6 +192,7 @@ args = ListOfArgs([
|
|
|
192
192
|
Arg('CROSS_COEFF', help="LEF crossing coefficient.", type=float, default='1.0', val='1.0'),
|
|
193
193
|
Arg('BW_STRENGTHS', help="List of strengths of the energy (floats) corresponding to each BW file. This equivalent to the `r` parameter in the LoopSage paper.", type=list, nargs='+', default=[], val=[]),
|
|
194
194
|
Arg('CROSS_LOOP', help="It true if the penalty is applied for situations mi<mj<ni<nj and mi=nj, and false if it is applied only for mi=nj.", type=bool, default='True', val='True'),
|
|
195
|
+
Arg('BETWEEN_FAMILIES_PENALTY', help="Penalty for LEF2s that are crossing LEFs.", type=bool, default='True', val='True'),
|
|
195
196
|
Arg('BIND_COEFF', help="CTCF binding coefficient.", type=float, default='1.0', val='1.0'),
|
|
196
197
|
Arg('SAVE_PLOTS', help="It should be true in case that you would like to save diagnostic plots. In case that you use small MC_STEP or large N_STEPS is better to mark it as False.", type=bool, default='True', val='True'),
|
|
197
198
|
Arg('SAVE_MDT', help="In case that you would liketo save metadata of the stochastic simulation.", type=bool, default='True', val='True'),
|
|
@@ -74,6 +74,7 @@ def main():
|
|
|
74
74
|
# Simulation Strengths
|
|
75
75
|
f, f2, b, kappa = args.FOLDING_COEFF, args.FOLDING_COEFF2, args.BIND_COEFF, args.CROSS_COEFF
|
|
76
76
|
r = args.BW_STRENGTHS
|
|
77
|
+
between_families_penalty = args.BETWEEN_FAMILIES_PENALTY # Added argument
|
|
77
78
|
|
|
78
79
|
# Definition of region
|
|
79
80
|
region, chrom = [args.REGION_START,args.REGION_END], args.CHROM
|
|
@@ -84,7 +85,7 @@ def main():
|
|
|
84
85
|
|
|
85
86
|
# Run Simulation
|
|
86
87
|
sim = StochasticSimulation(region,chrom,bedpe_file,out_dir=output_name,N_beads=N_beads,N_lef=N_lef,N_lef2=N_lef2, bw_files=bw_paths, track_file=args.LEF_TRACK_FILE)
|
|
87
|
-
Es, Ms, Ns, Bs, Ks, Fs, ufs = sim.run_energy_minimization(N_steps,MC_step,burnin,T,T_min,mode=mode,viz=args.SAVE_PLOTS,save=args.SAVE_MDT,lef_rw=args.LEF_RW,f=f,f2=f2,b=b,kappa=kappa,lef_drift=args.LEF_DRIFT,cross_loop=args.CROSS_LOOP,r=r)
|
|
88
|
+
Es, Ms, Ns, Bs, Ks, Fs, ufs = sim.run_energy_minimization(N_steps,MC_step,burnin,T,T_min,mode=mode,viz=args.SAVE_PLOTS,save=args.SAVE_MDT,lef_rw=args.LEF_RW,f=f,f2=f2,b=b,kappa=kappa,lef_drift=args.LEF_DRIFT,cross_loop=args.CROSS_LOOP,r=r,between_families_penalty=between_families_penalty)
|
|
88
89
|
if args.SIMULATION_TYPE=='EM':
|
|
89
90
|
sim.run_EM(args.PLATFORM,args.ANGLE_FF_STRENGTH,args.LE_FF_LENGTH,args.LE_FF_STRENGTH,args.EV_FF_STRENGTH,args.EV_FF_POWER,args.TOLERANCE,args.FRICTION,args.INTEGRATOR_STEP,args.SIM_TEMP,args.INITIAL_STRUCTURE_TYPE,args.VIZ_HEATS,args.FORCEFIELD_PATH)
|
|
90
91
|
elif args.SIMULATION_TYPE=='MD':
|
|
@@ -47,14 +47,15 @@ def E_bind(L, R, ms, ns, bind_norm):
|
|
|
47
47
|
return E_b
|
|
48
48
|
|
|
49
49
|
@njit
|
|
50
|
-
def E_cross(ms, ns, k_norm, cross_loop):
|
|
50
|
+
def E_cross(ms, ns, k_norm, N_lef, cross_loop=True, between_families_penalty=True):
|
|
51
51
|
'''
|
|
52
52
|
The crossing energy.
|
|
53
53
|
'''
|
|
54
54
|
crossing = 0.0
|
|
55
55
|
for i in prange(len(ms)):
|
|
56
56
|
for j in range(i + 1, len(ms)):
|
|
57
|
-
|
|
57
|
+
if between_families_penalty or (i < N_lef and j < N_lef) or (i >= N_lef and j >= N_lef):
|
|
58
|
+
crossing += Kappa(ms[i], ns[i], ms[j], ns[j], cross_loop)
|
|
58
59
|
return k_norm * crossing
|
|
59
60
|
|
|
60
61
|
@njit
|
|
@@ -76,11 +77,11 @@ def E_bw(N_bws, r, BWs, ms, ns):
|
|
|
76
77
|
return E_bw
|
|
77
78
|
|
|
78
79
|
@njit
|
|
79
|
-
def get_E(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, N_lef, N_lef2, cross_loop, r=None, N_bws=0, BWs=None):
|
|
80
|
+
def get_E(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, N_lef, N_lef2, cross_loop, r=None, N_bws=0, BWs=None, between_families_penalty=True):
|
|
80
81
|
''''
|
|
81
82
|
The total energy.
|
|
82
83
|
'''
|
|
83
|
-
energy = E_bind(L, R, ms, ns, bind_norm) + E_cross(ms, ns, k_norm, cross_loop) + E_fold(ms, ns, fold_norm)
|
|
84
|
+
energy = E_bind(L, R, ms, ns, bind_norm) + E_cross(ms, ns, k_norm, cross_loop, between_families_penalty) + E_fold(ms, ns, fold_norm)
|
|
84
85
|
if fold_norm2!=0: energy += E_fold(ms[N_lef:N_lef+N_lef2],ns[N_lef:N_lef+N_lef2], fold_norm2)
|
|
85
86
|
if r is not None and BWs is not None: energy += E_bw(N_bws, r, BWs, ms, ns)
|
|
86
87
|
return energy
|
|
@@ -107,19 +108,20 @@ def get_dE_bw(N_bws, r, BWs, ms, ns, m_new, n_new, idx):
|
|
|
107
108
|
return dE_bw
|
|
108
109
|
|
|
109
110
|
@njit
|
|
110
|
-
def get_dE_cross(ms, ns, m_new, n_new, idx, k_norm, cross_loop):
|
|
111
|
+
def get_dE_cross(ms, ns, m_new, n_new, idx, k_norm, cross_loop, N_lef, between_families_penalty):
|
|
111
112
|
'''
|
|
112
113
|
Energy difference for crossing energy.
|
|
113
114
|
'''
|
|
114
115
|
K1, K2 = 0, 0
|
|
115
116
|
for i in prange(len(ms)):
|
|
116
117
|
if i != idx:
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
if between_families_penalty or (idx < N_lef and i < N_lef) or (idx >= N_lef and i >= N_lef):
|
|
119
|
+
K1 += Kappa(ms[idx], ns[idx], ms[i], ns[i], cross_loop)
|
|
120
|
+
K2 += Kappa(m_new, n_new, ms[i], ns[i], cross_loop)
|
|
119
121
|
return k_norm * (K2 - K1)
|
|
120
122
|
|
|
121
123
|
@njit
|
|
122
|
-
def get_dE(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, m_new, n_new, idx, N_lef, N_lef2, cross_loop, r=None, N_bws=0, BWs=None):
|
|
124
|
+
def get_dE(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, m_new, n_new, idx, N_lef, N_lef2, cross_loop, r=None, N_bws=0, BWs=None, between_families_penalty=True):
|
|
123
125
|
'''
|
|
124
126
|
Total energy difference.
|
|
125
127
|
'''
|
|
@@ -129,7 +131,7 @@ def get_dE(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, m_new, n_new,
|
|
|
129
131
|
else:
|
|
130
132
|
dE += get_dE_fold(fold_norm2,ms[N_lef:N_lef+N_lef2],ns[N_lef:N_lef+N_lef2],m_new,n_new,idx-N_lef)
|
|
131
133
|
dE += get_dE_bind(L, R, bind_norm, ms, ns, m_new, n_new, idx)
|
|
132
|
-
dE += get_dE_cross(ms, ns, m_new, n_new, idx, k_norm, cross_loop)
|
|
134
|
+
dE += get_dE_cross(ms, ns, m_new, n_new, idx, k_norm, cross_loop, N_lef, between_families_penalty)
|
|
133
135
|
if r is not None and BWs is not None: dE += get_dE_bw(N_bws, r, BWs, ms, ns, m_new, n_new, idx)
|
|
134
136
|
return dE
|
|
135
137
|
|
|
@@ -154,12 +156,12 @@ def slide(m_old, n_old, ms, ns, N_beads, rw=True, drift=True):
|
|
|
154
156
|
choices = np.array([-1, 1], dtype=np.int64)
|
|
155
157
|
r1 = np.random.choice(choices) if rw else -1
|
|
156
158
|
r2 = np.random.choice(choices) if rw else 1
|
|
157
|
-
m_new = m_old + r1
|
|
158
|
-
if np.any(ns==m_new) and drift and m_old-r1<n_old-1:
|
|
159
|
-
m_new =
|
|
160
|
-
n_new = n_old + r2
|
|
161
|
-
if np.any(ms==n_new) and drift and n_old-r2>m_old+1:
|
|
162
|
-
n_new =
|
|
159
|
+
m_new = max(m_old + r1, 0)
|
|
160
|
+
if np.any(ns == m_new) and drift and m_old - r1 < n_old - 1:
|
|
161
|
+
m_new = max(m_old - r1, 0)
|
|
162
|
+
n_new = min(n_old + r2, N_beads - 1)
|
|
163
|
+
if np.any(ms == n_new) and drift and n_old - r2 > m_old + 1:
|
|
164
|
+
n_new = min(n_old - r2, N_beads - 1)
|
|
163
165
|
return int(m_new), int(n_new)
|
|
164
166
|
|
|
165
167
|
@njit
|
|
@@ -185,14 +187,14 @@ def initialize(N_beads, N_lef, track=None):
|
|
|
185
187
|
return ms, ns
|
|
186
188
|
|
|
187
189
|
@njit
|
|
188
|
-
def run_simulation(N_beads, N_steps, MC_step, burnin, T, T_min, fold_norm, fold_norm2, bind_norm, k_norm, N_lef, N_lef2, L, R, mode, lef_rw=True, lef_drift=True, cross_loop=True, r=None, N_bws=0, BWs=None, track=None):
|
|
190
|
+
def run_simulation(N_beads, N_steps, MC_step, burnin, T, T_min, fold_norm, fold_norm2, bind_norm, k_norm, N_lef, N_lef2, L, R, mode, lef_rw=True, lef_drift=True, cross_loop=True, r=None, N_bws=0, BWs=None, track=None, between_families_penalty=True):
|
|
189
191
|
'''
|
|
190
192
|
Runs the Monte Carlo simulation.
|
|
191
193
|
'''
|
|
192
194
|
Ti = T
|
|
193
195
|
bi = burnin // MC_step
|
|
194
196
|
ms, ns = initialize(N_beads, N_lef + N_lef2, track)
|
|
195
|
-
E = get_E(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, N_lef, N_lef2, cross_loop, r, N_bws, BWs)
|
|
197
|
+
E = get_E(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, N_lef, N_lef2, cross_loop, r, N_bws, BWs, between_families_penalty)
|
|
196
198
|
Es, Ks, Fs, Bs, ufs = np.zeros(N_steps // MC_step, dtype=np.float64), np.zeros(N_steps // MC_step, dtype=np.float64), np.zeros(N_steps // MC_step, dtype=np.float64), np.zeros(N_steps // MC_step, dtype=np.float64), np.zeros(N_steps // MC_step, dtype=np.float64)
|
|
197
199
|
Ms, Ns = np.zeros((N_lef + N_lef2, N_steps // MC_step), dtype=np.int64), np.zeros((N_lef + N_lef2, N_steps // MC_step), dtype=np.int64)
|
|
198
200
|
|
|
@@ -207,7 +209,7 @@ def run_simulation(N_beads, N_steps, MC_step, burnin, T, T_min, fold_norm, fold_
|
|
|
207
209
|
m_new, n_new = slide(ms[j], ns[j], ms, ns, N_beads, lef_rw, lef_drift)
|
|
208
210
|
|
|
209
211
|
# Compute energy difference
|
|
210
|
-
dE = get_dE(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, m_new, n_new, j, N_lef, N_lef2, cross_loop, r, N_bws, BWs)
|
|
212
|
+
dE = get_dE(L, R, bind_norm, fold_norm, fold_norm2, k_norm, ms, ns, m_new, n_new, j, N_lef, N_lef2, cross_loop, r, N_bws, BWs, between_families_penalty)
|
|
211
213
|
|
|
212
214
|
if dE <= 0 or np.exp(-dE / Ti) > np.random.rand():
|
|
213
215
|
ms[j], ns[j] = m_new, n_new
|
|
@@ -220,7 +222,7 @@ def run_simulation(N_beads, N_steps, MC_step, burnin, T, T_min, fold_norm, fold_
|
|
|
220
222
|
if i % MC_step == 0:
|
|
221
223
|
ufs[i // MC_step] = unfolding_metric(ms, ns, N_beads)
|
|
222
224
|
Es[i // MC_step] = E
|
|
223
|
-
Ks[i // MC_step] = E_cross(ms, ns, k_norm, cross_loop)
|
|
225
|
+
Ks[i // MC_step] = E_cross(ms, ns, k_norm, cross_loop, N_lef, between_families_penalty)
|
|
224
226
|
Fs[i // MC_step] = E_fold(ms, ns, fold_norm)
|
|
225
227
|
Bs[i // MC_step] = E_bind(L, R, ms, ns, bind_norm)
|
|
226
228
|
return Ms, Ns, Es, Ks, Fs, Bs, ufs
|
|
@@ -251,7 +253,7 @@ class StochasticSimulation:
|
|
|
251
253
|
print('Number of LEFs:',self.N_lef+self.N_lef2)
|
|
252
254
|
self.path = make_folder(out_dir)
|
|
253
255
|
|
|
254
|
-
def run_energy_minimization(self, N_steps, MC_step, burnin, T=1, T_min=0, mode='Metropolis', viz=False, save=False, f=1.0, f2=0.0, b=1.0, kappa=1.0, lef_rw=True, lef_drift=True, cross_loop=True, r=None):
|
|
256
|
+
def run_energy_minimization(self, N_steps, MC_step, burnin, T=1, T_min=0, mode='Metropolis', viz=False, save=False, f=1.0, f2=0.0, b=1.0, kappa=1.0, lef_rw=True, lef_drift=True, cross_loop=True, r=None, between_families_penalty=True):
|
|
255
257
|
'''
|
|
256
258
|
Implementation of the stochastic Monte Carlo simulation.
|
|
257
259
|
|
|
@@ -265,6 +267,7 @@ class StochasticSimulation:
|
|
|
265
267
|
r (list): strength of each ChIP-Seq experiment.
|
|
266
268
|
N_bws (int): number of binding weight matrices.
|
|
267
269
|
BWs (np.ndarray): binding weight matrices.
|
|
270
|
+
between_families_penalty (bool): whether to apply penalty for interactions between families.
|
|
268
271
|
'''
|
|
269
272
|
# Define normalization constants
|
|
270
273
|
fold_norm, fold_norm2, bind_norm, k_norm = -self.N_beads*f/((self.N_lef+self.N_lef2)*np.log(self.N_beads/(self.N_lef+self.N_lef2))), -self.N_beads*f2/((self.N_lef+self.N_lef2)*np.log(self.N_beads/(self.N_lef+self.N_lef2))), -self.N_beads*b/(np.sum(self.L)+np.sum(self.R)), kappa*1e4
|
|
@@ -275,7 +278,7 @@ class StochasticSimulation:
|
|
|
275
278
|
print('\nRunning simulation (with parallelization across CPU cores)...')
|
|
276
279
|
start = time.time()
|
|
277
280
|
self.burnin = burnin
|
|
278
|
-
self.Ms, self.Ns, self.Es, self.Ks, self.Fs, self.Bs, self.ufs = run_simulation(self.N_beads, N_steps, MC_step, burnin, T, T_min, fold_norm, fold_norm2, bind_norm, k_norm, self.N_lef, self.N_lef2, self.L, self.R, mode, lef_rw, lef_drift, cross_loop, r, self.N_bws, self.BWs, self.lef_track)
|
|
281
|
+
self.Ms, self.Ns, self.Es, self.Ks, self.Fs, self.Bs, self.ufs = run_simulation(self.N_beads, N_steps, MC_step, burnin, T, T_min, fold_norm, fold_norm2, bind_norm, k_norm, self.N_lef, self.N_lef2, self.L, self.R, mode, lef_rw, lef_drift, cross_loop, r, self.N_bws, self.BWs, self.lef_track, between_families_penalty)
|
|
279
282
|
end = time.time()
|
|
280
283
|
elapsed = end - start
|
|
281
284
|
print(f'Computation finished successfully in {elapsed//3600:.0f} hours, {elapsed%3600//60:.0f} minutes and {elapsed%60:.0f} seconds.')
|
|
@@ -294,7 +297,7 @@ class StochasticSimulation:
|
|
|
294
297
|
file.write(f'Folding energy in equilibrium is {np.average(self.Fs[burnin//MC_step:]):.2f}. Folding coefficient f={f}. Folding coefficient for the second family f2={f2}\n')
|
|
295
298
|
file.write(f'Binding energy in equilibrium is {np.average(self.Bs[burnin//MC_step:]):.2f}. Binding coefficient b={b}.\n')
|
|
296
299
|
if r is not None and self.BWs is not None:
|
|
297
|
-
file.write(f'RNApII binding energy included with {N_bws} binding weight matrices.\n')
|
|
300
|
+
file.write(f'RNApII binding energy included with {self.N_bws} binding weight matrices.\n')
|
|
298
301
|
file.write(f'Energy at equilibrium: {np.average(self.Es[self.burnin//MC_step:]):.2f}.\n')
|
|
299
302
|
np.save(save_dir + 'Ms.npy', self.Ms)
|
|
300
303
|
np.save(save_dir + 'Ns.npy', self.Ns)
|
|
@@ -342,22 +345,27 @@ def main():
|
|
|
342
345
|
# Definition of Monte Carlo parameters
|
|
343
346
|
N_steps, MC_step, burnin, T, T_min = int(4e4), int(5e2), 1000, 3.0, 1.0
|
|
344
347
|
N_lef, N_lef2 = 100, 20
|
|
345
|
-
lew_rw=True
|
|
348
|
+
lew_rw = True
|
|
346
349
|
mode = 'Annealing'
|
|
347
350
|
|
|
348
351
|
# Simulation Strengths
|
|
349
352
|
f, f2, b, kappa = 1.0, 2.0, 1.0, 1.0
|
|
350
353
|
|
|
351
354
|
# Definition of region
|
|
352
|
-
region, chrom = [15550000,16850000], 'chr6'
|
|
355
|
+
region, chrom = [15550000, 16850000], 'chr6'
|
|
353
356
|
|
|
354
357
|
# Definition of data
|
|
355
|
-
output_name='tmp'
|
|
358
|
+
output_name = 'tmp'
|
|
356
359
|
bedpe_file = '/home/skorsak/Data/HiChIP/Maps/hg00731_smc1_maps_2.bedpe'
|
|
357
360
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
+
# Between family penalty
|
|
362
|
+
between_families_penalty = True
|
|
363
|
+
|
|
364
|
+
sim = StochasticSimulation(region, chrom, bedpe_file, out_dir=output_name, N_beads=1000, N_lef=N_lef, N_lef2=N_lef2)
|
|
365
|
+
Es, Ms, Ns, Bs, Ks, Fs, ufs = sim.run_energy_minimization(
|
|
366
|
+
N_steps, MC_step, burnin, T, T_min, mode=mode, viz=True, save=True, f=f, f2=f2, b=b, kappa=kappa, lef_rw=lew_rw, between_families_penalty=between_families_penalty
|
|
367
|
+
)
|
|
368
|
+
sim.run_MD('CUDA', continuous_topoisomerase=True, p_ev=0.01)
|
|
361
369
|
|
|
362
370
|
if __name__=='__main__':
|
|
363
371
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyLoopSage
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
4
4
|
Summary: An energy-based stochastic model of loop extrusion in chromatin.
|
|
5
5
|
Home-page: https://github.com/SFGLab/pyLoopSage
|
|
6
6
|
Author: Sebastian Korsak
|
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: POSIX :: Linux
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: numpy<2.0,>1.2
|
|
16
16
|
Requires-Dist: numba
|
|
17
17
|
Requires-Dist: scipy
|
|
18
18
|
Requires-Dist: pandas
|
|
@@ -304,6 +304,8 @@ An example, illustrated with Chimera software, simulated trajectory of structure
|
|
|
304
304
|
| LEF_DRIFT | True if LEFs are pushed back when they encounter other LEFs. | bool | False |
|
|
305
305
|
| N_LEF | Number of loop extrusion factors. | int | None |
|
|
306
306
|
| N_LEF2 | Number of second family loop extrusion factors. | int | 0 |
|
|
307
|
+
| CROSS_LOOP | True if the penalty is applied when mi<mj<ni<nj. False if it applies only when mj=ni. When false it is better to enable LEF_DRIFT as well. | bool |True |
|
|
308
|
+
| BETWEEN_FAMILIES_PENALTY | Penalty applied when loops from different LEF families cross. | bool | True |
|
|
307
309
|
|
|
308
310
|
#### Energy Coefficients
|
|
309
311
|
| Argument Name | Description | Type | Default Value |
|
|
@@ -311,9 +313,8 @@ An example, illustrated with Chimera software, simulated trajectory of structure
|
|
|
311
313
|
| FOLDING_COEFF | Folding coefficient. | float | 1.0 |
|
|
312
314
|
| FOLDING_COEFF2 | Folding coefficient for the second family of LEFs. | float | 0.0 |
|
|
313
315
|
| CROSS_COEFF | LEF crossing coefficient. | float | 1.0 |
|
|
314
|
-
| CROSS_LOOP | True if the penalty is applied when mi<mj<ni<nj. False if it applies only when mj=ni. When false it is better to enable LEF_DRIFT as well. | bool |True |
|
|
315
316
|
| BIND_COEFF | CTCF binding coefficient. | float | 1.0 |
|
|
316
|
-
| BW_STRENGTHS | List of strengths corresponding to each
|
|
317
|
+
| BW_STRENGTHS | List of strengths of the energy (floats) corresponding to each BW file. This equivalent to the `r` parameter in the LoopSage paper. | list | None |
|
|
317
318
|
|
|
318
319
|
#### Molecular Dynamics Simulation
|
|
319
320
|
| Argument Name | Description | Type | Default Value |
|
|
@@ -6,7 +6,7 @@ with open('README.md', 'r', encoding='utf-8') as f:
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name='pyLoopSage', # Package name
|
|
9
|
-
version='1.1.
|
|
9
|
+
version='1.1.3', # Version of the software
|
|
10
10
|
description='An energy-based stochastic model of loop extrusion in chromatin.',
|
|
11
11
|
long_description=long_description,
|
|
12
12
|
long_description_content_type='text/markdown',
|
|
@@ -20,7 +20,7 @@ setup(
|
|
|
20
20
|
'loopsage': ['forcefields/*'],
|
|
21
21
|
},
|
|
22
22
|
install_requires=[ # List your package dependencies here
|
|
23
|
-
'numpy
|
|
23
|
+
'numpy>1.2,<2.0',
|
|
24
24
|
'numba',
|
|
25
25
|
'scipy',
|
|
26
26
|
'pandas',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|