pyLoopSage 1.0.5__tar.gz → 1.0.7__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.0.5 → pyloopsage-1.0.7}/PKG-INFO +3 -3
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/README.md +2 -2
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/__init__.py +1 -1
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/args_definition.py +6 -3
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/em.py +5 -12
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/md.py +7 -14
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/run.py +3 -3
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/stochastic_simulation.py +4 -4
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/utils.py +1 -2
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/pyLoopSage.egg-info/PKG-INFO +3 -3
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/setup.py +1 -1
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/LICENSE +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/initial_structures.py +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/plots.py +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/preproc.py +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/loopsage/vizualization_tools.py +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/pyLoopSage.egg-info/SOURCES.txt +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/pyLoopSage.egg-info/dependency_links.txt +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/pyLoopSage.egg-info/entry_points.txt +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/pyLoopSage.egg-info/requires.txt +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/pyLoopSage.egg-info/top_level.txt +0 -0
- {pyloopsage-1.0.5 → pyloopsage-1.0.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyLoopSage
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
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
|
|
@@ -135,7 +135,7 @@ chr1 991375 993240 chr1 1062647 1064919 15 1.0 0.9997541297643132
|
|
|
135
135
|
|
|
136
136
|
where the last two columns represent the probabilites for left and right anchor respectively to be tandem right. If the probability is negative it means that no CTCF motif was detected in this anchor. You can extract these probabilities from the repo: https://github.com/SFGLab/3d-analysis-toolkit, with `find_motifs.py` file.
|
|
137
137
|
|
|
138
|
-
Then, we define the main parameters of the simulation `N_beads,N_coh,kappa,f,b` or we can choose the default ones (take care because it might be the case that they are not the appropriate ones and they need to be changed), the parameters of Monte Carlo `N_steps, MC_step, burnin, T`, and we initialize the class `LoopSage()`. The command `sim.run_energy_minimization()` corresponds to the stochastic Monte Carlo simulation, and it produces a set of cohesin constraints as a result (`Ms, Ns`). Note that the stochastic simulation has two modes: `Annealing` and `Metropolis`. We feed cohesin constraints to the molecular simulation part of and we run `MD_LE()` or `
|
|
138
|
+
Then, we define the main parameters of the simulation `N_beads,N_coh,kappa,f,b` or we can choose the default ones (take care because it might be the case that they are not the appropriate ones and they need to be changed), the parameters of Monte Carlo `N_steps, MC_step, burnin, T`, and we initialize the class `LoopSage()`. The command `sim.run_energy_minimization()` corresponds to the stochastic Monte Carlo simulation, and it produces a set of cohesin constraints as a result (`Ms, Ns`). Note that the stochastic simulation has two modes: `Annealing` and `Metropolis`. We feed cohesin constraints to the molecular simulation part of and we run `MD_LE()` or `EM_LE()` simulation which produces a trajectory of 3d-structures, and the average heatmap. `MD_LE()` function can produce an actual trajectory and a `.dcd` video of how simulation changes over time. However, the implementation needs a high amount of memory since we need to define a bond for each time step, and it may not work for large systems. `EM_LE()` is suggested for large simulations, because it does not require so big amount of memory. *We would like to advise to our users that in case that they would like to use molecular dynamics (`MD`), it is better to choose small `MC_step`, because the trajectory of LEFs should be continuous.*
|
|
139
139
|
|
|
140
140
|
### Running LoopSage from command-line
|
|
141
141
|
To run LoopSage from command-line, you only need to type a command
|
|
@@ -217,7 +217,7 @@ Now, to reassure that our algorithm works well we need to observe some fundament
|
|
|
217
217
|
In graph A, we can see the plot of the energy as a function of simulation time. In Metropolis after some steps, the simulation should reach equillibrium after the defined burnin period (blue vertical line). In case of Simulated Annealing, the energy should decrease as function of time because the temperature decreases, and thus the energy should not be conserved. Autocorrelations (B), show us if the thermodyncamic ensembles that we obtained are autocorrelated or not. The Monte Carlo step (sampling frequency) should be big enough so as to have small autocorrelations (<0.5). The averaged heatmap (C), shows the simulated heatmap, after averaging inversed all-versus-all distances of the region of interest. Finally, (D) shows the Pearson correlation between projected 1D signal of heatmap of experimental and simulated data.
|
|
218
218
|
|
|
219
219
|
In the output folder there are another three subfolders:
|
|
220
|
-
* `
|
|
220
|
+
* `ensembles` has the ensembles of 3D structures in `.cif` format (it can open with vizualization software Chimera: https://www.cgl.ucsf.edu/chimera/) or `pyvista`,
|
|
221
221
|
* `heatmaps` with the inversed all-versus-all distance heatmap of each one of these structures.
|
|
222
222
|
* `other` here are some numpy arrays and some computed statistics. Numpy arrays like `Ms` and `Ns` have the degrees of freedoms of LEFs over time, then `Fs, Ks, Es` they have folding, corssing energy and total energy over time. `Ts` is the temperature over time. And finally in `other.txt` you can see the statistics of the simulation and the input parameters. In `correlations.txt` you can find a file with Pearson, Spearmann and Kendau tau correlations between estimated and experimental data. We provide an optimistic simulations where zeros of the signal are taken into account, and a pessimistic one where the zeros are not taken into account.
|
|
223
223
|
|
|
@@ -101,7 +101,7 @@ chr1 991375 993240 chr1 1062647 1064919 15 1.0 0.9997541297643132
|
|
|
101
101
|
|
|
102
102
|
where the last two columns represent the probabilites for left and right anchor respectively to be tandem right. If the probability is negative it means that no CTCF motif was detected in this anchor. You can extract these probabilities from the repo: https://github.com/SFGLab/3d-analysis-toolkit, with `find_motifs.py` file.
|
|
103
103
|
|
|
104
|
-
Then, we define the main parameters of the simulation `N_beads,N_coh,kappa,f,b` or we can choose the default ones (take care because it might be the case that they are not the appropriate ones and they need to be changed), the parameters of Monte Carlo `N_steps, MC_step, burnin, T`, and we initialize the class `LoopSage()`. The command `sim.run_energy_minimization()` corresponds to the stochastic Monte Carlo simulation, and it produces a set of cohesin constraints as a result (`Ms, Ns`). Note that the stochastic simulation has two modes: `Annealing` and `Metropolis`. We feed cohesin constraints to the molecular simulation part of and we run `MD_LE()` or `
|
|
104
|
+
Then, we define the main parameters of the simulation `N_beads,N_coh,kappa,f,b` or we can choose the default ones (take care because it might be the case that they are not the appropriate ones and they need to be changed), the parameters of Monte Carlo `N_steps, MC_step, burnin, T`, and we initialize the class `LoopSage()`. The command `sim.run_energy_minimization()` corresponds to the stochastic Monte Carlo simulation, and it produces a set of cohesin constraints as a result (`Ms, Ns`). Note that the stochastic simulation has two modes: `Annealing` and `Metropolis`. We feed cohesin constraints to the molecular simulation part of and we run `MD_LE()` or `EM_LE()` simulation which produces a trajectory of 3d-structures, and the average heatmap. `MD_LE()` function can produce an actual trajectory and a `.dcd` video of how simulation changes over time. However, the implementation needs a high amount of memory since we need to define a bond for each time step, and it may not work for large systems. `EM_LE()` is suggested for large simulations, because it does not require so big amount of memory. *We would like to advise to our users that in case that they would like to use molecular dynamics (`MD`), it is better to choose small `MC_step`, because the trajectory of LEFs should be continuous.*
|
|
105
105
|
|
|
106
106
|
### Running LoopSage from command-line
|
|
107
107
|
To run LoopSage from command-line, you only need to type a command
|
|
@@ -183,7 +183,7 @@ Now, to reassure that our algorithm works well we need to observe some fundament
|
|
|
183
183
|
In graph A, we can see the plot of the energy as a function of simulation time. In Metropolis after some steps, the simulation should reach equillibrium after the defined burnin period (blue vertical line). In case of Simulated Annealing, the energy should decrease as function of time because the temperature decreases, and thus the energy should not be conserved. Autocorrelations (B), show us if the thermodyncamic ensembles that we obtained are autocorrelated or not. The Monte Carlo step (sampling frequency) should be big enough so as to have small autocorrelations (<0.5). The averaged heatmap (C), shows the simulated heatmap, after averaging inversed all-versus-all distances of the region of interest. Finally, (D) shows the Pearson correlation between projected 1D signal of heatmap of experimental and simulated data.
|
|
184
184
|
|
|
185
185
|
In the output folder there are another three subfolders:
|
|
186
|
-
* `
|
|
186
|
+
* `ensembles` has the ensembles of 3D structures in `.cif` format (it can open with vizualization software Chimera: https://www.cgl.ucsf.edu/chimera/) or `pyvista`,
|
|
187
187
|
* `heatmaps` with the inversed all-versus-all distance heatmap of each one of these structures.
|
|
188
188
|
* `other` here are some numpy arrays and some computed statistics. Numpy arrays like `Ms` and `Ns` have the degrees of freedoms of LEFs over time, then `Fs, Ks, Es` they have folding, corssing energy and total energy over time. `Ts` is the temperature over time. And finally in `other.txt` you can see the statistics of the simulation and the input parameters. In `correlations.txt` you can find a file with Pearson, Spearmann and Kendau tau correlations between estimated and experimental data. We provide an optimistic simulations where zeros of the signal are taken into account, and a pessimistic one where the zeros are not taken into account.
|
|
189
189
|
|
|
@@ -150,11 +150,14 @@ args = ListOfArgs([
|
|
|
150
150
|
# Molecular Dynamic Properties
|
|
151
151
|
Arg('INITIAL_STRUCTURE_TYPE', help="you can choose between: rw, confined_rw, self_avoiding_rw, helix, circle, spiral, sphere.", type=str, default='rw', val='rw'),
|
|
152
152
|
Arg('SIMULATION_TYPE', help="It can be either EM (multiple energy minimizations) or MD (one energy minimization and then run molecular dynamics).", type=str, default='', val=''),
|
|
153
|
+
Arg('INTEGRATOR_STEP', help="The step of the integrator.", type=Quantity, default='5 femtosecond', val='5 femtosecond'),
|
|
153
154
|
Arg('FORCEFIELD_PATH', help="Path to XML file with forcefield.", type=str, default='forcefield/classic_sm_ff.xml', val='forcefield/classic_sm_ff.xml'),
|
|
154
155
|
Arg('ANGLE_FF_STRENGTH', help="Angle force strength.", type=float, default='200.0', val='200.0'),
|
|
155
|
-
Arg('LE_FF_LENGTH', help="Equillibrium distance of loop forces.", type=float, default='0.
|
|
156
|
-
Arg('LE_FF_STRENGTH', help="
|
|
156
|
+
Arg('LE_FF_LENGTH', help="Equillibrium distance of loop forces.", type=float, default='0.1', val='0.1'),
|
|
157
|
+
Arg('LE_FF_STRENGTH', help="Interaction Strength of loop forces.", type=float, default='3000.0', val='3000.0'),
|
|
157
158
|
Arg('EV_FF_STRENGTH', help="Excluded-volume strength.", type=float, default='10.0', val='10.0'),
|
|
159
|
+
Arg('FRICTION',help='Friction coefficient of the Langevin integrator.',type=float, default='0.1', val='0.1'),
|
|
158
160
|
Arg('TOLERANCE', help="Tolerance that works as stopping condition for energy minimization.", type=float, default='0.001', val='0.001'),
|
|
161
|
+
Arg('SIM_TEMP', help="The temperature of the stochastic simulation.", type=Quantity, default='310 kelvin', val='310 kelvin'),
|
|
159
162
|
Arg('SIM_STEP', help="This is the amount of simulation steps that are perform each time that we change the loop forces. If this number is too high, the simulation is slow, if is too low it may not have enough time to adapt the structure to the new constraints.", type=int, default='100', val='100'),
|
|
160
|
-
])
|
|
163
|
+
])
|
|
@@ -12,7 +12,7 @@ from .utils import *
|
|
|
12
12
|
from .initial_structures import *
|
|
13
13
|
|
|
14
14
|
class EM_LE:
|
|
15
|
-
def __init__(self,M,N,N_beads,burnin,MC_step,path,platform,angle_ff_strength=200,le_distance=0.1,le_ff_strength=300000.0,ev_ff_strength=10.0,tolerance=0.001):
|
|
15
|
+
def __init__(self,M,N,N_beads,burnin,MC_step,path=None,platform='CPU',angle_ff_strength=200,le_distance=0.1,le_ff_strength=300000.0,ev_ff_strength=10.0,tolerance=0.001):
|
|
16
16
|
'''
|
|
17
17
|
M, N (np arrays): Position matrix of two legs of cohesin m,n.
|
|
18
18
|
Rows represent loops/cohesins and columns represent time
|
|
@@ -31,15 +31,9 @@ class EM_LE:
|
|
|
31
31
|
self.ev_ff_strength = ev_ff_strength
|
|
32
32
|
self.tolerance = tolerance
|
|
33
33
|
|
|
34
|
-
def run_pipeline(self,
|
|
34
|
+
def run_pipeline(self,plots=False, friction=0.1, integrator_step = 5 * mm.unit.femtosecond, temperature = 310):
|
|
35
35
|
'''
|
|
36
36
|
This is the basic function that runs the molecular simulation pipeline.
|
|
37
|
-
|
|
38
|
-
Input parameters:
|
|
39
|
-
run_MD (bool): True if user wants to run molecular simulation (not only energy minimization).
|
|
40
|
-
sim_step (int): the simulation step of Langevin integrator.
|
|
41
|
-
write_files (bool): True if the user wants to save the structures that determine the simulation ensemble.
|
|
42
|
-
plots (bool): True if the user wants to see the output average heatmaps.
|
|
43
37
|
'''
|
|
44
38
|
# Define initial structure
|
|
45
39
|
print('Building initial structure...')
|
|
@@ -56,7 +50,7 @@ class EM_LE:
|
|
|
56
50
|
pdb = PDBxFile(self.path+'/LE_init_struct.cif')
|
|
57
51
|
forcefield = ForceField('forcefields/classic_sm_ff.xml')
|
|
58
52
|
self.system = forcefield.createSystem(pdb.topology, nonbondedCutoff=1*u.nanometer)
|
|
59
|
-
integrator = mm.LangevinIntegrator(
|
|
53
|
+
integrator = mm.LangevinIntegrator(temperature, friction, integrator_step)
|
|
60
54
|
|
|
61
55
|
# Add forces
|
|
62
56
|
ms,ns = self.M[:,i], self.N[:,i]
|
|
@@ -69,8 +63,7 @@ class EM_LE:
|
|
|
69
63
|
simulation.minimizeEnergy(tolerance=self.tolerance)
|
|
70
64
|
self.state = simulation.context.getState(getPositions=True)
|
|
71
65
|
PDBxFile.writeFile(pdb.topology, self.state.getPositions(), open(self.path+f'/ensemble/EMLE_{i-self.burnin+1}.cif', 'w'))
|
|
72
|
-
|
|
73
|
-
sum_heat+=get_heatmap(self.state.getPositions(),save_path=save_path,save=write_files)
|
|
66
|
+
sum_heat+=get_heatmap(self.state.getPositions(),save=False)
|
|
74
67
|
counter+=1
|
|
75
68
|
print('Energy minimizations done :D\n')
|
|
76
69
|
|
|
@@ -128,4 +121,4 @@ def main():
|
|
|
128
121
|
M = np.load('/home/skorsak/Dropbox/LoopSage/files/region_[48100000,48700000]_chr3/Annealing_Nbeads500_ncoh50/Ms.npy')
|
|
129
122
|
N = np.load('/home/skorsak/Dropbox/LoopSage/files/region_[48100000,48700000]_chr3/Annealing_Nbeads500_ncoh50/Ns.npy')
|
|
130
123
|
md = EM_LE(4*M,4*N,2000,5,1)
|
|
131
|
-
md.run_pipeline(
|
|
124
|
+
md.run_pipeline()
|
|
@@ -16,7 +16,7 @@ from .utils import *
|
|
|
16
16
|
from .initial_structures import *
|
|
17
17
|
|
|
18
18
|
class MD_LE:
|
|
19
|
-
def __init__(self,M,N,N_beads,burnin,MC_step,path,platform,angle_ff_strength=200,le_distance=0.1,le_ff_strength=30000.0,ev_ff_strength=10.0,tolerance=0.001):
|
|
19
|
+
def __init__(self,M,N,N_beads,burnin,MC_step,path=None,platform='CPU',angle_ff_strength=200,le_distance=0.1,le_ff_strength=30000.0,ev_ff_strength=10.0,tolerance=0.001):
|
|
20
20
|
'''
|
|
21
21
|
M, N (np arrays): Position matrix of two legs of cohesin m,n.
|
|
22
22
|
Rows represent loops/cohesins and columns represent time
|
|
@@ -35,15 +35,9 @@ class MD_LE:
|
|
|
35
35
|
self.ev_ff_strength = ev_ff_strength
|
|
36
36
|
self.tolerance = tolerance
|
|
37
37
|
|
|
38
|
-
def run_pipeline(self,run_MD=True,sim_step=100,
|
|
38
|
+
def run_pipeline(self,run_MD=True, friction=0.1, integrator_step=5 * mm.unit.femtosecond, sim_step=100, temperature=310, plots=False):
|
|
39
39
|
'''
|
|
40
40
|
This is the basic function that runs the molecular simulation pipeline.
|
|
41
|
-
|
|
42
|
-
Input parameters:
|
|
43
|
-
run_MD (bool): True if user wants to run molecular simulation (not only energy minimization).
|
|
44
|
-
sim_step (int): the simulation step of Langevin integrator.
|
|
45
|
-
write_files (bool): True if the user wants to save the structures that determine the simulation ensemble.
|
|
46
|
-
plots (bool): True if the user wants to see the output average heatmaps.
|
|
47
41
|
'''
|
|
48
42
|
# Parameters
|
|
49
43
|
self.angle_ff_strength=200
|
|
@@ -62,7 +56,7 @@ class MD_LE:
|
|
|
62
56
|
pdb = PDBxFile(self.path+'/LE_init_struct.cif')
|
|
63
57
|
forcefield = ForceField('forcefields/classic_sm_ff.xml')
|
|
64
58
|
self.system = forcefield.createSystem(pdb.topology, nonbondedCutoff=1*u.nanometer)
|
|
65
|
-
integrator = mm.LangevinIntegrator(
|
|
59
|
+
integrator = mm.LangevinIntegrator(temperature, friction, integrator_step)
|
|
66
60
|
|
|
67
61
|
# Add forces
|
|
68
62
|
print('Adding forces...')
|
|
@@ -91,9 +85,8 @@ class MD_LE:
|
|
|
91
85
|
self.simulation.step(sim_step)
|
|
92
86
|
if i>=self.burnin:
|
|
93
87
|
self.state = self.simulation.context.getState(getPositions=True)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
heats.append(get_heatmap(self.state.getPositions(),save_path=save_path,save=write_files))
|
|
88
|
+
PDBxFile.writeFile(pdb.topology, self.state.getPositions(), open(self.path+f'/ensemble/MDLE_{i-self.burnin+1}.cif', 'w'))
|
|
89
|
+
heats.append(get_heatmap(self.state.getPositions(),save=False))
|
|
97
90
|
end = time.time()
|
|
98
91
|
elapsed = end - start
|
|
99
92
|
|
|
@@ -117,7 +110,7 @@ class MD_LE:
|
|
|
117
110
|
|
|
118
111
|
def add_evforce(self):
|
|
119
112
|
'Leonard-Jones potential for excluded volume'
|
|
120
|
-
self.ev_force = mm.CustomNonbondedForce('epsilon*(sigma1+sigma2)/(r+r_small)')
|
|
113
|
+
self.ev_force = mm.CustomNonbondedForce('epsilon*((sigma1+sigma2)/(r+r_small))')
|
|
121
114
|
self.ev_force.addGlobalParameter('epsilon', defaultValue=self.ev_ff_strength)
|
|
122
115
|
self.ev_force.addGlobalParameter('r_small', defaultValue=0.01)
|
|
123
116
|
self.ev_force.addPerParticleParameter('sigma')
|
|
@@ -172,4 +165,4 @@ def main():
|
|
|
172
165
|
M = np.load('/home/skorsak/Dropbox/LoopSage/files/region_[48100000,48700000]_chr3/Annealing_Nbeads500_ncoh50/Ms.npy')
|
|
173
166
|
N = np.load('/home/skorsak/Dropbox/LoopSage/files/region_[48100000,48700000]_chr3/Annealing_Nbeads500_ncoh50/Ns.npy')
|
|
174
167
|
md = MD_LE(4*M,4*N,2000,5,1)
|
|
175
|
-
md.run_pipeline(
|
|
168
|
+
md.run_pipeline()
|
|
@@ -72,13 +72,13 @@ def main():
|
|
|
72
72
|
sim = StochasticSimulation(region,chrom,bedpe_file,out_dir=output_name,N_beads=N_beads,N_lef=N_lef)
|
|
73
73
|
Es, Ms, Ns, Bs, Ks, Fs, ufs = sim.run_energy_minimization(N_steps,MC_step,burnin,T,T_min,mode=mode,viz=True,save=True,lef_rw=args.LEF_RW)
|
|
74
74
|
if args.SIMULATION_TYPE=='EM':
|
|
75
|
-
sim.run_EM(args.PLATFORM,args.ANGLE_FF_STRENGTH,args.LE_FF_LENGTH,args.LE_FF_STRENGTH,args.EV_FF_STRENGTH,args.TOLERANCE)
|
|
75
|
+
sim.run_EM(args.PLATFORM,args.ANGLE_FF_STRENGTH,args.LE_FF_LENGTH,args.LE_FF_STRENGTH,args.EV_FF_STRENGTH,args.TOLERANCE,args.FRICTION,args.INTEGRATOR_STEP,args.SIM_TEMP)
|
|
76
76
|
elif args.SIMULATION_TYPE=='MD':
|
|
77
|
-
sim.run_MD(args.PLATFORM,args.ANGLE_FF_STRENGTH,args.LE_FF_LENGTH,args.LE_FF_STRENGTH,args.EV_FF_STRENGTH,args.TOLERANCE,args.SIM_STEP)
|
|
77
|
+
sim.run_MD(args.PLATFORM,args.ANGLE_FF_STRENGTH,args.LE_FF_LENGTH,args.LE_FF_STRENGTH,args.EV_FF_STRENGTH,args.TOLERANCE,args.FRICTION,args.INTEGRATOR_STEP,args.SIM_TEMP,args.SIM_STEP)
|
|
78
78
|
elif args.SIMULATION_TYPE==None:
|
|
79
79
|
print('\n3D simulation did not run because it was not specified. Please specify argument SIMULATION_TYPE as EM or MD.')
|
|
80
80
|
else:
|
|
81
81
|
IndentationError('Uknown simulation type. It can be either MD or EM.')
|
|
82
82
|
|
|
83
83
|
if __name__=='__main__':
|
|
84
|
-
main()
|
|
84
|
+
main()
|
|
@@ -272,14 +272,14 @@ class StochasticSimulation:
|
|
|
272
272
|
self.N_CTCF = np.max([np.count_nonzero(self.L),np.count_nonzero(self.R)])
|
|
273
273
|
print('Number of CTCF:',self.N_CTCF)
|
|
274
274
|
|
|
275
|
-
def run_EM(self,platform='CPU',angle_ff_strength=200,le_distance=0.0,le_ff_strength=300000.0,ev_ff_strength=10.0,tolerance=0.001):
|
|
275
|
+
def run_EM(self,platform='CPU',angle_ff_strength=200,le_distance=0.0,le_ff_strength=300000.0,ev_ff_strength=10.0,tolerance=0.001,friction=0.1,integrator_step=5*mm.unit.femtosecond,temperature=310):
|
|
276
276
|
em = EM_LE(self.Ms,self.Ns,self.N_beads,self.burnin,self.MC_step,self.path,platform,angle_ff_strength,le_distance,le_ff_strength,ev_ff_strength,tolerance)
|
|
277
|
-
sim_heat = em.run_pipeline(
|
|
277
|
+
sim_heat = em.run_pipeline(plots=True,friction=friction,integrator_step=integrator_step,temperature=temperature)
|
|
278
278
|
corr_exp_heat(sim_heat,self.bedpe_file,self.region,self.chrom,self.N_beads,self.path)
|
|
279
279
|
|
|
280
|
-
def run_MD(self,platform='CPU',angle_ff_strength=200,le_distance=0.0,le_ff_strength=300000.0,ev_ff_strength=10.0,tolerance=0.001,sim_step=100):
|
|
280
|
+
def run_MD(self,platform='CPU',angle_ff_strength=200,le_distance=0.0,le_ff_strength=300000.0,ev_ff_strength=10.0,tolerance=0.001,friction=0.1,integrator_step=5*mm.unit.femtosecond,temperature=310,sim_step=100):
|
|
281
281
|
md = MD_LE(self.Ms,self.Ns,self.N_beads,self.burnin,self.MC_step,self.path,platform,angle_ff_strength,le_distance,le_ff_strength,ev_ff_strength,tolerance)
|
|
282
|
-
sim_heat = md.run_pipeline(
|
|
282
|
+
sim_heat = md.run_pipeline(plots=True,sim_step=sim_step,friction=friction,integrator_step=integrator_step,temperature=temperature)
|
|
283
283
|
corr_exp_heat(sim_heat,self.bedpe_file,self.region,self.chrom,self.N_beads,self.path)
|
|
284
284
|
|
|
285
285
|
def main():
|
|
@@ -18,7 +18,6 @@ def make_folder(folder_name):
|
|
|
18
18
|
os.mkdir(folder_name+'/plots')
|
|
19
19
|
os.mkdir(folder_name+'/other')
|
|
20
20
|
os.mkdir(folder_name+'/ensemble')
|
|
21
|
-
os.mkdir(folder_name+'/heatmaps')
|
|
22
21
|
except OSError as error:
|
|
23
22
|
a=1
|
|
24
23
|
# print(f'Directory with name "{folder_name}" already exists! No problem lets continue!')
|
|
@@ -465,4 +464,4 @@ def save_info(N_beads,N_coh,N_CTCF,kappa,f,b,avg_loop,path,N_steps,MC_step,burni
|
|
|
465
464
|
file.write(f'Average loop size {avg_loop}\n')
|
|
466
465
|
file.write(f'f = {f}, b={b}, k={kappa}\n')
|
|
467
466
|
file.write(f'Monte Carlo parameters: N_steps={N_steps}, MC_step={MC_step}, burnin={burnin*MC_step}, method {mode}\n')
|
|
468
|
-
file.write(f'Equillibrium parameters: uf={np.average(ufs)}, E={np.average(Es)}, K={np.average(Ks)}, F={np.average(Fs)}, B={np.average(Bs)}')
|
|
467
|
+
file.write(f'Equillibrium parameters: uf={np.average(ufs)}, E={np.average(Es)}, K={np.average(Ks)}, F={np.average(Fs)}, B={np.average(Bs)}')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyLoopSage
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
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
|
|
@@ -135,7 +135,7 @@ chr1 991375 993240 chr1 1062647 1064919 15 1.0 0.9997541297643132
|
|
|
135
135
|
|
|
136
136
|
where the last two columns represent the probabilites for left and right anchor respectively to be tandem right. If the probability is negative it means that no CTCF motif was detected in this anchor. You can extract these probabilities from the repo: https://github.com/SFGLab/3d-analysis-toolkit, with `find_motifs.py` file.
|
|
137
137
|
|
|
138
|
-
Then, we define the main parameters of the simulation `N_beads,N_coh,kappa,f,b` or we can choose the default ones (take care because it might be the case that they are not the appropriate ones and they need to be changed), the parameters of Monte Carlo `N_steps, MC_step, burnin, T`, and we initialize the class `LoopSage()`. The command `sim.run_energy_minimization()` corresponds to the stochastic Monte Carlo simulation, and it produces a set of cohesin constraints as a result (`Ms, Ns`). Note that the stochastic simulation has two modes: `Annealing` and `Metropolis`. We feed cohesin constraints to the molecular simulation part of and we run `MD_LE()` or `
|
|
138
|
+
Then, we define the main parameters of the simulation `N_beads,N_coh,kappa,f,b` or we can choose the default ones (take care because it might be the case that they are not the appropriate ones and they need to be changed), the parameters of Monte Carlo `N_steps, MC_step, burnin, T`, and we initialize the class `LoopSage()`. The command `sim.run_energy_minimization()` corresponds to the stochastic Monte Carlo simulation, and it produces a set of cohesin constraints as a result (`Ms, Ns`). Note that the stochastic simulation has two modes: `Annealing` and `Metropolis`. We feed cohesin constraints to the molecular simulation part of and we run `MD_LE()` or `EM_LE()` simulation which produces a trajectory of 3d-structures, and the average heatmap. `MD_LE()` function can produce an actual trajectory and a `.dcd` video of how simulation changes over time. However, the implementation needs a high amount of memory since we need to define a bond for each time step, and it may not work for large systems. `EM_LE()` is suggested for large simulations, because it does not require so big amount of memory. *We would like to advise to our users that in case that they would like to use molecular dynamics (`MD`), it is better to choose small `MC_step`, because the trajectory of LEFs should be continuous.*
|
|
139
139
|
|
|
140
140
|
### Running LoopSage from command-line
|
|
141
141
|
To run LoopSage from command-line, you only need to type a command
|
|
@@ -217,7 +217,7 @@ Now, to reassure that our algorithm works well we need to observe some fundament
|
|
|
217
217
|
In graph A, we can see the plot of the energy as a function of simulation time. In Metropolis after some steps, the simulation should reach equillibrium after the defined burnin period (blue vertical line). In case of Simulated Annealing, the energy should decrease as function of time because the temperature decreases, and thus the energy should not be conserved. Autocorrelations (B), show us if the thermodyncamic ensembles that we obtained are autocorrelated or not. The Monte Carlo step (sampling frequency) should be big enough so as to have small autocorrelations (<0.5). The averaged heatmap (C), shows the simulated heatmap, after averaging inversed all-versus-all distances of the region of interest. Finally, (D) shows the Pearson correlation between projected 1D signal of heatmap of experimental and simulated data.
|
|
218
218
|
|
|
219
219
|
In the output folder there are another three subfolders:
|
|
220
|
-
* `
|
|
220
|
+
* `ensembles` has the ensembles of 3D structures in `.cif` format (it can open with vizualization software Chimera: https://www.cgl.ucsf.edu/chimera/) or `pyvista`,
|
|
221
221
|
* `heatmaps` with the inversed all-versus-all distance heatmap of each one of these structures.
|
|
222
222
|
* `other` here are some numpy arrays and some computed statistics. Numpy arrays like `Ms` and `Ns` have the degrees of freedoms of LEFs over time, then `Fs, Ks, Es` they have folding, corssing energy and total energy over time. `Ts` is the temperature over time. And finally in `other.txt` you can see the statistics of the simulation and the input parameters. In `correlations.txt` you can find a file with Pearson, Spearmann and Kendau tau correlations between estimated and experimental data. We provide an optimistic simulations where zeros of the signal are taken into account, and a pessimistic one where the zeros are not taken into account.
|
|
223
223
|
|
|
@@ -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.0.
|
|
9
|
+
version='1.0.7', # 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',
|
|
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
|