MultiMM 1.0.19__tar.gz → 1.0.22__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.
- {multimm-1.0.19 → multimm-1.0.22}/MultiMM.egg-info/PKG-INFO +27 -15
- {multimm-1.0.19 → multimm-1.0.22}/MultiMM.egg-info/SOURCES.txt +3 -1
- {multimm-1.0.19 → multimm-1.0.22}/PKG-INFO +27 -15
- {multimm-1.0.19 → multimm-1.0.22}/README.md +26 -14
- {multimm-1.0.19 → multimm-1.0.22}/setup.py +4 -1
- {multimm-1.0.19 → multimm-1.0.22}/simulation/__init__.py +1 -1
- {multimm-1.0.19 → multimm-1.0.22}/simulation/args_definition.py +4 -3
- multimm-1.0.22/simulation/forcefields/dna_histones_ff.xml +75 -0
- multimm-1.0.22/simulation/forcefields/ff.xml +24 -0
- {multimm-1.0.19 → multimm-1.0.22}/simulation/initial_structure_tools.py +2 -2
- {multimm-1.0.19 → multimm-1.0.22}/simulation/model.py +109 -29
- {multimm-1.0.19 → multimm-1.0.22}/simulation/plots.py +65 -9
- {multimm-1.0.19 → multimm-1.0.22}/simulation/run.py +34 -22
- {multimm-1.0.19 → multimm-1.0.22}/simulation/utils.py +18 -11
- {multimm-1.0.19 → multimm-1.0.22}/LICENSE +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/MultiMM.egg-info/dependency_links.txt +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/MultiMM.egg-info/entry_points.txt +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/MultiMM.egg-info/requires.txt +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/MultiMM.egg-info/top_level.txt +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/setup.cfg +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/simulation/nucleosome_interpolation.py +0 -0
- {multimm-1.0.19 → multimm-1.0.22}/simulation/validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MultiMM
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.22
|
|
4
4
|
Summary: A tool for chromatin modeling from nucleosomes to chromosomal territories.
|
|
5
5
|
Home-page: https://github.com/SFGLab/MultiMM
|
|
6
6
|
Author: Sebastian Korsak
|
|
@@ -73,14 +73,17 @@ PyPI software: https://pypi.org/project/MultiMM/.
|
|
|
73
73
|
|
|
74
74
|
## Input Data
|
|
75
75
|
|
|
76
|
-
### Loops (bedpe file)
|
|
77
76
|
MultiMM relies on three types of datasets:
|
|
78
77
|
|
|
79
78
|
- Loop interactions in `bedpe` format (mandatory).
|
|
80
79
|
- Compartmentalization data in `bed` format (optional).
|
|
81
80
|
- ATAC-Seq p-value data in `.BigWig` format (optional).
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
### Loops (bedpe file)
|
|
83
|
+
|
|
84
|
+
For **loop interactions**, users must provide a file describing interactions between anchor 1 and anchor 2, along with their strength.
|
|
85
|
+
|
|
86
|
+
The file must be in .bedpe format, contain 7 columns, and must not include a header.
|
|
84
87
|
|
|
85
88
|
```text
|
|
86
89
|
chr10 100225000 100230000 chr10 100420000 100425000 95
|
|
@@ -89,9 +92,12 @@ chr10 101190000 101195000 chr10 101370000 101375000 152
|
|
|
89
92
|
chr10 101190000 101200000 chr10 101470000 101480000 181
|
|
90
93
|
chr10 101600000 101605000 chr10 101805000 101810000 152
|
|
91
94
|
```
|
|
95
|
+
The file can include interactions from all chromosomes; MultiMM will automatically handle them.
|
|
96
|
+
|
|
97
|
+
For single-cell data, users should prepare the file by setting the second and third columns identical (as well as the fifth and sixth columns) and set the strength value to 1.
|
|
98
|
+
|
|
92
99
|
|
|
93
100
|
### Compartments
|
|
94
|
-
The file may contain interactions for all chromosomes, which MultiMM can automatically model. For single-cell data, users can provide a file with the second and third columns identical (the same for the fifth and sixth columns) and strength set to 1.
|
|
95
101
|
|
|
96
102
|
For **(sub)compartment interactions**, the file should be in the format produced by the CALDER software: https://github.com/CSOgroup/CALDER2. Users do not need to run CALDER specifically, but the file format must match. The file should contain at least the first four columns with chromosome, regions, and the subcompartment label. Example:
|
|
97
103
|
|
|
@@ -118,15 +124,13 @@ chr1 1400000 1500000 1.145813878361721
|
|
|
118
124
|
|
|
119
125
|
### Nucleosomes
|
|
120
126
|
|
|
121
|
-
For
|
|
122
|
-
|
|
123
|
-
**Note:** At present, MultiMM only works for human genome data. The code may run for other organisms with some debugging and modifications. We hope that it will be generalized in future versions. *MultiMM can run for different types of datasets. It is possible to call loops from any kind of experiment: Hi-C, scHi-C, ChIA-PET, Hi-ChIP. However, we cannot guarantee that the default choice of parameters is the most appropriate one for any dataset. Therefore, the user should test it and check the convergence of the algorithm for their own data. Before making any changes in the parameters, read the method paper carefully and try to understand the function of each force.*
|
|
127
|
+
For ATAC-Seq data, users must provide a BigWig file containing p-values. The pyBigWig library is required to read BigWig files. Note: pyBigWig is not compatible with Windows systems.
|
|
124
128
|
|
|
125
129
|
### Definition of a region based on a gene (optional)
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
To model a genomic region around a specific gene, you can load a `.tsv` file containing gene information. Specify either the gene name or the gene ID.
|
|
128
132
|
|
|
129
|
-
The file should
|
|
133
|
+
The `.tsv` file should be formatted as follows:
|
|
130
134
|
|
|
131
135
|
```text
|
|
132
136
|
gene_id gene_name chromosome start end
|
|
@@ -142,6 +146,13 @@ ENSG00000260972 chr1 5492978 5494674
|
|
|
142
146
|
ENSG00000224340 chr1 10054445 10054781
|
|
143
147
|
```
|
|
144
148
|
|
|
149
|
+
In case that you specify the gene, MultiMM will output a visualization with the gene as well. For example, in the folowing region we can see the polymer structure that is modelled (around the gene) and the gene with red color.
|
|
150
|
+
|
|
151
|
+

