Skip to content

Commit

Permalink
Merge pull request #66 from hoffmangroup/bigwig-stat-dimension-fix
Browse files Browse the repository at this point in the history
Fix summary statistics for bigWig files to produce 1-dimensional arrays
  • Loading branch information
EricR86 committed Aug 22, 2023
2 parents 05f497d + c9873a2 commit 7233a8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS
@@ -1,3 +1,6 @@
1.7.1:
* fix array dimensionality consistency for summary statistics on bigWig files

1.7.0:
* adapted existing python interface to open bigWig files

Expand Down
10 changes: 5 additions & 5 deletions genomedata/_bigwig.py
Expand Up @@ -69,23 +69,23 @@ def __getitem__(self, name):
# NB: One implicit trackname across chromosomes for stat retrieval
@property
def mins(self):
return array(self.bw_file_header['minVal'])
return array([self.bw_file_header['minVal']])

@property
def maxs(self):
return array(self.bw_file_header['maxVal'])
return array([self.bw_file_header['maxVal']])

@property
def sums(self):
return array(self.bw_file_header['sumData'])
return array([self.bw_file_header['sumData']])

@property
def sums_squares(self):
return array(self.bw_file_header['sumSquared'])
return array([self.bw_file_header['sumSquared']])

@property
def num_datapoints(self):
return array(self.bw_file_header['nBasesCovered'])
return array([self.bw_file_header['nBasesCovered']])

def tracknames_continuous(self):
# Return filepath to bigWig as implicit trackname
Expand Down
2 changes: 1 addition & 1 deletion test/run_tests.py
Expand Up @@ -304,7 +304,7 @@ def test_interface(self):
self.assertEqual(genome.maxs, [93473])
self.assertEqual(genome.sums, [32720078])
self.assertEqual(genome.sums_squares, [1280737190372])
self.assertAlmostEqual(genome.vars, 414615.8372, places=4)
self.assertAlmostEqual(genome.vars[0], 414615.8372, places=4)

# Test chromosome retrieval
chr1 = genome["chr1"] # memoization
Expand Down

0 comments on commit 7233a8c

Please sign in to comment.