Skip to content

Commit 94baf41

Browse files
committed
Merge branch 'master' into update_version
2 parents d48bf31 + 056eb75 commit 94baf41

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

.github/workflows/pytest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [ '3.8', '3.9', '3.10' ]
18+
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
1919

2020
steps:
2121
- uses: actions/checkout@v2

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cooltools/__pycache__
1414
# Distribution / packaging
1515
.Python
1616
env/
17+
.venv/
1718
build/
1819
develop-eggs/
1920
dist/
@@ -106,4 +107,5 @@ tmp.npz
106107
tmp.hdf5
107108
cooltools/sandbox/test.mcool
108109

109-
.vscode/
110+
.vscode/
111+
.idea/

cooltools/api/snipping.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
The main user-facing function of this module is `pileup`, it performs pileups using
55
snippers and other functions defined in the module. The concept is the following:
66
7-
- First, the provided features are annotated with the regions from a view (or simply
7+
- First, the provided features are annotated with the regions from a view (or simply
88
whole chromosomes, if no view is provided). They are assigned to the region that
99
contains it, or the one with the largest overlap.
10-
- Then the features are expanded using the `flank` argument, and aligned to the bins
10+
- Then the features are expanded using the `flank` argument, and aligned to the bins
1111
of the cooler
12-
- Depending on the requested operation (whether the normalization to expected is
12+
- Depending on the requested operation (whether the normalization to expected is
1313
required), the appropriate snipper object is created
14-
- A snipper can `select` a particular region of a genome-wide matrix, meaning it
14+
- A snipper can `select` a particular region of a genome-wide matrix, meaning it
1515
stores its sparse representation in memory. This could be whole chromosomes or
1616
chromosome arms, for example
17-
- A snipper can `snip` a small area of a selected region, meaning it will extract
17+
- A snipper can `snip` a small area of a selected region, meaning it will extract
1818
and return a dense representation of this area
19-
- For each region present, it is first `select`ed, and then all features within it are
19+
- For each region present, it is first `select`ed, and then all features within it are
2020
`snip`ped, creating a stack: a 3D array containing all snippets for this region
21-
- For features that are not assigned to any region, an empty snippet is returned
22-
- All per-region stacks are then combined into one, which then can be averaged to create
21+
- For features that are not assigned to any region, an empty snippet is returned
22+
- All per-region stacks are then combined into one, which then can be averaged to create
2323
a single pileup
24-
- The order of snippets in the stack matches the order of features, this way the stack
24+
- The order of snippets in the stack matches the order of features, this way the stack
2525
can also be used for analysis of any subsets of original features
2626
2727
This procedure achieves a good tradeoff between speed and RAM. Extracting each
@@ -390,7 +390,8 @@ def select(self, region1, region2):
390390
if self.cooler_opts["sparse"]:
391391
matrix = matrix.tocsr()
392392
if self.min_diag is not None:
393-
diags = np.arange(np.diff(self.clr.extent(region1_coords)), dtype=np.int32)
393+
lo, hi = self.clr.extent(region1_coords)
394+
diags = np.arange(hi - lo, dtype=np.int32)
394395
self.diag_indicators[region1] = LazyToeplitz(-diags, diags)
395396
return matrix
396397

@@ -600,7 +601,8 @@ def select(self, region1, region2):
600601
.values
601602
)
602603
if self.min_diag is not None:
603-
diags = np.arange(np.diff(self.clr.extent(region1_coords)), dtype=np.int32)
604+
lo, hi = self.clr.extent(region1_coords)
605+
diags = np.arange(hi - lo, dtype=np.int32)
604606
self.diag_indicators[region1] = LazyToeplitz(-diags, diags)
605607
return matrix
606608

@@ -770,7 +772,8 @@ def select(self, region1, region2):
770772
.values
771773
)
772774
if self.min_diag is not None:
773-
diags = np.arange(np.diff(self.clr.extent(region1_coords)), dtype=np.int32)
775+
lo, hi = self.clr.extent(region1_coords)
776+
diags = np.arange(hi - lo, dtype=np.int32)
774777
self.diag_indicators[region1] = LazyToeplitz(-diags, diags)
775778
return self._expected
776779

@@ -861,7 +864,7 @@ def pileup(
861864
map_functor : callable, optional
862865
Map function to dispatch the matrix chunks to workers.
863866
If left unspecified, pool_decorator applies the following defaults: if nproc>1 this defaults to multiprocess.Pool;
864-
If nproc=1 this defaults the builtin map.
867+
If nproc=1 this defaults the builtin map.
865868
866869
Returns
867870
-------
@@ -983,5 +986,5 @@ def pileup(
983986
stack = _pileup(features_df, snipper.select, snipper.snip, map=map_functor)
984987
if feature_type == "bed":
985988
stack = np.fmax(stack, np.transpose(stack, axes=(0, 2, 1)))
986-
989+
987990
return stack

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ matplotlib
77
multiprocess
88
numba
99
numpy
10-
pandas>=1.5.1,<2
10+
pandas>=1.5.1
1111
scikit-learn>=1.1.2
1212
scipy
1313
scikit-image

tests/test_checks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ def test_is_track():
235235
assert cooltools.lib.is_track(track)
236236

237237
track_incompat = bioframe.sort_bedframe(track.copy())
238-
track_incompat.iloc[:, 0] = 10
238+
track_incompat["chrom"] = 10
239239

240240
# not bedframe in first three columns
241241
assert cooltools.lib.is_track(track_incompat) is False
242242

243243
track_incompat = track.copy()
244-
track_incompat.iloc[:, -1] = ["a", "b", "c", "d"]
244+
track_incompat["value"] = ["a", "b", "c", "d"]
245245
# not numeric type in column4
246246
assert cooltools.lib.is_track(track_incompat) is False
247247

0 commit comments

Comments
 (0)