|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
> **Note:** Currently, MultiMM is designed to work with human genome data. While it may be possible to run the code on other organisms with additional debugging and modifications, full support for other species is planned for future versions. MultiMM can process various types of datasets. It is capable of calling loops from a range of experiments, including Hi-C, scHi-C, ChIA-PET, and Hi-ChIP. However, we cannot guarantee that the default parameters are optimal for every dataset. Therefore, users are encouraged to test the software carefully and verify the convergence of the algorithm with their own data.Before adjusting any parameters, please read the method paper thoroughly to understand the role and impact of each force.
|
|
155
|
+
|
|
145
156
|
## Usage
|
|
146
157
|
All the model's parameters are specified in a `config.ini` file. This file should have the following format:
|
|
147
158
|
|
|
@@ -225,8 +236,9 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
225
236
|
|
|
226
237
|
| Argument Name | Type | Value | Units | Description |
|
|
227
238
|
|------------------------------|--------------|-------------|---------------|-------------|
|
|
228
|
-
| PLATFORM | str |
|
|
239
|
+
| PLATFORM | str | CPU | CPU | name of the platform. Available choices: CPU, OpenCL, CUDA. |
|
|
229
240
|
| DEVICE | str | None | None | device index for CUDA or OpenCL (count from 0) |
|
|
241
|
+
| MAGIC_ARGUMENT | str | None | None | Helping function to specify parameters of simulation. Choose 'GENE', 'CHROM' or 'GW' depending on the resolution of interest. |
|
|
230
242
|
| INITIAL_STRUCTURE_PATH | str | None | None | Path to CIF file. |
|
|
231
243
|
| BUILD_INITIAL_STRUCTURE | bool | True | None | To build a new initial structure. |
|
|
232
244
|
| INITIAL_STRUCTURE_TYPE | str | hilbert | None | you can choose between: hilbert, circle, rw, confined_rw, self_avoiding_rw, helix, spiral, sphere, knot. |
|
|
@@ -290,7 +302,7 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
290
302
|
| POINTS_PER_NUC | int | 20 | None | The number of points that consist a nucleosome helix. |
|
|
291
303
|
| PHI_NORM | float | pi/5 | None | Zig zag angle. |
|
|
292
304
|
| SIM_RUN_MD | bool | False | None | Do you want to run MD simulation? |
|
|
293
|
-
| SIM_N_STEPS | int |
|
|
305
|
+
| SIM_N_STEPS | int | 10000 | None | Number of steps in MD simulation |
|
|
294
306
|
| SIM_ERROR_TOLERANCE | float | 0.01 | None | Error tolerance for variable MD simulation |
|
|
295
307
|
| SIM_AMD_ALPHA | float | 100.0 | kJ/mol | Alpha of AMD simulation. |
|
|
296
308
|
| SIM_AMD_E | float | 1000.0 | kJ/mol | E (energy) of AMD simulation. |
|
|
@@ -302,10 +314,10 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
302
314
|
| SIM_TEMPERATURE | Quantity | 310 | kelvin | Simulation temperature |
|
|
303
315
|
| TRJ_FRAMES | int | 2000 | None | Number of trajectory frames to save. |
|
|
304
316
|
|
|
305
|
-
##
|
|
317
|
+
## Citation and Cotribution
|
|
306
318
|
|
|
307
|
-
The software is freely distributed under the GNU license and
|
|
319
|
+
The software is freely distributed under the GNU license and is available for use in research, in accordance with the open-source license of MultiMM. If you use the software for research or other purposes, please cite the following paper:
|
|
308
320
|
|
|
309
|
-
- Korsak, Sevastianos, Krzysztof Banecki, and Dariusz Plewczynski. "Multiscale molecular modeling of chromatin with MultiMM: From nucleosomes to the whole genome." Computational and Structural Biotechnology Journal 23 (2024): 3537
|
|
321
|
+
- Korsak, Sevastianos, Krzysztof Banecki, and Dariusz Plewczynski. "Multiscale molecular modeling of chromatin with MultiMM: From nucleosomes to the whole genome." Computational and Structural Biotechnology Journal 23 (2024): 3537–3548.
|
|
310
322
|
|
|
311
|
-
|
|
323
|
+
If you would like to contribute to the development of this model or suggest improvements, we encourage you to contact the authors. Additionally, if you encounter any issues while running the software, your feedback is highly appreciated, and we are happy to assist you.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MultiMM
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.22
|
|
4
4
|
Summary: A tool for chromatin modeling from nucleosomes to chromosomal territories.
|
|
5
5
|
Home-page: https://github.com/SFGLab/MultiMM
|
|
6
6
|
Author: Sebastian Korsak
|
|
@@ -73,14 +73,17 @@ PyPI software: https://pypi.org/project/MultiMM/.
|
|
|
73
73
|
|
|
74
74
|
## Input Data
|
|
75
75
|
|
|
76
|
-
### Loops (bedpe file)
|
|
77
76
|
MultiMM relies on three types of datasets:
|
|
78
77
|
|
|
79
78
|
- Loop interactions in `bedpe` format (mandatory).
|
|
80
79
|
- Compartmentalization data in `bed` format (optional).
|
|
81
80
|
- ATAC-Seq p-value data in `.BigWig` format (optional).
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
### Loops (bedpe file)
|
|
83
|
+
|
|
84
|
+
For **loop interactions**, users must provide a file describing interactions between anchor 1 and anchor 2, along with their strength.
|
|
85
|
+
|
|
86
|
+
The file must be in .bedpe format, contain 7 columns, and must not include a header.
|
|
84
87
|
|
|
85
88
|
```text
|
|
86
89
|
chr10 100225000 100230000 chr10 100420000 100425000 95
|
|
@@ -89,9 +92,12 @@ chr10 101190000 101195000 chr10 101370000 101375000 152
|
|
|
89
92
|
chr10 101190000 101200000 chr10 101470000 101480000 181
|
|
90
93
|
chr10 101600000 101605000 chr10 101805000 101810000 152
|
|
91
94
|
```
|
|
95
|
+
The file can include interactions from all chromosomes; MultiMM will automatically handle them.
|
|
96
|
+
|
|
97
|
+
For single-cell data, users should prepare the file by setting the second and third columns identical (as well as the fifth and sixth columns) and set the strength value to 1.
|
|
98
|
+
|
|
92
99
|
|
|
93
100
|
### Compartments
|
|
94
|
-
The file may contain interactions for all chromosomes, which MultiMM can automatically model. For single-cell data, users can provide a file with the second and third columns identical (the same for the fifth and sixth columns) and strength set to 1.
|
|
95
101
|
|
|
96
102
|
For **(sub)compartment interactions**, the file should be in the format produced by the CALDER software: https://github.com/CSOgroup/CALDER2. Users do not need to run CALDER specifically, but the file format must match. The file should contain at least the first four columns with chromosome, regions, and the subcompartment label. Example:
|
|
97
103
|
|
|
@@ -118,15 +124,13 @@ chr1 1400000 1500000 1.145813878361721
|
|
|
118
124
|
|
|
119
125
|
### Nucleosomes
|
|
120
126
|
|
|
121
|
-
For
|
|
122
|
-
|
|
123
|
-
**Note:** At present, MultiMM only works for human genome data. The code may run for other organisms with some debugging and modifications. We hope that it will be generalized in future versions. *MultiMM can run for different types of datasets. It is possible to call loops from any kind of experiment: Hi-C, scHi-C, ChIA-PET, Hi-ChIP. However, we cannot guarantee that the default choice of parameters is the most appropriate one for any dataset. Therefore, the user should test it and check the convergence of the algorithm for their own data. Before making any changes in the parameters, read the method paper carefully and try to understand the function of each force.*
|
|
127
|
+
For ATAC-Seq data, users must provide a BigWig file containing p-values. The pyBigWig library is required to read BigWig files. Note: pyBigWig is not compatible with Windows systems.
|
|
124
128
|
|
|
125
129
|
### Definition of a region based on a gene (optional)
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
To model a genomic region around a specific gene, you can load a `.tsv` file containing gene information. Specify either the gene name or the gene ID.
|
|
128
132
|
|
|
129
|
-
The file should
|
|
133
|
+
The `.tsv` file should be formatted as follows:
|
|
130
134
|
|
|
131
135
|
```text
|
|
132
136
|
gene_id gene_name chromosome start end
|
|
@@ -142,6 +146,13 @@ ENSG00000260972 chr1 5492978 5494674
|
|
|
142
146
|
ENSG00000224340 chr1 10054445 10054781
|
|
143
147
|
```
|
|
144
148
|
|
|
149
|
+
In case that you specify the gene, MultiMM will output a visualization with the gene as well. For example, in the folowing region we can see the polymer structure that is modelled (around the gene) and the gene with red color.
|
|
150
|
+
|
|
151
|
+

|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
> **Note:** Currently, MultiMM is designed to work with human genome data. While it may be possible to run the code on other organisms with additional debugging and modifications, full support for other species is planned for future versions. MultiMM can process various types of datasets. It is capable of calling loops from a range of experiments, including Hi-C, scHi-C, ChIA-PET, and Hi-ChIP. However, we cannot guarantee that the default parameters are optimal for every dataset. Therefore, users are encouraged to test the software carefully and verify the convergence of the algorithm with their own data.Before adjusting any parameters, please read the method paper thoroughly to understand the role and impact of each force.
|
|
155
|
+
|
|
145
156
|
## Usage
|
|
146
157
|
All the model's parameters are specified in a `config.ini` file. This file should have the following format:
|
|
147
158
|
|
|
@@ -225,8 +236,9 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
225
236
|
|
|
226
237
|
| Argument Name | Type | Value | Units | Description |
|
|
227
238
|
|------------------------------|--------------|-------------|---------------|-------------|
|
|
228
|
-
| PLATFORM | str |
|
|
239
|
+
| PLATFORM | str | CPU | CPU | name of the platform. Available choices: CPU, OpenCL, CUDA. |
|
|
229
240
|
| DEVICE | str | None | None | device index for CUDA or OpenCL (count from 0) |
|
|
241
|
+
| MAGIC_ARGUMENT | str | None | None | Helping function to specify parameters of simulation. Choose 'GENE', 'CHROM' or 'GW' depending on the resolution of interest. |
|
|
230
242
|
| INITIAL_STRUCTURE_PATH | str | None | None | Path to CIF file. |
|
|
231
243
|
| BUILD_INITIAL_STRUCTURE | bool | True | None | To build a new initial structure. |
|
|
232
244
|
| INITIAL_STRUCTURE_TYPE | str | hilbert | None | you can choose between: hilbert, circle, rw, confined_rw, self_avoiding_rw, helix, spiral, sphere, knot. |
|
|
@@ -290,7 +302,7 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
290
302
|
| POINTS_PER_NUC | int | 20 | None | The number of points that consist a nucleosome helix. |
|
|
291
303
|
| PHI_NORM | float | pi/5 | None | Zig zag angle. |
|
|
292
304
|
| SIM_RUN_MD | bool | False | None | Do you want to run MD simulation? |
|
|
293
|
-
| SIM_N_STEPS | int |
|
|
305
|
+
| SIM_N_STEPS | int | 10000 | None | Number of steps in MD simulation |
|
|
294
306
|
| SIM_ERROR_TOLERANCE | float | 0.01 | None | Error tolerance for variable MD simulation |
|
|
295
307
|
| SIM_AMD_ALPHA | float | 100.0 | kJ/mol | Alpha of AMD simulation. |
|
|
296
308
|
| SIM_AMD_E | float | 1000.0 | kJ/mol | E (energy) of AMD simulation. |
|
|
@@ -302,10 +314,10 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
302
314
|
| SIM_TEMPERATURE | Quantity | 310 | kelvin | Simulation temperature |
|
|
303
315
|
| TRJ_FRAMES | int | 2000 | None | Number of trajectory frames to save. |
|
|
304
316
|
|
|
305
|
-
##
|
|
317
|
+
## Citation and Cotribution
|
|
306
318
|
|
|
307
|
-
The software is freely distributed under the GNU license and
|
|
319
|
+
The software is freely distributed under the GNU license and is available for use in research, in accordance with the open-source license of MultiMM. If you use the software for research or other purposes, please cite the following paper:
|
|
308
320
|
|
|
309
|
-
- Korsak, Sevastianos, Krzysztof Banecki, and Dariusz Plewczynski. "Multiscale molecular modeling of chromatin with MultiMM: From nucleosomes to the whole genome." Computational and Structural Biotechnology Journal 23 (2024): 3537
|
|
321
|
+
- Korsak, Sevastianos, Krzysztof Banecki, and Dariusz Plewczynski. "Multiscale molecular modeling of chromatin with MultiMM: From nucleosomes to the whole genome." Computational and Structural Biotechnology Journal 23 (2024): 3537–3548.
|
|
310
322
|
|
|
311
|
-
|
|
323
|
+
If you would like to contribute to the development of this model or suggest improvements, we encourage you to contact the authors. Additionally, if you encounter any issues while running the software, your feedback is highly appreciated, and we are happy to assist you.
|
|
@@ -32,14 +32,17 @@ PyPI software: https://pypi.org/project/MultiMM/.
|
|
|
32
32
|
|
|
33
33
|
## Input Data
|
|
34
34
|
|
|
35
|
-
### Loops (bedpe file)
|
|
36
35
|
MultiMM relies on three types of datasets:
|
|
37
36
|
|
|
38
37
|
- Loop interactions in `bedpe` format (mandatory).
|
|
39
38
|
- Compartmentalization data in `bed` format (optional).
|
|
40
39
|
- ATAC-Seq p-value data in `.BigWig` format (optional).
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
### Loops (bedpe file)
|
|
42
|
+
|
|
43
|
+
For **loop interactions**, users must provide a file describing interactions between anchor 1 and anchor 2, along with their strength.
|
|
44
|
+
|
|
45
|
+
The file must be in .bedpe format, contain 7 columns, and must not include a header.
|
|
43
46
|
|
|
44
47
|
```text
|
|
45
48
|
chr10 100225000 100230000 chr10 100420000 100425000 95
|
|
@@ -48,9 +51,12 @@ chr10 101190000 101195000 chr10 101370000 101375000 152
|
|
|
48
51
|
chr10 101190000 101200000 chr10 101470000 101480000 181
|
|
49
52
|
chr10 101600000 101605000 chr10 101805000 101810000 152
|
|
50
53
|
```
|
|
54
|
+
The file can include interactions from all chromosomes; MultiMM will automatically handle them.
|
|
55
|
+
|
|
56
|
+
For single-cell data, users should prepare the file by setting the second and third columns identical (as well as the fifth and sixth columns) and set the strength value to 1.
|
|
57
|
+
|
|
51
58
|
|
|
52
59
|
### Compartments
|
|
53
|
-
The file may contain interactions for all chromosomes, which MultiMM can automatically model. For single-cell data, users can provide a file with the second and third columns identical (the same for the fifth and sixth columns) and strength set to 1.
|
|
54
60
|
|
|
55
61
|
For **(sub)compartment interactions**, the file should be in the format produced by the CALDER software: https://github.com/CSOgroup/CALDER2. Users do not need to run CALDER specifically, but the file format must match. The file should contain at least the first four columns with chromosome, regions, and the subcompartment label. Example:
|
|
56
62
|
|
|
@@ -77,15 +83,13 @@ chr1 1400000 1500000 1.145813878361721
|
|
|
77
83
|
|
|
78
84
|
### Nucleosomes
|
|
79
85
|
|
|
80
|
-
For
|
|
81
|
-
|
|
82
|
-
**Note:** At present, MultiMM only works for human genome data. The code may run for other organisms with some debugging and modifications. We hope that it will be generalized in future versions. *MultiMM can run for different types of datasets. It is possible to call loops from any kind of experiment: Hi-C, scHi-C, ChIA-PET, Hi-ChIP. However, we cannot guarantee that the default choice of parameters is the most appropriate one for any dataset. Therefore, the user should test it and check the convergence of the algorithm for their own data. Before making any changes in the parameters, read the method paper carefully and try to understand the function of each force.*
|
|
86
|
+
For ATAC-Seq data, users must provide a BigWig file containing p-values. The pyBigWig library is required to read BigWig files. Note: pyBigWig is not compatible with Windows systems.
|
|
83
87
|
|
|
84
88
|
### Definition of a region based on a gene (optional)
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
To model a genomic region around a specific gene, you can load a `.tsv` file containing gene information. Specify either the gene name or the gene ID.
|
|
87
91
|
|
|
88
|
-
The file should
|
|
92
|
+
The `.tsv` file should be formatted as follows:
|
|
89
93
|
|
|
90
94
|
```text
|
|
91
95
|
gene_id gene_name chromosome start end
|
|
@@ -101,6 +105,13 @@ ENSG00000260972 chr1 5492978 5494674
|
|
|
101
105
|
ENSG00000224340 chr1 10054445 10054781
|
|
102
106
|
```
|
|
103
107
|
|
|
108
|
+
In case that you specify the gene, MultiMM will output a visualization with the gene as well. For example, in the folowing region we can see the polymer structure that is modelled (around the gene) and the gene with red color.
|
|
109
|
+
|
|
110
|
+

