gwseq-io 0.0.13__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.
- gwseq_io-0.0.13/LICENSE +21 -0
- gwseq_io-0.0.13/PKG-INFO +195 -0
- gwseq_io-0.0.13/README.md +181 -0
- gwseq_io-0.0.13/gwseq_io/bam_entry.cpp +369 -0
- gwseq_io-0.0.13/gwseq_io/bam_header.cpp +140 -0
- gwseq_io-0.0.13/gwseq_io/bam_index.cpp +211 -0
- gwseq_io-0.0.13/gwseq_io/bam_reader.cpp +146 -0
- gwseq_io-0.0.13/gwseq_io/bbi_data_tree.cpp +118 -0
- gwseq_io-0.0.13/gwseq_io/bbi_data_values.cpp +193 -0
- gwseq_io-0.0.13/gwseq_io/bbi_headers.cpp +210 -0
- gwseq_io-0.0.13/gwseq_io/bbi_locs.cpp +123 -0
- gwseq_io-0.0.13/gwseq_io/bbi_reader.cpp +618 -0
- gwseq_io-0.0.13/gwseq_io/binding.cpp +1088 -0
- gwseq_io-0.0.13/gwseq_io/genomes.cpp +14 -0
- gwseq_io-0.0.13/gwseq_io/hic_headers.cpp +242 -0
- gwseq_io-0.0.13/gwseq_io/hic_locs.cpp +88 -0
- gwseq_io-0.0.13/gwseq_io/hic_matrices_data.cpp +337 -0
- gwseq_io-0.0.13/gwseq_io/hic_matrices_metadata.cpp +65 -0
- gwseq_io-0.0.13/gwseq_io/hic_reader.cpp +325 -0
- gwseq_io-0.0.13/gwseq_io/main.cpp +22 -0
- gwseq_io-0.0.13/gwseq_io/util/array_util.cpp +811 -0
- gwseq_io-0.0.13/gwseq_io/util/byte_util.cpp +693 -0
- gwseq_io-0.0.13/gwseq_io/util/compression_util.cpp +286 -0
- gwseq_io-0.0.13/gwseq_io/util/file_util.cpp +948 -0
- gwseq_io-0.0.13/gwseq_io/util/includes.cpp +60 -0
- gwseq_io-0.0.13/gwseq_io/util/iter_util.cpp +63 -0
- gwseq_io-0.0.13/gwseq_io/util/loc_util.cpp +91 -0
- gwseq_io-0.0.13/gwseq_io/util/main.cpp +22 -0
- gwseq_io-0.0.13/gwseq_io/util/map_util.cpp +234 -0
- gwseq_io-0.0.13/gwseq_io/util/parallel_util.cpp +225 -0
- gwseq_io-0.0.13/gwseq_io/util/progress_util.cpp +67 -0
- gwseq_io-0.0.13/gwseq_io/util/py_call.cpp +79 -0
- gwseq_io-0.0.13/gwseq_io/util/py_util.cpp +96 -0
- gwseq_io-0.0.13/gwseq_io/util/string_util.cpp +134 -0
- gwseq_io-0.0.13/gwseq_io/util/tree_util.cpp +480 -0
- gwseq_io-0.0.13/gwseq_io.egg-info/PKG-INFO +195 -0
- gwseq_io-0.0.13/gwseq_io.egg-info/SOURCES.txt +42 -0
- gwseq_io-0.0.13/gwseq_io.egg-info/dependency_links.txt +1 -0
- gwseq_io-0.0.13/gwseq_io.egg-info/not-zip-safe +1 -0
- gwseq_io-0.0.13/gwseq_io.egg-info/requires.txt +2 -0
- gwseq_io-0.0.13/gwseq_io.egg-info/top_level.txt +1 -0
- gwseq_io-0.0.13/pyproject.toml +26 -0
- gwseq_io-0.0.13/setup.cfg +4 -0
- gwseq_io-0.0.13/setup.py +65 -0
gwseq_io-0.0.13/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Arthur Gouhier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
gwseq_io-0.0.13/PKG-INFO
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gwseq_io
|
|
3
|
+
Version: 0.0.13
|
|
4
|
+
Summary: Process BBI (bigWig/bigBed) and HiC files
|
|
5
|
+
Author-email: Arthur Gouhier <ajgouhier@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/ajgouhier/gwseq_io
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: pybind11>=2.6.0
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
pip install gwseq-io
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires numpy and pybind11.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Open bigWig, bigBed and HiC files
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
reader = gwseq_io.open(path, *, parallel, zoom_correction, file_buffer_size, max_file_buffer_count)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Parameters:
|
|
32
|
+
- `parallel` Number of parallel file handles and processing threads. 24 by default.
|
|
33
|
+
- `zoom_correction` Scaling factor for automatic zoom level selection based on bin size. Only for bigWig files. 1/3 by default.
|
|
34
|
+
- `file_buffer_size` Size in bytes of each file buffer for caching file reads. Use -1 for recommended (32768 or 1048576 for URLs). -1 by default.
|
|
35
|
+
- `max_file_buffer_count` Maximum number of file buffers to keep in cache. Use -1 for recommended (128). -1 by default.
|
|
36
|
+
|
|
37
|
+
Attributes for bigWig and bigBed files:
|
|
38
|
+
- `main_header` General file formatting info.
|
|
39
|
+
- `zoom_headers` Zooms levels info (reduction level and location).
|
|
40
|
+
- `auto_sql` BED entries declaration (only in bigBed).
|
|
41
|
+
- `total_summary` Statistical summary of entire file values (coverage, sums and extremes).
|
|
42
|
+
- `chr_sizes` Chromosomes IDs and sizes.
|
|
43
|
+
- `type` Either "bigwig" or "bigbed".
|
|
44
|
+
|
|
45
|
+
Attributes for HiC files:
|
|
46
|
+
- `header` `footer` General file info.
|
|
47
|
+
- `chr_sizes` Chromosomes IDs and sizes.
|
|
48
|
+
- `normalizations` Available normalizations.
|
|
49
|
+
- `units` Available units.
|
|
50
|
+
- `bin_sizes` Available bin sizes.
|
|
51
|
+
|
|
52
|
+
### Read bigWig and bigBed signal
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
values = reader.read_signal(chr_ids, starts, ends)
|
|
56
|
+
values = reader.read_signal(chr_ids, starts=starts, span=span)
|
|
57
|
+
values = reader.read_signal(chr_ids, ends=ends, span=span)
|
|
58
|
+
values = reader.read_signal(chr_ids, centers=centers, span=span)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Parameters:
|
|
62
|
+
- `chr_ids` `starts` `ends` `centers` Chromosomes ids, starts, ends and centers of locations. Both `starts` `ends` or one of `starts` `ends` `centers` (with `span`) may be specified.
|
|
63
|
+
- `span` Reading window in bp relative to locations `starts` `ends` `centers`. Only one reference may be specified if specified. Not by default.
|
|
64
|
+
- `bin_size` Reading bin size in bp. May vary in output if locations have variable spans or `bin_count` is specified. 1 by default.
|
|
65
|
+
- `bin_count` Output bin count. Inferred as max location span / bin size by default.
|
|
66
|
+
- `bin_mode` Method to aggregate bin values. Either "mean", "sum" or "count". "mean" by default.
|
|
67
|
+
- `full_bin` Extend locations ends to overlapping bins if true. Not by default.
|
|
68
|
+
- `def_value` Default value to use when no data overlap a bin. 0 by default.
|
|
69
|
+
- `zoom` BigWig zoom level to use. Use full data if -1. Auto-detect the best level if -2 by selecting the larger level whose bin size is lower than the third of `bin_size` (may be the full data). Full data by default.
|
|
70
|
+
- `progress` Function called during data extraction. Takes the extracted coverage and the total coverage in bp as parameters. Use default callback function if true. None by default.
|
|
71
|
+
|
|
72
|
+
Returns a numpy float32 array of shape (locations, bin count).
|
|
73
|
+
|
|
74
|
+
### Quantify bigWig and bigBed signal
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
values = reader.quantify(chr_ids, starts, ends)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Parameters:
|
|
81
|
+
- `chr_ids` `starts` `ends` `centers` `span` `bin_size` `full_bin` `def_value` `zoom` `progress` Identical to `read_signal` method.
|
|
82
|
+
- `reduce` Method to aggregate values over span. Either "mean", "sd", "sem", "sum", "count", "min" or "max". "mean" by default.
|
|
83
|
+
|
|
84
|
+
Returns a numpy float32 array of shape (locations).
|
|
85
|
+
|
|
86
|
+
### Profile bigWig and bigBed signal
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
values = reader.profile(chr_ids, starts, ends)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Parameters:
|
|
93
|
+
- `chr_ids` `starts` `ends` `centers` `span` `bin_size` `bin_count` `bin_mode` `full_bin` `def_value` `zoom` `progress` Identical to `read_signal` method.
|
|
94
|
+
- `reduce` Method to aggregate values over locations. Either "mean", "sd", "sem", "sum", "count", "min" or "max". "mean" by default.
|
|
95
|
+
|
|
96
|
+
Returns a numpy float32 array of shape (bin count).
|
|
97
|
+
|
|
98
|
+
### Read bigBed entries
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
values = reader.read_entries(chr_ids, starts, ends)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Parameters:
|
|
105
|
+
- `chr_ids` `starts` `ends` `centers` `spans` `progress` Identical to `read_signal` method.
|
|
106
|
+
|
|
107
|
+
Returns a list (locations) of list of entries (dict with at least "chr", "start" and "end" keys).
|
|
108
|
+
|
|
109
|
+
### Convert bigWig to bedGraph or WIG
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
reader.to_bedgraph(output_path)
|
|
113
|
+
reader.to_wig(output_path)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Parameters:
|
|
117
|
+
- `output_path` Path to output file.
|
|
118
|
+
- `chr_ids` Only extract data from these chromosomes. All by default.
|
|
119
|
+
- `zoom` Zoom level to use. Use full data if -1. Full data by default.
|
|
120
|
+
- `progress` Function called during data extraction. Takes the extracted coverage and the total coverage in bp as parameters. None by default.
|
|
121
|
+
|
|
122
|
+
### Convert bigBed to BED
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
reader.to_bed(output_path)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Parameters:
|
|
129
|
+
- `output_path` `chr_ids` `progress` Identical to `to_bedgraph` and `to_wig` methods.
|
|
130
|
+
- `col_count` Only write this number of columns (eg, 3 for chr, start and end). All by default.
|
|
131
|
+
|
|
132
|
+
### Write bigWig file
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
writer = bigwig_io.open(path, "w")
|
|
136
|
+
writer = bigwig_io.open(path, "w", def_value=0)
|
|
137
|
+
writer = bigwig_io.open(path, "w", chr_sizes={"chr1": 1234, "chr2": 1234})
|
|
138
|
+
writer.add_entry("chr1", start=1000, end=1010, value=0.1)
|
|
139
|
+
writer.add_value("chr1", start=1000, span=10, value=0.1)
|
|
140
|
+
writer.add_values("chr1", start=1000, span=10, values=[0.1, 0.1, 0.1, 0.1])
|
|
141
|
+
```
|
|
142
|
+
must be pooled by chr, and sorted by (1) start (2) end
|
|
143
|
+
no overlap
|
|
144
|
+
|
|
145
|
+
### Write bigBed file
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
writer = bigwig_io.open(path, "w", type="bigbed")
|
|
149
|
+
writer = bigwig_io.open(path, "w", type="bigbed", chr_sizes={"chr1": 1234, "chr2": 1234})
|
|
150
|
+
writer = bigwig_io.open(path, "w", type="bigbed", fields=["chr", "start", "end", "name"])
|
|
151
|
+
writer = bigwig_io.open(path, "w", type="bigbed", fields={"chr": "string", "start", "uint", "end": "uint", "name": "string"})
|
|
152
|
+
writer.add_entry("chr1", start=1000, end=1010)
|
|
153
|
+
writer.add_entry("chr1", start=1000, end=1010, fields={"name": "read#1"})
|
|
154
|
+
```
|
|
155
|
+
must be pooled by chr, and sorted by (1) start (2) end
|
|
156
|
+
may be overlapping
|
|
157
|
+
|
|
158
|
+
### Read HiC signal
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
values = reader.read_signal(chr_ids, starts, ends)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Parameters:
|
|
165
|
+
- `chr_ids` `starts` `ends` Chromosomes ids, starts and ends of the 2 locations.
|
|
166
|
+
- `bin_size` Input bin size or -1 to use the smallest. Must be available in the file. Smallest by default.
|
|
167
|
+
- `bin_count` Approximate output bin count. Takes precedence over `bin_size` if specified by selecting the closest bin size resulting in `bin_count`. Not specified by default.
|
|
168
|
+
- `exact_bin_count` Resize output to match `bin_count` (if specified). Not by default.
|
|
169
|
+
- `full_bin` Extend locations ends to overlapping bins if true. Not by default.
|
|
170
|
+
- `def_value` Default value to use when no data overlap a bin. 0 by default.
|
|
171
|
+
- `triangle` Skip symmetrical data if true. Not by default.
|
|
172
|
+
- `min_distance` `max_distance` Min and max distance in bp from diagonal for contacts to be reported. All by default.
|
|
173
|
+
- `normalization` Either "none" or any normalization available in the file, such as "kr", "vc" or "vc_sqrt". "none" by default.
|
|
174
|
+
- `mode` Either "observed" or "oe" (observed/expected). "observed" by default.
|
|
175
|
+
- `unit` Either "bp" or "frag". "bp" by default.
|
|
176
|
+
- `save_to` Save output to this .npz path (under "values" key) and return nothing. Not by default.
|
|
177
|
+
|
|
178
|
+
Returns a numpy float32 array of shape (loc 1 bins, loc 2 bins).
|
|
179
|
+
|
|
180
|
+
### Read HiC sparse signal
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
values = reader.read_sparse_signal(chr_ids, starts, ends)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Parameters:
|
|
187
|
+
- `chr_ids` `starts` `ends` `bin_size` `bin_count` `exact_bin_count` `full_bin` `def_value` `triangle` `min_distance` `max_distance` `normalization` `mode` `unit` `save_to` Identical to `read_signal` method.
|
|
188
|
+
|
|
189
|
+
Returns a COO sparse matrix as a dict with keys:
|
|
190
|
+
- `values` Values as a numpy float32 array.
|
|
191
|
+
- `row` Values rows indices as a numpy uint32 array.
|
|
192
|
+
- `col` Values columns indices as a numpy uint32 array.
|
|
193
|
+
- `shape` Shape of the dense array as a tuple.
|
|
194
|
+
|
|
195
|
+
Convert in python using `scipy.sparse.csr_array((x["values"], (x["row"], x["col"])), shape=x["shape"])`.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
## Installation
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
pip install gwseq-io
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Requires numpy and pybind11.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Open bigWig, bigBed and HiC files
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
reader = gwseq_io.open(path, *, parallel, zoom_correction, file_buffer_size, max_file_buffer_count)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Parameters:
|
|
18
|
+
- `parallel` Number of parallel file handles and processing threads. 24 by default.
|
|
19
|
+
- `zoom_correction` Scaling factor for automatic zoom level selection based on bin size. Only for bigWig files. 1/3 by default.
|
|
20
|
+
- `file_buffer_size` Size in bytes of each file buffer for caching file reads. Use -1 for recommended (32768 or 1048576 for URLs). -1 by default.
|
|
21
|
+
- `max_file_buffer_count` Maximum number of file buffers to keep in cache. Use -1 for recommended (128). -1 by default.
|
|
22
|
+
|
|
23
|
+
Attributes for bigWig and bigBed files:
|
|
24
|
+
- `main_header` General file formatting info.
|
|
25
|
+
- `zoom_headers` Zooms levels info (reduction level and location).
|
|
26
|
+
- `auto_sql` BED entries declaration (only in bigBed).
|
|
27
|
+
- `total_summary` Statistical summary of entire file values (coverage, sums and extremes).
|
|
28
|
+
- `chr_sizes` Chromosomes IDs and sizes.
|
|
29
|
+
- `type` Either "bigwig" or "bigbed".
|
|
30
|
+
|
|
31
|
+
Attributes for HiC files:
|
|
32
|
+
- `header` `footer` General file info.
|
|
33
|
+
- `chr_sizes` Chromosomes IDs and sizes.
|
|
34
|
+
- `normalizations` Available normalizations.
|
|
35
|
+
- `units` Available units.
|
|
36
|
+
- `bin_sizes` Available bin sizes.
|
|
37
|
+
|
|
38
|
+
### Read bigWig and bigBed signal
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
values = reader.read_signal(chr_ids, starts, ends)
|
|
42
|
+
values = reader.read_signal(chr_ids, starts=starts, span=span)
|
|
43
|
+
values = reader.read_signal(chr_ids, ends=ends, span=span)
|
|
44
|
+
values = reader.read_signal(chr_ids, centers=centers, span=span)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Parameters:
|
|
48
|
+
- `chr_ids` `starts` `ends` `centers` Chromosomes ids, starts, ends and centers of locations. Both `starts` `ends` or one of `starts` `ends` `centers` (with `span`) may be specified.
|
|
49
|
+
- `span` Reading window in bp relative to locations `starts` `ends` `centers`. Only one reference may be specified if specified. Not by default.
|
|
50
|
+
- `bin_size` Reading bin size in bp. May vary in output if locations have variable spans or `bin_count` is specified. 1 by default.
|
|
51
|
+
- `bin_count` Output bin count. Inferred as max location span / bin size by default.
|
|
52
|
+
- `bin_mode` Method to aggregate bin values. Either "mean", "sum" or "count". "mean" by default.
|
|
53
|
+
- `full_bin` Extend locations ends to overlapping bins if true. Not by default.
|
|
54
|
+
- `def_value` Default value to use when no data overlap a bin. 0 by default.
|
|
55
|
+
- `zoom` BigWig zoom level to use. Use full data if -1. Auto-detect the best level if -2 by selecting the larger level whose bin size is lower than the third of `bin_size` (may be the full data). Full data by default.
|
|
56
|
+
- `progress` Function called during data extraction. Takes the extracted coverage and the total coverage in bp as parameters. Use default callback function if true. None by default.
|
|
57
|
+
|
|
58
|
+
Returns a numpy float32 array of shape (locations, bin count).
|
|
59
|
+
|
|
60
|
+
### Quantify bigWig and bigBed signal
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
values = reader.quantify(chr_ids, starts, ends)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
- `chr_ids` `starts` `ends` `centers` `span` `bin_size` `full_bin` `def_value` `zoom` `progress` Identical to `read_signal` method.
|
|
68
|
+
- `reduce` Method to aggregate values over span. Either "mean", "sd", "sem", "sum", "count", "min" or "max". "mean" by default.
|
|
69
|
+
|
|
70
|
+
Returns a numpy float32 array of shape (locations).
|
|
71
|
+
|
|
72
|
+
### Profile bigWig and bigBed signal
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
values = reader.profile(chr_ids, starts, ends)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Parameters:
|
|
79
|
+
- `chr_ids` `starts` `ends` `centers` `span` `bin_size` `bin_count` `bin_mode` `full_bin` `def_value` `zoom` `progress` Identical to `read_signal` method.
|
|
80
|
+
- `reduce` Method to aggregate values over locations. Either "mean", "sd", "sem", "sum", "count", "min" or "max". "mean" by default.
|
|
81
|
+
|
|
82
|
+
Returns a numpy float32 array of shape (bin count).
|
|
83
|
+
|
|
84
|
+
### Read bigBed entries
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
values = reader.read_entries(chr_ids, starts, ends)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Parameters:
|
|
91
|
+
- `chr_ids` `starts` `ends` `centers` `spans` `progress` Identical to `read_signal` method.
|
|
92
|
+
|
|
93
|
+
Returns a list (locations) of list of entries (dict with at least "chr", "start" and "end" keys).
|
|
94
|
+
|
|
95
|
+
### Convert bigWig to bedGraph or WIG
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
reader.to_bedgraph(output_path)
|
|
99
|
+
reader.to_wig(output_path)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Parameters:
|
|
103
|
+
- `output_path` Path to output file.
|
|
104
|
+
- `chr_ids` Only extract data from these chromosomes. All by default.
|
|
105
|
+
- `zoom` Zoom level to use. Use full data if -1. Full data by default.
|
|
106
|
+
- `progress` Function called during data extraction. Takes the extracted coverage and the total coverage in bp as parameters. None by default.
|
|
107
|
+
|
|
108
|
+
### Convert bigBed to BED
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
reader.to_bed(output_path)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Parameters:
|
|
115
|
+
- `output_path` `chr_ids` `progress` Identical to `to_bedgraph` and `to_wig` methods.
|
|
116
|
+
- `col_count` Only write this number of columns (eg, 3 for chr, start and end). All by default.
|
|
117
|
+
|
|
118
|
+
### Write bigWig file
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
writer = bigwig_io.open(path, "w")
|
|
122
|
+
writer = bigwig_io.open(path, "w", def_value=0)
|
|
123
|
+
writer = bigwig_io.open(path, "w", chr_sizes={"chr1": 1234, "chr2": 1234})
|
|
124
|
+
writer.add_entry("chr1", start=1000, end=1010, value=0.1)
|
|
125
|
+
writer.add_value("chr1", start=1000, span=10, value=0.1)
|
|
126
|
+
writer.add_values("chr1", start=1000, span=10, values=[0.1, 0.1, 0.1, 0.1])
|
|
127
|
+
```
|
|
128
|
+
must be pooled by chr, and sorted by (1) start (2) end
|
|
129
|
+
no overlap
|
|
130
|
+
|
|
131
|
+
### Write bigBed file
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
writer = bigwig_io.open(path, "w", type="bigbed")
|
|
135
|
+
writer = bigwig_io.open(path, "w", type="bigbed", chr_sizes={"chr1": 1234, "chr2": 1234})
|
|
136
|
+
writer = bigwig_io.open(path, "w", type="bigbed", fields=["chr", "start", "end", "name"])
|
|
137
|
+
writer = bigwig_io.open(path, "w", type="bigbed", fields={"chr": "string", "start", "uint", "end": "uint", "name": "string"})
|
|
138
|
+
writer.add_entry("chr1", start=1000, end=1010)
|
|
139
|
+
writer.add_entry("chr1", start=1000, end=1010, fields={"name": "read#1"})
|
|
140
|
+
```
|
|
141
|
+
must be pooled by chr, and sorted by (1) start (2) end
|
|
142
|
+
may be overlapping
|
|
143
|
+
|
|
144
|
+
### Read HiC signal
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
values = reader.read_signal(chr_ids, starts, ends)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Parameters:
|
|
151
|
+
- `chr_ids` `starts` `ends` Chromosomes ids, starts and ends of the 2 locations.
|
|
152
|
+
- `bin_size` Input bin size or -1 to use the smallest. Must be available in the file. Smallest by default.
|
|
153
|
+
- `bin_count` Approximate output bin count. Takes precedence over `bin_size` if specified by selecting the closest bin size resulting in `bin_count`. Not specified by default.
|
|
154
|
+
- `exact_bin_count` Resize output to match `bin_count` (if specified). Not by default.
|
|
155
|
+
- `full_bin` Extend locations ends to overlapping bins if true. Not by default.
|
|
156
|
+
- `def_value` Default value to use when no data overlap a bin. 0 by default.
|
|
157
|
+
- `triangle` Skip symmetrical data if true. Not by default.
|
|
158
|
+
- `min_distance` `max_distance` Min and max distance in bp from diagonal for contacts to be reported. All by default.
|
|
159
|
+
- `normalization` Either "none" or any normalization available in the file, such as "kr", "vc" or "vc_sqrt". "none" by default.
|
|
160
|
+
- `mode` Either "observed" or "oe" (observed/expected). "observed" by default.
|
|
161
|
+
- `unit` Either "bp" or "frag". "bp" by default.
|
|
162
|
+
- `save_to` Save output to this .npz path (under "values" key) and return nothing. Not by default.
|
|
163
|
+
|
|
164
|
+
Returns a numpy float32 array of shape (loc 1 bins, loc 2 bins).
|
|
165
|
+
|
|
166
|
+
### Read HiC sparse signal
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
values = reader.read_sparse_signal(chr_ids, starts, ends)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Parameters:
|
|
173
|
+
- `chr_ids` `starts` `ends` `bin_size` `bin_count` `exact_bin_count` `full_bin` `def_value` `triangle` `min_distance` `max_distance` `normalization` `mode` `unit` `save_to` Identical to `read_signal` method.
|
|
174
|
+
|
|
175
|
+
Returns a COO sparse matrix as a dict with keys:
|
|
176
|
+
- `values` Values as a numpy float32 array.
|
|
177
|
+
- `row` Values rows indices as a numpy uint32 array.
|
|
178
|
+
- `col` Values columns indices as a numpy uint32 array.
|
|
179
|
+
- `shape` Shape of the dense array as a tuple.
|
|
180
|
+
|
|
181
|
+
Convert in python using `scipy.sparse.csr_array((x["values"], (x["row"], x["col"])), shape=x["shape"])`.
|