0

I have a file that looks like this:

>  loc.38167  h3k4me1 1.8299  1.5343  0.0     0.0     1.8299  1.5343  0.0 ....

>  loc.08652  h3k4me3 0.0     0.0     0.0     0.0     0.0    0.0     0.0 ....

I want to plot 500 random 'loc.' points on a graph. Each loc. has 100 values. I use the following python script:

file = open('h3k4me3.tab.data')

data = {}
for line in file:
    cols = line.strip().split('\t')
    vals = map(float,cols[2:])
    data[cols[0]] = vals

file.close 

randomA = data.keys()[:500]

window = int(math.ceil(5000.0 / 100))
xticks = range(-2500,2500,window)

sns.tsplot([data[k] for k in randomA],time=xticks)

However, I get ValueError: arrays must all be same length

Alex Trevylan
  • 517
  • 7
  • 17
  • 1
    Possible duplicate of [Creating dataframe from a dictionary where entries have different lengths](http://stackoverflow.com/questions/19736080/creating-dataframe-from-a-dictionary-where-entries-have-different-lengths) – zanussi Mar 10 '17 at 20:34
  • I guess you need to check if all your `vals` have length of 100 – heyu91 Mar 10 '17 at 20:56

0 Answers0