|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
> **Note:** Currently, MultiMM is designed to work with human genome data. While it may be possible to run the code on other organisms with additional debugging and modifications, full support for other species is planned for future versions. MultiMM can process various types of datasets. It is capable of calling loops from a range of experiments, including Hi-C, scHi-C, ChIA-PET, and Hi-ChIP. However, we cannot guarantee that the default parameters are optimal for every dataset. Therefore, users are encouraged to test the software carefully and verify the convergence of the algorithm with their own data.Before adjusting any parameters, please read the method paper thoroughly to understand the role and impact of each force.
|
|
114
|
+
|
|
104
115
|
## Usage
|
|
105
116
|
All the model's parameters are specified in a `config.ini` file. This file should have the following format:
|
|
106
117
|
|
|
@@ -184,8 +195,9 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
184
195
|
|
|
185
196
|
| Argument Name | Type | Value | Units | Description |
|
|
186
197
|
|------------------------------|--------------|-------------|---------------|-------------|
|
|
187
|
-
| PLATFORM | str |
|
|
198
|
+
| PLATFORM | str | CPU | CPU | name of the platform. Available choices: CPU, OpenCL, CUDA. |
|
|
188
199
|
| DEVICE | str | None | None | device index for CUDA or OpenCL (count from 0) |
|
|
200
|
+
| MAGIC_ARGUMENT | str | None | None | Helping function to specify parameters of simulation. Choose 'GENE', 'CHROM' or 'GW' depending on the resolution of interest. |
|
|
189
201
|
| INITIAL_STRUCTURE_PATH | str | None | None | Path to CIF file. |
|
|
190
202
|
| BUILD_INITIAL_STRUCTURE | bool | True | None | To build a new initial structure. |
|
|
191
203
|
| INITIAL_STRUCTURE_TYPE | str | hilbert | None | you can choose between: hilbert, circle, rw, confined_rw, self_avoiding_rw, helix, spiral, sphere, knot. |
|
|
@@ -249,7 +261,7 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
249
261
|
| POINTS_PER_NUC | int | 20 | None | The number of points that consist a nucleosome helix. |
|
|
250
262
|
| PHI_NORM | float | pi/5 | None | Zig zag angle. |
|
|
251
263
|
| SIM_RUN_MD | bool | False | None | Do you want to run MD simulation? |
|
|
252
|
-
| SIM_N_STEPS | int |
|
|
264
|
+
| SIM_N_STEPS | int | 10000 | None | Number of steps in MD simulation |
|
|
253
265
|
| SIM_ERROR_TOLERANCE | float | 0.01 | None | Error tolerance for variable MD simulation |
|
|
254
266
|
| SIM_AMD_ALPHA | float | 100.0 | kJ/mol | Alpha of AMD simulation. |
|
|
255
267
|
| SIM_AMD_E | float | 1000.0 | kJ/mol | E (energy) of AMD simulation. |
|
|
@@ -261,10 +273,10 @@ Therefore, it is advisable to read the paper and understand well the meaning of
|
|
|
261
273
|
| SIM_TEMPERATURE | Quantity | 310 | kelvin | Simulation temperature |
|
|
262
274
|
| TRJ_FRAMES | int | 2000 | None | Number of trajectory frames to save. |
|
|
263
275
|
|
|
264
|
-
##
|
|
276
|
+
## Citation and Cotribution
|
|
265
277
|
|
|
266
|
-
The software is freely distributed under the GNU license and
|
|
278
|
+
The software is freely distributed under the GNU license and is available for use in research, in accordance with the open-source license of MultiMM. If you use the software for research or other purposes, please cite the following paper:
|
|
267
279
|
|
|
268
|
-
- Korsak, Sevastianos, Krzysztof Banecki, and Dariusz Plewczynski. "Multiscale molecular modeling of chromatin with MultiMM: From nucleosomes to the whole genome." Computational and Structural Biotechnology Journal 23 (2024): 3537
|
|
280
|
+
- Korsak, Sevastianos, Krzysztof Banecki, and Dariusz Plewczynski. "Multiscale molecular modeling of chromatin with MultiMM: From nucleosomes to the whole genome." Computational and Structural Biotechnology Journal 23 (2024): 3537–3548.
|
|
269
281
|
|
|
270
|
-
|
|
282
|
+
If you would like to contribute to the development of this model or suggest improvements, we encourage you to contact the authors. Additionally, if you encounter any issues while running the software, your feedback is highly appreciated, and we are happy to assist you.
|
|
@@ -6,7 +6,7 @@ with open('README.md', 'r', encoding='utf-8') as f:
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name='MultiMM', # Package name
|
|
9
|
-
version='1.0.
|
|
9
|
+
version='1.0.22', # Version of the software
|
|
10
10
|
description='A tool for chromatin modeling from nucleosomes to chromosomal territories.',
|
|
11
11
|
long_description=long_description,
|
|
12
12
|
long_description_content_type='text/markdown',
|
|
@@ -15,6 +15,9 @@ setup(
|
|
|
15
15
|
url='https://github.com/SFGLab/MultiMM', # GitHub repository URL
|
|
16
16
|
license='GNU General Public License v3.0',
|
|
17
17
|
packages=find_packages(include=['simulation', 'simulation.*']),
|
|
18
|
+
package_data={
|
|
19
|
+
'simulation': ['forcefields/*'],
|
|
20
|
+
},
|
|
18
21
|
include_package_data=True,
|
|
19
22
|
install_requires=[ # List your package dependencies here
|
|
20
23
|
'numpy',
|
|
@@ -132,8 +132,9 @@ available_platforms = [mm.Platform.getPlatform(i).getName() for i in range(mm.Pl
|
|
|
132
132
|
|
|
133
133
|
args = ListOfArgs([
|
|
134
134
|
# Platform settings
|
|
135
|
-
Arg('PLATFORM', help=f"name of the platform. Available choices: {' '.join(available_platforms)}", type=str, default='', val=''),
|
|
135
|
+
Arg('PLATFORM', help=f"name of the platform. Available choices: {' '.join(available_platforms)}", type=str, default='CPU', val='CPU'),
|
|
136
136
|
Arg('DEVICE', help="device index for CUDA or OpenCL (count from 0)", type=str, default='', val=''),
|
|
137
|
+
Arg('MAGIC_ARGUMENT', help="Choose 'GENE' or 'REGION' for gene or TAD level, 'CHROM' for chromosome leve, and 'GW' for genome level. It will setup some parameters for you and print you helpful comments.", type=str, default='', val=''),
|
|
137
138
|
|
|
138
139
|
# Input data
|
|
139
140
|
Arg('INITIAL_STRUCTURE_PATH', help="Path to CIF file.", type=str, default='', val=''),
|
|
@@ -224,7 +225,7 @@ args = ListOfArgs([
|
|
|
224
225
|
|
|
225
226
|
# Simulation parameters
|
|
226
227
|
Arg('SIM_RUN_MD', help='Do you want to run MD simulation?', type=bool, default='False', val='False'),
|
|
227
|
-
Arg('SIM_N_STEPS', help='Number of steps in MD simulation', type=int, default='', val=''),
|
|
228
|
+
Arg('SIM_N_STEPS', help='Number of steps in MD simulation', type=int, default='10000', val='10000'),
|
|
228
229
|
Arg('SIM_ERROR_TOLERANCE', help='Error tolerance for variable MD simulation', type=float, default='0.01', val='0.01'),
|
|
229
230
|
Arg('SIM_AMD_ALPHA', help='Alpha of AMD simulation.', type=float, default='100.0', val='100.0'),
|
|
230
231
|
Arg('SIM_AMD_E', help='E (energy) of AMD simulation.', type=float, default='1000.0', val='1000.0'),
|
|
@@ -237,4 +238,4 @@ args = ListOfArgs([
|
|
|
237
238
|
|
|
238
239
|
# Trajectory settings
|
|
239
240
|
Arg('TRJ_FRAMES', help='Number of trajectory frames to save.', type=int, default='2000', val='2000'),
|
|
240
|
-
])
|
|
241
|
+
])
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
<ForceField>
|
|
3
|
+
|
|
4
|
+
<AtomTypes>
|
|
5
|
+
<!-- theoretical mass of chromatin in a.m.u. -->
|
|
6
|
+
<Type name="0" class="DNA" element="C" mass="148.0"/>
|
|
7
|
+
<Type name="1" class="HIS" element="H" mass="1529.0"/>
|
|
8
|
+
<Type name="2" class="HIS" element="H" mass="1529.0"/>
|
|
9
|
+
<Type name="3" class="HIS" element="H" mass="1529.0"/>
|
|
10
|
+
<Type name="4" class="HIS" element="H" mass="1529.0"/>
|
|
11
|
+
</AtomTypes>
|
|
12
|
+
|
|
13
|
+
<Residues>
|
|
14
|
+
|
|
15
|
+
<Residue name="ALB">
|
|
16
|
+
<Atom name="CB" type="0"/>
|
|
17
|
+
<ExternalBond atomName="CB"/>
|
|
18
|
+
</Residue>
|
|
19
|
+
|
|
20
|
+
<Residue name="ALA">
|
|
21
|
+
<Atom name="CA" type="0"/>
|
|
22
|
+
<ExternalBond atomName="CA"/>
|
|
23
|
+
<ExternalBond atomName="CA"/>
|
|
24
|
+
</Residue>
|
|
25
|
+
|
|
26
|
+
<Residue name="HXX">
|
|
27
|
+
<Atom name="HIA" type="1"/>
|
|
28
|
+
<Atom name="HIB" type="2"/>
|
|
29
|
+
<Atom name="HIC" type="3"/>
|
|
30
|
+
<Atom name="HID" type="4"/>
|
|
31
|
+
<Bond atomName1="HIA" atomName2="HIB" />
|
|
32
|
+
<Bond atomName1="HIA" atomName2="HIC" />
|
|
33
|
+
<Bond atomName1="HIA" atomName2="HID" />
|
|
34
|
+
<Bond atomName1="HIB" atomName2="HIC" />
|
|
35
|
+
<Bond atomName1="HIB" atomName2="HID" />
|
|
36
|
+
<Bond atomName1="HIC" atomName2="HID" />
|
|
37
|
+
</Residue>
|
|
38
|
+
|
|
39
|
+
</Residues>
|
|
40
|
+
|
|
41
|
+
<HarmonicBondForce>
|
|
42
|
+
<Bond type1="0" type2="0" length="0.1" k="3000000.0"/>
|
|
43
|
+
<!-- Histone Square -->
|
|
44
|
+
<Bond type1="1" type2="2" length="0.118" k="300000.0" />
|
|
45
|
+
<Bond type1="1" type2="4" length="0.118" k="300000.0" />
|
|
46
|
+
<Bond type1="2" type2="3" length="0.118" k="300000.0" />
|
|
47
|
+
<Bond type1="3" type2="4" length="0.118" k="300000.0" />
|
|
48
|
+
|
|
49
|
+
<!-- Histone diagonals -->
|
|
50
|
+
<Bond type1="1" type2="3" length="0.167" k="300000.0" />
|
|
51
|
+
<Bond type1="2" type2="4" length="0.167" k="300000.0" />
|
|
52
|
+
<!--
|
|
53
|
+
diagonal distance - 0.167
|
|
54
|
+
border distance - 0.118
|
|
55
|
+
-->
|
|
56
|
+
</HarmonicBondForce>
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
<CustomNonbondedForce energy="scale*((sigma2+sigma1/r)^12)" bondCutoff="2">
|
|
60
|
+
<GlobalParameter name="scale" defaultValue="5"/>
|
|
61
|
+
<PerParticleParameter name="sigma"/>
|
|
62
|
+
<Atom type="0" sigma="0.1"/>
|
|
63
|
+
<Atom type="1" sigma="0.1"/>
|
|
64
|
+
<Atom type="2" sigma="0.1"/>
|
|
65
|
+
<Atom type="3" sigma="0.1"/>
|
|
66
|
+
<Atom type="4" sigma="0.1"/>
|
|
67
|
+
<!--
|
|
68
|
+
kadlof said
|
|
69
|
+
dna signa = 0.05
|
|
70
|
+
histone sigma = 0.1
|
|
71
|
+
-->
|
|
72
|
+
</CustomNonbondedForce>
|
|
73
|
+
|
|
74
|
+
<!-- 0.12209182 -->
|
|
75
|
+
</ForceField>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<ForceField>
|
|
2
|
+
|
|
3
|
+
<AtomTypes>
|
|
4
|
+
<!-- teoretical mass of 10kb chromatin in a.m.u. -->
|
|
5
|
+
<Type name="0" class="BEAD" element="D" mass="16427.889"/>
|
|
6
|
+
</AtomTypes>
|
|
7
|
+
|
|
8
|
+
<Residues>
|
|
9
|
+
|
|
10
|
+
<Residue name="ALB">
|
|
11
|
+
<Atom name="CB" type="0"/>
|
|
12
|
+
<ExternalBond from="0"/>
|
|
13
|
+
</Residue>
|
|
14
|
+
|
|
15
|
+
<Residue name="ALA">E
|
|
16
|
+
<Atom name="CA" type="0"/>
|
|
17
|
+
<ExternalBond from="0"/>
|
|
18
|
+
<ExternalBond from="0"/>
|
|
19
|
+
</Residue>
|
|
20
|
+
|
|
21
|
+
</Residues>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
</ForceField>
|
|
@@ -282,7 +282,7 @@ def build_init_mmcif(n_dna,chrom_ends,psf=True,path='',curve='hilbert',scale=5):
|
|
|
282
282
|
|
|
283
283
|
with open(mmcif_file_name, 'w') as f:
|
|
284
284
|
f.write(mmcif_file_content)
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
if psf:
|
|
287
287
|
generate_psf(n_dna,path+'MultiMM.psf')
|
|
288
288
|
|
|
@@ -537,4 +537,4 @@ def load_from_file(path,num_pts):
|
|
|
537
537
|
u_fine = np.linspace(0,1,num_pts)
|
|
538
538
|
x_fine, y_fine, z_fine = interpolate.splev(u_fine, tck)
|
|
539
539
|
points = 20*np.vstack((x_fine, y_fine, z_fine)).T
|
|
540
|
-
return points
|
|
540
|
+
return points
|
|
@@ -19,28 +19,37 @@ class MultiMM:
|
|
|
19
19
|
------------
|
|
20
20
|
args: list of arguments imported from config.ini file.
|
|
21
21
|
'''
|
|
22
|
+
# Import args
|
|
23
|
+
self.args = args
|
|
24
|
+
self.convenient_argument_changer()
|
|
25
|
+
|
|
22
26
|
# Output folder
|
|
23
27
|
self.ms, self.ns, self.ds, self.chr_ends, self.Cs = None, None, None, None, None
|
|
24
28
|
|
|
25
29
|
# Make save directory
|
|
26
30
|
self.save_path = args.OUT_PATH+'/'
|
|
27
31
|
# Create main save directory and subdirectories if they don't exist
|
|
28
|
-
os.makedirs(os.path.join(self.save_path, '
|
|
29
|
-
os.makedirs(os.path.join(self.save_path, 'chromosomes'), exist_ok=True)
|
|
32
|
+
os.makedirs(os.path.join(self.save_path, 'md_frames'), exist_ok=True)
|
|
30
33
|
os.makedirs(os.path.join(self.save_path, 'plots'), exist_ok=True)
|
|
31
|
-
|
|
32
|
-
self.
|
|
34
|
+
if args.GENE_ID==None and args.GENE_NAME==None and args.LOC_START==None: os.makedirs(os.path.join(self.save_path,'plots','chromosomes'), exist_ok=True)
|
|
35
|
+
os.makedirs(os.path.join(self.save_path, 'metadata'), exist_ok=True)
|
|
36
|
+
os.makedirs(os.path.join(self.save_path, 'model'), exist_ok=True)
|
|
37
|
+
if args.GENE_ID==None and args.GENE_NAME==None and args.LOC_START==None: os.makedirs(os.path.join(self.save_path,'model','chromosomes'), exist_ok=True)
|
|
38
|
+
save_args_to_txt(self.args,args.OUT_PATH+'/metadata/parameters.txt')
|
|
39
|
+
|
|
33
40
|
chrom = args.CHROM
|
|
34
41
|
coords = [args.LOC_START,args.LOC_END] if args.LOC_START!=None else None
|
|
35
42
|
|
|
36
43
|
if (args.GENE_TSV!=None):
|
|
37
44
|
if args.GENE_ID!=None:
|
|
38
45
|
print('Gene ID:',args.GENE_ID)
|
|
39
|
-
chrom, coords = get_gene_region(gene_tsv=args.GENE_TSV,gene_id=args.GENE_ID,window_size=args.GENE_WINDOW)
|
|
46
|
+
chrom, coords, gene_coords = get_gene_region(gene_tsv=args.GENE_TSV,gene_id=args.GENE_ID,window_size=args.GENE_WINDOW)
|
|
47
|
+
self.gene_start, self.gene_end = ((gene_coords[0]-coords[0])*self.args.N_BEADS)//(coords[1]-coords[0]), ((gene_coords[1]-coords[0])*self.args.N_BEADS)//(coords[1]-coords[0])
|
|
40
48
|
print(f'We model the region {coords[0]}-{coords[1]} of chrom {chrom} of the gene {args.GENE_ID}.\n')
|
|
41
49
|
elif args.GENE_NAME!=None:
|
|
42
50
|
print('Gene name:',args.GENE_NAME)
|
|
43
|
-
chrom, coords = get_gene_region(gene_tsv=args.GENE_TSV,gene_name=args.GENE_NAME,window_size=args.GENE_WINDOW)
|
|
51
|
+
chrom, coords, gene_coords = get_gene_region(gene_tsv=args.GENE_TSV,gene_name=args.GENE_NAME,window_size=args.GENE_WINDOW)
|
|
52
|
+
self.gene_start, self.gene_end = ((gene_coords[0]-coords[0])*self.args.N_BEADS)//(coords[1]-coords[0]), ((gene_coords[1]-coords[0])*self.args.N_BEADS)//(coords[1]-coords[0])
|
|
44
53
|
print(f'We model the region {coords[0]}-{coords[1]} of chrom {chrom} of the gene {args.GENE_NAME}.\n')
|
|
45
54
|
else:
|
|
46
55
|
raise InterruptedError('You did not provide gene name or ID.')
|
|
@@ -54,18 +63,21 @@ class MultiMM:
|
|
|
54
63
|
elif args.COMPARTMENT_PATH!=None:
|
|
55
64
|
if args.COMPARTMENT_PATH.lower().endswith('.bed'):
|
|
56
65
|
self.Cs, self.chr_ends, self.chrom_idxs = import_bed(bed_file=args.COMPARTMENT_PATH,N_beads=self.args.N_BEADS,\
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
chrom=chrom,coords=coords,\
|
|
67
|
+
save_path=self.save_path,\
|
|
68
|
+
shuffle=args.SHUFFLE_CHROMS,\
|
|
69
|
+
seed=args.SHUFFLING_SEED)
|
|
60
70
|
else:
|
|
61
71
|
raise InterruptedError('Compartments file should be in .bed format.')
|
|
62
72
|
|
|
63
73
|
# Loops
|
|
64
74
|
if args.LOOPS_PATH.lower().endswith('.bedpe'):
|
|
65
75
|
self.ms, self.ns, self.ds, self.chr_ends, self.chrom_idxs = import_mns_from_bedpe(bedpe_file = args.LOOPS_PATH,N_beads=self.args.N_BEADS,\
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
coords = coords, chrom=chrom,\
|
|
77
|
+
path=self.save_path,\
|
|
78
|
+
shuffle=args.SHUFFLE_CHROMS,\
|
|
79
|
+
seed=args.SHUFFLING_SEED,\
|
|
80
|
+
down_prob=args.DOWNSAMPLING_PROB)
|
|
69
81
|
else:
|
|
70
82
|
raise InterruptedError('You did not provide appropriate loop file. Loop .bedpe file is obligatory.')
|
|
71
83
|
|
|
@@ -77,7 +89,7 @@ class MultiMM:
|
|
|
77
89
|
else:
|
|
78
90
|
raise InterruptedError('ATAC-Seq file should be in .bw or .BigWig format.')
|
|
79
91
|
|
|
80
|
-
if self.args.CHROM=='': write_chrom_colors(self.chr_ends,self.chrom_idxs,name=self.save_path+'MultiMM_chromosome_colors.cmd')
|
|
92
|
+
if self.args.CHROM=='': write_chrom_colors(self.chr_ends,self.chrom_idxs,name=self.save_path+'metadata/MultiMM_chromosome_colors.cmd')
|
|
81
93
|
|
|
82
94
|
# Chromosomes
|
|
83
95
|
self.chrom_spin, self.chrom_strength = np.zeros(self.args.N_BEADS), np.zeros(self.args.N_BEADS)
|
|
@@ -86,6 +98,44 @@ class MultiMM:
|
|
|
86
98
|
self.chrom_spin[self.chr_ends[i]:self.chr_ends[i+1]] = self.chrom_idxs[i]
|
|
87
99
|
self.chrom_strength[self.chr_ends[i]:self.chr_ends[i+1]] = chrom_strength[i]
|
|
88
100
|
|
|
101
|
+
def convenient_argument_changer(self):
|
|
102
|
+
self.args.NUC_DO_INTERPOLATION = False
|
|
103
|
+
self.args.ATACSEQ_PATH = None
|
|
104
|
+
if self.args.MAGIC_ARGUMENT=='GENE' or self.args.MAGIC_ARGUMENT=='REGION' or self.args.MAGIC_ARGUMENT=='TAD':
|
|
105
|
+
print('\033[91m' + 'MAGIC COMMENT: For gene level it is needed to provide a loops_path, a gene_tsv file, and a gene_name or gene_id to specify the target gene of interest.'+ '\033[0m')
|
|
106
|
+
self.args.N_BEADS=1000
|
|
107
|
+
self.args.SC_USE_SPHERICAL_CONTAINER=False
|
|
108
|
+
self.args.CHB_USE_CHROMOSOMAL_BLOCKS=False
|
|
109
|
+
self.args.SCB_USE_SUBCOMPARTMENT_BLOCKS=False
|
|
110
|
+
self.args.COB_USE_COMPARTMENT_BLOCKS=False
|
|
111
|
+
self.args.IBL_USE_B_LAMINA_INTERACTION=False
|
|
112
|
+
self.args.CF_USE_CENTRAL_FORCE=False
|
|
113
|
+
self.args.SHUFFLE_CHROMS=False
|
|
114
|
+
self.args.SIM_RUN_MD=True
|
|
115
|
+
self.args.SIM_N_STEPS=10000
|
|
116
|
+
elif self.args.MAGIC_ARGUMENT=='CHROMOSOME' or self.args.MAGIC_ARGUMENT=='CHROM' or self.args.MAGIC_ARGUMENT=='COMP':
|
|
117
|
+
print('\033[91m' + 'MAGIC COMMENT: For chromosome level it is needed to provide a loops_path. Do not forget to specify the beggining and end of your chromosome. You can remove the centromers or telomers that are in the boundaries. You can optionally add an eigenvector_tsv to include block-copolymer forces.'+ '\033[0m')
|
|
118
|
+
self.args.N_BEADS=20000
|
|
119
|
+
self.args.SC_USE_SPHERICAL_CONTAINER=False
|
|
120
|
+
self.args.CHB_USE_CHROMOSOMAL_BLOCKS=False
|
|
121
|
+
self.args.SCB_USE_SUBCOMPARTMENT_BLOCKS=False
|
|
122
|
+
self.args.COB_USE_COMPARTMENT_BLOCKS=True if self.args.EIGENVECTOR_TSV!=None or self.args.COMPARTMENT_PATH!=None else False
|
|
123
|
+
self.args.IBL_USE_B_LAMINA_INTERACTION=False
|
|
124
|
+
self.args.CF_USE_CENTRAL_FORCE=False
|
|
125
|
+
self.args.SIM_RUN_MD=True
|
|
126
|
+
self.args.SIM_N_STEPS=10000
|
|
127
|
+
elif self.args.MAGIC_ARGUMENT=='GW' or self.args.MAGIC_ARGUMENT=='GENOME':
|
|
128
|
+
print('\033[91m' + 'MAGIC COMMENT: For gw level it is needed to provide a loops_path. You can optionally add an eigenvector_tsv to include block-copolymer forces.'+ '\033[0m')
|
|
129
|
+
self.args.N_BEADS=200000
|
|
130
|
+
self.args.SC_USE_SPHERICAL_CONTAINER=True
|
|
131
|
+
self.args.CHB_USE_CHROMOSOMAL_BLOCKS=False
|
|
132
|
+
self.args.SCB_USE_SUBCOMPARTMENT_BLOCKS=False
|
|
133
|
+
self.args.COB_USE_COMPARTMENT_BLOCKS=True if self.args.eigenvec_tsv!=None or self.args.COMPARTMENT_PATH!=None else False
|
|
134
|
+
self.args.IBL_USE_B_LAMINA_INTERACTION=True
|
|
135
|
+
self.args.CF_USE_CENTRAL_FORCE=True
|
|
136
|
+
self.args.SIM_RUN_MD=False
|
|
137
|
+
self.args.SIM_N_STEPS=10000
|
|
138
|
+
|
|
89
139
|
def add_evforce(self):
|
|
90
140
|
sigma = self.args.LE_HARMONIC_BOND_R0
|
|
91
141
|
self.ev_force = mm.CustomNonbondedForce(f'epsilon*(sigma/(r+r_small))^{self.args.EV_POWER}')
|
|
@@ -206,11 +256,11 @@ class MultiMM:
|
|
|
206
256
|
if self.args.BUILD_INITIAL_STRUCTURE:
|
|
207
257
|
print('\nCreating initial structure...')
|
|
208
258
|
comp_mode = 'compartments' if np.all(self.Cs!=None) and len(np.unique(self.Cs))<=3 else 'subcompartments'
|
|
209
|
-
if np.all(self.Cs!=None): write_cmm(self.Cs,name=self.save_path+'MultiMM_compartment_colors.cmd')
|
|
259
|
+
if np.all(self.Cs!=None): write_cmm(self.Cs,name=self.save_path+'metadata/MultiMM_compartment_colors.cmd')
|
|
210
260
|
pdb_content = build_init_mmcif(n_dna=self.args.N_BEADS,chrom_ends=self.chr_ends,\
|
|
211
|
-
path=self.save_path,curve=self.args.INITIAL_STRUCTURE_TYPE,scale=(self.radius1+self.radius2)/2)
|
|
261
|
+
path=self.save_path+'metadata/',curve=self.args.INITIAL_STRUCTURE_TYPE,scale=(self.radius1+self.radius2)/2)
|
|
212
262
|
print('---Done!---')
|
|
213
|
-
self.pdb = PDBxFile(self.save_path+'MultiMM_init.cif') if self.args.INITIAL_STRUCTURE_path==None or build_init_mmcif else PDBxFile(self.args.INITIAL_STRUCTURE_PATH)
|
|
263
|
+
self.pdb = PDBxFile(self.save_path+'metadata/MultiMM_init.cif') if self.args.INITIAL_STRUCTURE_path==None or build_init_mmcif else PDBxFile(self.args.INITIAL_STRUCTURE_PATH)
|
|
214
264
|
self.mass_center = np.average(get_coordinates_mm(self.pdb.positions),axis=0)
|
|
215
265
|
forcefield = ForceField(self.args.FORCEFIELD_PATH)
|
|
216
266
|
self.system = forcefield.createSystem(self.pdb.topology)
|
|
@@ -251,10 +301,13 @@ class MultiMM:
|
|
|
251
301
|
# Try to use CUDA or OpenCL, fall back to CPU if not available
|
|
252
302
|
try:
|
|
253
303
|
platform = mm.Platform.getPlatformByName(self.args.PLATFORM)
|
|
254
|
-
|
|
255
|
-
|
|
304
|
+
|
|
305
|
+
# Only check if user *wanted* GPU
|
|
306
|
+
if self.args.PLATFORM in ["CUDA", "OpenCL"]:
|
|
307
|
+
if platform.getName() not in ["CUDA", "OpenCL"]:
|
|
308
|
+
raise Exception(f"{self.args.PLATFORM} is not CUDA or OpenCL")
|
|
256
309
|
except Exception as e:
|
|
257
|
-
print(f"Failed to find
|
|
310
|
+
print(f"Failed to find {self.args.PLATFORM}: {e}. Falling back to CPU.")
|
|
258
311
|
platform = mm.Platform.getPlatformByName('CPU')
|
|
259
312
|
|
|
260
313
|
# Run the simulation
|
|
@@ -272,7 +325,7 @@ class MultiMM:
|
|
|
272
325
|
|
|
273
326
|
# Save the minimized structure
|
|
274
327
|
self.state = self.simulation.context.getState(getPositions=True)
|
|
275
|
-
PDBxFile.writeFile(self.pdb.topology, self.state.getPositions(), open(self.save_path+'MultiMM_minimized.cif', 'w'))
|
|
328
|
+
PDBxFile.writeFile(self.pdb.topology, self.state.getPositions(), open(self.save_path+'model/MultiMM_minimized.cif', 'w'))
|
|
276
329
|
print(f"--- Energy minimization done!! Executed in {(time.time() - start_time)//3600:.0f} hours, {(time.time() - start_time)%3600//60:.0f} minutes and {(time.time() - start_time)%60:.0f} seconds. :D ---\n")
|
|
277
330
|
print('---Done!---')
|
|
278
331
|
|
|
@@ -280,30 +333,30 @@ class MultiMM:
|
|
|
280
333
|
V = get_coordinates_mm(self.state.getPositions())
|
|
281
334
|
for i in range(len(self.chr_ends)-1):
|
|
282
335
|
write_mmcif_chrom(coords=10*V[self.chr_ends[i]:self.chr_ends[i+1]],\
|
|
283
|
-
path=self.save_path+f'chromosomes/MultiMM_minimized_{chrs[self.chrom_idxs[i]]}.cif')
|
|
336
|
+
path=self.save_path+f'model/chromosomes/MultiMM_minimized_{chrs[self.chrom_idxs[i]]}.cif')
|
|
284
337
|
|
|
285
338
|
def run_md(self):
|
|
286
339
|
self.simulation.reporters.append(StateDataReporter(stdout, self.args.SIM_SAMPLING_STEP, step=True, totalEnergy=True, kineticEnergy=True ,potentialEnergy=True, temperature=True, separator='\t'))
|
|
287
|
-
self.simulation.reporters.append(DCDReporter(self.save_path+'MultiMM_annealing.dcd', self.args.SIM_N_STEPS//self.args.TRJ_FRAMES))
|
|
340
|
+
self.simulation.reporters.append(DCDReporter(self.save_path+'metadata/MultiMM_annealing.dcd', self.args.SIM_N_STEPS//self.args.TRJ_FRAMES))
|
|
288
341
|
print('Running relaxation...')
|
|
289
342
|
start = time.time()
|
|
290
343
|
for i in range(self.args.SIM_N_STEPS//self.args.SIM_SAMPLING_STEP):
|
|
291
344
|
self.simulation.step(self.args.SIM_SAMPLING_STEP)
|
|
292
345
|
self.state = self.simulation.context.getState(getPositions=True)
|
|
293
|
-
PDBxFile.writeFile(self.pdb.topology, self.state.getPositions(), open(self.save_path+f'
|
|
346
|
+
PDBxFile.writeFile(self.pdb.topology, self.state.getPositions(), open(self.save_path+f'md_frames/frame_{i+1}.cif', 'w'))
|
|
294
347
|
end = time.time()
|
|
295
348
|
elapsed = end - start
|
|
296
349
|
self.state = self.simulation.context.getState(getPositions=True)
|
|
297
|
-
PDBxFile.writeFile(self.pdb.topology, self.state.getPositions(), open(self.save_path+'MultiMM_afterMD.cif', 'w'))
|
|
350
|
+
PDBxFile.writeFile(self.pdb.topology, self.state.getPositions(), open(self.save_path+'model/MultiMM_afterMD.cif', 'w'))
|
|
298
351
|
print(f'Everything is done! Simulation finished succesfully!\nMD finished in {elapsed//3600:.0f} hours, {elapsed%3600//60:.0f} minutes and {elapsed%60:.0f} seconds. ---\n')
|
|
299
352
|
|
|
300
353
|
def nuc_interpolation(self):
|
|
301
354
|
print('Running nucleosome interpolation...')
|
|
302
355
|
start = time.time()
|
|
303
|
-
nuc_interpol = NucleosomeInterpolation(get_coordinates_cif(self.save_path+'MultiMM_minimized.cif'),self.atacseq,\
|
|
356
|
+
nuc_interpol = NucleosomeInterpolation(get_coordinates_cif(self.save_path+'model/MultiMM_minimized.cif'),self.atacseq,\
|
|
304
357
|
self.args.MAX_NUCS_PER_BEAD, self.args.NUC_RADIUS, self.args.POINTS_PER_NUC, self.args.PHI_NORM)
|
|
305
358
|
Vnuc = nuc_interpol.interpolate_structure_with_nucleosomes()
|
|
306
|
-
write_mmcif_chrom(Vnuc,path=self.save_path+f'MultiMM_minimized_with_nucs.cif')
|
|
359
|
+
write_mmcif_chrom(Vnuc,path=self.save_path+f'model/MultiMM_minimized_with_nucs.cif')
|
|
307
360
|
end = time.time()
|
|
308
361
|
elapsed = end - start
|
|
309
362
|
print(f'Nucleosome interpolation finished succesfully in {elapsed//3600:.0f} hours, {elapsed%3600//60:.0f} minutes and {elapsed%60:.0f} seconds.')
|
|
@@ -317,6 +370,33 @@ class MultiMM:
|
|
|
317
370
|
self.r_comp = self.args.SCB_DISTANCE
|
|
318
371
|
else:
|
|
319
372
|
self.r_comp = (self.radius2-self.radius1)/20
|
|
373
|
+
|
|
374
|
+
def make_plots(self):
|
|
375
|
+
is_gw = self.args.GENE_ID==None and self.args.GENE_NAME==None and self.args.LOC_START==None
|
|
376
|
+
is_comp = np.any(self.Cs!=None)
|
|
377
|
+
if is_gw:
|
|
378
|
+
if is_comp: plot_projection(get_coordinates_mm(self.state.getPositions()),self.Cs,save_path=self.save_path)
|
|
379
|
+
viz_chroms(self.save_path,r=0.2,comps=is_comp)
|
|
380
|
+
for i in range(len(self.chr_ends)-1):
|
|
381
|
+
V = get_coordinates_cif(self.save_path+f'model/chromosomes/MultiMM_minimized_{chrs[self.chrom_idxs[i]]}.cif')
|
|
382
|
+
viz_structure(V, r=0.2, cmap='coolwarm', save_path=self.save_path+f'plots/chromosomes/{chrs[self.chrom_idxs[i]]}_minimized_structure.png')
|
|
383
|
+
else:
|
|
384
|
+
if args.GENE_ID!=None or args.GENE_NAME!=None:
|
|
385
|
+
save_chimera_cmd(self.gene_start, self.gene_end, self.args.N_BEADS, cmd_filename=self.save_path+"metadata/chimera_gene_coloring.cmd")
|
|
386
|
+
V = get_coordinates_cif(self.save_path+'metadata/MultiMM_init.cif')
|
|
387
|
+
viz_gene_structure(V, self.gene_start, self.gene_end, r=0.2, cmap='coolwarm', save_path=self.save_path+'plots/initial_structure_gene_coloring.png')
|
|
388
|
+
V = get_coordinates_cif(self.save_path+'model/MultiMM_minimized.cif')
|
|
389
|
+
viz_gene_structure(V, self.gene_start, self.gene_end, r=0.2, cmap='coolwarm', save_path=self.save_path+'plots/minimized_structure_gene_coloring.png')
|
|
390
|
+
if self.args.SIM_RUN_MD:
|
|
391
|
+
V = get_coordinates_cif(self.save_path+'model/MultiMM_afterMD.cif')
|
|
392
|
+
viz_gene_structure(V, self.gene_start, self.gene_end, r=0.2, cmap='coolwarm', save_path=self.save_path+'plots/structure_afterMD_gene_coloring.png')
|
|
393
|
+
V = get_coordinates_cif(self.save_path+'metadata/MultiMM_init.cif')
|
|
394
|
+
viz_structure(V, r=0.2, cmap='coolwarm', save_path=self.save_path+'plots/initial_structure.png')
|
|
395
|
+
V = get_coordinates_cif(self.save_path+'model/MultiMM_minimized.cif')
|
|
396
|
+
viz_structure(V, r=0.2, cmap='coolwarm', save_path=self.save_path+'plots/minimized_structure.png')
|
|
397
|
+
if self.args.SIM_RUN_MD:
|
|
398
|
+
V = get_coordinates_cif(self.save_path+'model/MultiMM_afterMD.cif')
|
|
399
|
+
viz_structure(V, r=0.2, cmap='coolwarm', save_path=self.save_path+'plots/structure_afterMD.png')
|
|
320
400
|
|
|
321
401
|
def run(self):
|
|
322
402
|
'''
|
|
@@ -333,15 +413,15 @@ class MultiMM:
|
|
|
333
413
|
|
|
334
414
|
# Run simulation / Energy minimization
|
|
335
415
|
self.min_energy()
|
|
336
|
-
self.save_chromosomes()
|
|
416
|
+
if args.GENE_ID==None and args.GENE_NAME==None and args.LOC_START==None: self.save_chromosomes()
|
|
337
417
|
|
|
338
418
|
# Run molecular dynamics
|
|
339
419
|
if self.args.SIM_RUN_MD: self.run_md()
|
|
340
420
|
|
|
341
421
|
# Make diagnostic plots
|
|
342
|
-
if self.args.SAVE_PLOTS
|
|
422
|
+
if self.args.SAVE_PLOTS:
|
|
343
423
|
print('Creating and saving plots...')
|
|
344
|
-
|
|
424
|
+
self.make_plots()
|
|
345
425
|
print('Done! :)\n')
|
|
346
426
|
|
|
347
427
|
# Run nucleosome interpolation
|
|
@@ -76,7 +76,8 @@ def polyline_from_points(points):
|
|
|
76
76
|
poly.lines = the_cell
|
|
77
77
|
return poly
|
|
78
78
|
|
|
79
|
-
def viz_structure(V, colors=None, r=0.1, cmap='coolwarm'):
|
|
79
|
+
def viz_structure(V, colors=None, r=0.1, cmap='coolwarm', save_path=None):
|
|
80
|
+
"""Visualize structure V and optionally save it to a file."""
|
|
80
81
|
polyline = polyline_from_points(V)
|
|
81
82
|
polyline["scalars"] = np.arange(polyline.n_points)
|
|
82
83
|
|
|
@@ -85,16 +86,71 @@ def viz_structure(V, colors=None, r=0.1, cmap='coolwarm'):
|
|
|
85
86
|
color_values = (colors - np.min(colors)) / (np.max(colors) - np.min(colors)) # Normalize colors
|
|
86
87
|
polyline["colors"] = color_values # Set colors as point scalars
|
|
87
88
|
polymer = polyline.tube(radius=r)
|
|
88
|
-
polymer.plot(smooth_shading=True, cmap=cmap, scalars="colors", show_scalar_bar=False)
|
|
89
89
|
else:
|
|
90
90
|
polymer = polyline.tube(radius=r)
|
|
91
|
-
|
|
91
|
+
|
|
92
|
+
# Create plotter
|
|
93
|
+
plotter = pv.Plotter(off_screen=True if save_path else False)
|
|
94
|
+
plotter.add_mesh(polymer, smooth_shading=True, cmap=cmap, scalars="colors" if colors is not None else None, show_scalar_bar=False)
|
|
95
|
+
|
|
96
|
+
if save_path:
|
|
97
|
+
plotter.show(screenshot=save_path)
|
|
98
|
+
else:
|
|
99
|
+
plotter.show()
|
|
100
|
+
|
|
101
|
+
def save_chimera_cmd(start, end, total_residues, cmd_filename="coloring.cmd"):
|
|
102
|
+
"""
|
|
103
|
+
Create a Chimera .cmd file:
|
|
104
|
+
- Color residues outside the given region blue.
|
|
105
|
+
- Color residues inside the region red.
|
|
106
|
+
"""
|
|
107
|
+
with open(cmd_filename, "w") as f:
|
|
108
|
+
# Color all residues blue first (except the highlighted region)
|
|
109
|
+
if start > 1:
|
|
110
|
+
f.write(f"color blue :1-{start-1}\n")
|
|
111
|
+
if end < total_residues:
|
|
112
|
+
f.write(f"color blue :{end+1}-{total_residues}\n")
|
|
113
|
+
|
|
114
|
+
# Color the selected region red
|
|
115
|
+
f.write(f"color red :{start}-{end}\n")
|
|
116
|
+
|
|
117
|
+
f.write("focus\n")
|
|
118
|
+
|
|
119
|
+
def viz_gene_structure(V, start, end, r=0.1, cmap='coolwarm', save_path=None):
|
|
120
|
+
"""Visualize structure V, highlight a continuous region in red, rest in blue."""
|
|
121
|
+
polyline = polyline_from_points(V)
|
|
122
|
+
polyline["scalars"] = np.arange(polyline.n_points)
|
|
123
|
+
|
|
124
|
+
# Create colors: 0 for blue, 1 for red
|
|
125
|
+
colors = np.zeros(len(V))
|
|
126
|
+
colors[start:end+1] = 1 # Mark the highlighted region
|
|
127
|
+
|
|
128
|
+
polyline["colors"] = colors
|
|
129
|
+
|
|
130
|
+
# Create tube
|
|
131
|
+
polymer = polyline.tube(radius=r)
|
|
132
|
+
|
|
133
|
+
# Create plotter
|
|
134
|
+
plotter = pv.Plotter(off_screen=True if save_path else False)
|
|
135
|
+
plotter.add_mesh(
|
|
136
|
+
polymer,
|
|
137
|
+
smooth_shading=True,
|
|
138
|
+
scalars="colors",
|
|
139
|
+
cmap=["blue", "red"], # Explicit color map
|
|
140
|
+
show_scalar_bar=False,
|
|
141
|
+
clim=[0, 1] # Force colors 0 and 1
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
if save_path:
|
|
145
|
+
plotter.show(screenshot=save_path)
|
|
146
|
+
else:
|
|
147
|
+
plotter.show()
|
|
92
148
|
|
|
93
149
|
def viz_chroms(sim_path,r=0.1,comps=True):
|
|
94
|
-
cif_path = sim_path + '/MultiMM_minimized.cif'
|
|
95
|
-
chrom_idxs_path = sim_path + '/chrom_idxs.npy'
|
|
96
|
-
chrom_comps_path = sim_path + '/compartments.npy'
|
|
97
|
-
chrom_ends_path = sim_path + '/chrom_lengths.npy'
|
|
150
|
+
cif_path = sim_path + 'model/MultiMM_minimized.cif'
|
|
151
|
+
chrom_idxs_path = sim_path + 'metadata/chrom_idxs.npy'
|
|
152
|
+
chrom_comps_path = sim_path + 'metadata/compartments.npy'
|
|
153
|
+
chrom_ends_path = sim_path + 'metadata/chrom_lengths.npy'
|
|
98
154
|
chrom_idxs = np.load(chrom_idxs_path)
|
|
99
155
|
if comps: comps = np.load(chrom_comps_path)
|
|
100
156
|
chrom_ends = np.load(chrom_ends_path)
|
|
@@ -104,8 +160,8 @@ def viz_chroms(sim_path,r=0.1,comps=True):
|
|
|
104
160
|
for i in range(len(chrom_ends)-1):
|
|
105
161
|
start, end = chrom_ends[i], chrom_ends[i+1]
|
|
106
162
|
chroms[start:end] = chrom_idxs[i]
|
|
107
|
-
viz_structure(V,chroms[:len(V)],cmap='gist_ncar',r=r)
|
|
108
|
-
if comps: viz_structure(V,comps[:len(V)],cmap='coolwarm',r=r)
|
|
163
|
+
viz_structure(V,chroms[:len(V)],cmap='gist_ncar',r=r,save_path=sim_path+'plots/minimized_structure_chromosomes.png')
|
|
164
|
+
if comps: viz_structure(V,comps[:len(V)],cmap='coolwarm',r=r,save_path=sim_path+'plots/minimized_structure_compartments.png')
|
|
109
165
|
|
|
110
166
|
def get_heatmap(cif_file,viz=False,th=1,save=False,save_path=None,vmax=1,vmin=0):
|
|
111
167
|
'''
|
|
@@ -48,35 +48,47 @@ def my_config_parser(config_parser: configparser.ConfigParser) -> List[tuple[str
|
|
|
48
48
|
return args_cp
|
|
49
49
|
|
|
50
50
|
def get_config() -> ListOfArgs:
|
|
51
|
-
"""
|
|
52
|
-
|
|
53
|
-
Then
|
|
54
|
-
|
|
51
|
+
"""Prepare list of arguments.
|
|
52
|
+
First, defaults are set.
|
|
53
|
+
Then, optionally config file values.
|
|
54
|
+
Finally, CLI arguments overwrite everything."""
|
|
55
55
|
|
|
56
|
-
print(
|
|
57
|
-
arg_parser = argparse.ArgumentParser()
|
|
56
|
+
print("Reading config...")
|
|
58
57
|
|
|
58
|
+
# Step 1: Setup argparse
|
|
59
|
+
arg_parser = argparse.ArgumentParser()
|
|
59
60
|
arg_parser.add_argument('-c', '--config_file', help="Specify config file (ini format)", metavar="FILE")
|
|
61
|
+
|
|
60
62
|
for arg in args:
|
|
61
63
|
arg_parser.add_argument(f"--{arg.name.lower()}", help=arg.help)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
name, value =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
|
|
65
|
+
args_ap = arg_parser.parse_args() # parse command-line arguments
|
|
66
|
+
args_dict = vars(args_ap)
|
|
67
|
+
|
|
68
|
+
# Step 2: If config file provided, parse it
|
|
69
|
+
if args_ap.config_file:
|
|
70
|
+
config_parser = configparser.ConfigParser()
|
|
71
|
+
config_parser.read(args_ap.config_file)
|
|
72
|
+
args_cp = my_config_parser(config_parser)
|
|
73
|
+
|
|
74
|
+
# Override default args with values from config file
|
|
75
|
+
for cp_arg in args_cp:
|
|
76
|
+
name, value = cp_arg
|
|
77
|
+
arg = args.get_arg(name)
|
|
78
|
+
arg.val = value
|
|
79
|
+
|
|
80
|
+
# Step 3: Override again with CLI arguments (if present)
|
|
81
|
+
for name, value in args_dict.items():
|
|
82
|
+
if name == "config_file":
|
|
83
|
+
continue
|
|
84
|
+
if value is not None:
|
|
85
|
+
arg = args.get_arg(name.upper())
|
|
86
|
+
arg.val = value
|
|
87
|
+
|
|
88
|
+
# Step 4: Finalize
|
|
78
89
|
args.to_python()
|
|
79
90
|
args.write_config_file()
|
|
91
|
+
|
|
80
92
|
return args
|
|
81
93
|
|
|
82
94
|
def main():
|
|
@@ -172,7 +172,7 @@ def import_bed(bed_file,N_beads,coords=None,chrom=None,save_path='',shuffle=Fals
|
|
|
172
172
|
resolution = chrom_ends[-1]//N_beads if chrom==None else (coords[1]-coords[0])//N_beads
|
|
173
173
|
chrom_ends = np.array(chrom_ends)//resolution
|
|
174
174
|
chrom_ends[-1] = N_beads
|
|
175
|
-
np.save(save_path+'chrom_lengths.npy',chrom_ends)
|
|
175
|
+
np.save(save_path+'metadata/chrom_lengths.npy',chrom_ends)
|
|
176
176
|
if chrom!=None:
|
|
177
177
|
comps_df[1], comps_df[2] = comps_df[1]-coords[0], comps_df[2]-coords[0]
|
|
178
178
|
comps_df[1], comps_df[2] = comps_df[1]//resolution, comps_df[2]//resolution
|
|
@@ -191,8 +191,8 @@ def import_bed(bed_file,N_beads,coords=None,chrom=None,save_path='',shuffle=Fals
|
|
|
191
191
|
val = -1
|
|
192
192
|
comps_array[comps_df[1][i]:comps_df[2][i]] = val
|
|
193
193
|
|
|
194
|
-
np.save(save_path+'compartments.npy',comps_array)
|
|
195
|
-
np.save(save_path+'chrom_idxs.npy',chrom_idxs)
|
|
194
|
+
np.save(save_path+'metadata/compartments.npy',comps_array)
|
|
195
|
+
np.save(save_path+'metadata/chrom_idxs.npy',chrom_idxs)
|
|
196
196
|
print('Done')
|
|
197
197
|
return comps_array.astype(int), chrom_ends.astype(int), chrom_idxs.astype(int)
|
|
198
198
|
|
|
@@ -275,7 +275,7 @@ def import_mns_from_bedpe(bedpe_file, N_beads, coords=None, chrom=None, threshol
|
|
|
275
275
|
resolution = int(np.max(loops[5].values))//N_beads if chrom==None else (coords[1]-coords[0])//N_beads
|
|
276
276
|
chrom_ends = np.array(chrom_ends)//resolution
|
|
277
277
|
chrom_ends[-1] = N_beads
|
|
278
|
-
np.save(path+'chrom_lengths.npy',chrom_ends)
|
|
278
|
+
np.save(path+'metadata/chrom_lengths.npy',chrom_ends)
|
|
279
279
|
if chrom!=None:
|
|
280
280
|
loops[1], loops[2], loops[4], loops[5] = loops[1]-coords[0], loops[2]-coords[0], loops[4]-coords[0], loops[5]-coords[0]
|
|
281
281
|
loops[1], loops[2], loops[4], loops[5] = loops[1]//resolution, loops[2]//resolution, loops[4]//resolution, loops[5]//resolution
|
|
@@ -308,10 +308,10 @@ def import_mns_from_bedpe(bedpe_file, N_beads, coords=None, chrom=None, threshol
|
|
|
308
308
|
print('Average loop size:',avg_ls)
|
|
309
309
|
|
|
310
310
|
N_loops = len(ms)
|
|
311
|
-
np.save(path+'chrom_idxs.npy',chrom_idxs)
|
|
312
|
-
np.save(path+'ms.npy',ms)
|
|
313
|
-
np.save(path+'ns.npy',ns)
|
|
314
|
-
np.save(path+'ds.npy',ds)
|
|
311
|
+
np.save(path+'metadata/chrom_idxs.npy',chrom_idxs)
|
|
312
|
+
np.save(path+'metadata/ms.npy',ms)
|
|
313
|
+
np.save(path+'metadata/ns.npy',ns)
|
|
314
|
+
np.save(path+'metadata/ds.npy',ds)
|
|
315
315
|
print('Done! Number of loops is ',N_loops)
|
|
316
316
|
return ms.astype(int), ns.astype(int), ds, chrom_ends.astype(int), chrom_idxs.astype(int)
|
|
317
317
|
|
|
@@ -366,7 +366,7 @@ def import_bw(bw_path,N_beads,coords=None,chrom=None,viz=False,binary=False,path
|
|
|
366
366
|
lengths = np.array(lengths)
|
|
367
367
|
resolution = chrom_length//(2*N_beads)
|
|
368
368
|
polymer_lengths = lengths//resolution
|
|
369
|
-
np.save(path+'chrom_lengths.npy',polymer_lengths)
|
|
369
|
+
np.save(path+'metadata/chrom_lengths.npy',polymer_lengths)
|
|
370
370
|
|
|
371
371
|
# Import the downgraded signal
|
|
372
372
|
print('Importing bw signal...')
|
|
@@ -413,7 +413,7 @@ def import_bw(bw_path,N_beads,coords=None,chrom=None,viz=False,binary=False,path
|
|
|
413
413
|
plt.grid()
|
|
414
414
|
plt.show()
|
|
415
415
|
|
|
416
|
-
np.save(path+'signal.npy',genomewide_signal)
|
|
416
|
+
np.save(path+'metadata/signal.npy',genomewide_signal)
|
|
417
417
|
|
|
418
418
|
return genomewide_signal
|
|
419
419
|
|
|
@@ -433,8 +433,9 @@ def get_gene_region(gene_tsv, gene_id=None, gene_name=None, window_size = 200000
|
|
|
433
433
|
start = genes[genes['gene_name']==gene_name]['start'].values[0]
|
|
434
434
|
end = genes[genes['gene_name']==gene_name]['end'].values[0]
|
|
435
435
|
|
|
436
|
+
gene_region = [start,end]
|
|
436
437
|
region = [max(0,int(start-window_size)), int(end+window_size)]
|
|
437
|
-
return chrom, region
|
|
438
|
+
return chrom, region, gene_region
|
|
438
439
|
|
|
439
440
|
def discretize_array(arr, thresholds):
|
|
440
441
|
"""
|
|
@@ -455,6 +456,12 @@ def chrom_sort_key(chrom):
|
|
|
455
456
|
val = match.group(1)
|
|
456
457
|
return int(val) if val.isdigit() else {'X': 23, 'Y': 24}[val]
|
|
457
458
|
|
|
459
|
+
def save_args_to_txt(args, filename):
|
|
460
|
+
"""Save all arguments and their values into a text file."""
|
|
461
|
+
with open(filename, 'w') as f:
|
|
462
|
+
for arg in args:
|
|
463
|
+
f.write(f"{arg.name} = {arg.val}\n")
|
|
464
|
+
|
|
458
465
|
def get_eigenvector(eigenvec_tsv, N_beads, chrom=None, region=None, viz=False):
|
|
459
466
|
# Import dataset
|
|
460
467
|
eigenvector = pd.read_csv(eigenvec_tsv,sep='\t')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|