Skip to content

BigBed interval problem  #122

@jtd032

Description

@jtd032

I am creating a list of histograms, one for each file using below code:

Imports

import numpy as np
import pyBigWig as bw
import matplotlib.pyplot as plt
import os

For Loop

directory = 'listed file path'
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if os.path.isfile(f) and filename.endswith('.bb'):
fp = bw.open(f,'r')
chr = filename.replace('.bb','')
max = fp.header()['maxVal']
#print(fp.header())
a = np.array(fp.entries(chr, 1, max),dtype=np.int64)
plt.hist(a[:,2], bins='auto') # arguments are passed to np.histogram
plt.title("Histogram with 'auto' bins")
#Text(0.5, 1.0, "Histogram with 'auto' bins")
print(chr)
plt.show()

The problem I am riunning into is retreval of the maxVal from the Header command, it works for the first few graphs but ends up spitting out an error at later files: (int() argument must be a string, a bytes-like object or a number, not 'NoneType') am I understanding that the maxVal is the top end of the range of values for that file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions