Example #1
0
                         (0.125,0, 0),
                         (0.375,1, 1),
                         (0.64,1, 1),
                         (0.91,0,0),
                         (1, 0, 0)),
               'blue':  ((0., 0.5, 0.5),
                         (0.11, 1, 1),
                         (0.34, 1, 1),
                         (0.65,0, 0),
                         (1, 0, 0))}


# compute the properties for the circle collection
min_count = min([min(cd.itervalues()) for cd in countdict.itervalues()])
max_count = max([max(cd.itervalues()) for cd in countdict.itervalues()])
size_scale = scale.linear(min_count,max_count).range(3,100)
color_scale = lambda c: mpl.cm.jet(scale.log(min_count,max_count).range(0,0.85)(c))

xy = []
s = []
c = []
for (i,v_gene) in enumerate(uniq_feature_values['v']):
    for (j,j_gene) in enumerate(uniq_feature_values['j']):
        try:
            count = countdict[v_gene][j_gene]
        except KeyError: # count == 0
            continue
        
        xy.append( (i,j) )
        s.append(size_scale(count))
        c.append(color_scale(count))
    raise ValueError, "need input and output names"

data = timeseries.load_timeseries(inhandle)
matrix = data['matrix']
labels = np.asarray(data['labels'])
times = data['times']
sums = data['sums']

streams = matrix / sums

# determine colors for the streamgraph
colors = []
time_idxs = np.arange(streams.shape[1])
onset_time = lambda stream: np.min(time_idxs[stream > 0])
weight = lambda stream: np.sum(stream)
Hscale = scale.linear(range(len(times))).range(0,1-1./len(times))
Lscale = scale.root(streams.sum(axis=1)).range(0.8,0.5).power(4)
for stream in streams:
    h = Hscale(onset_time(stream))
    l = Lscale(weight(stream))
    colors.append( colorsys.hls_to_rgb(h,l,1) + (1.,) )
colors = np.array(colors)

# sort streamgraphs appropriately
argsort_onset = streamgraph.argsort_onset(streams)
streams = streams[argsort_onset]
matrix = matrix[argsort_onset]
colors = colors[argsort_onset]

# argsort_inside_out = streamgraph.argsort_inside_out(streams)
# streams = streams[argsort_inside_out]
Example #3
0
                                          features,
                                          count=options.quantify)

_jet_data = {
    'red':
    ((0., 0, 0), (0.35, 0, 0), (0.66, 1, 1), (0.89, 1, 1), (1, 0.5, 0.5)),
    'green': ((0., 0, 0), (0.125, 0, 0), (0.375, 1, 1), (0.64, 1, 1),
              (0.91, 0, 0), (1, 0, 0)),
    'blue':
    ((0., 0.5, 0.5), (0.11, 1, 1), (0.34, 1, 1), (0.65, 0, 0), (1, 0, 0))
}

# compute the properties for the circle collection
min_count = min([min(cd.itervalues()) for cd in countdict.itervalues()])
max_count = max([max(cd.itervalues()) for cd in countdict.itervalues()])
size_scale = scale.linear(min_count, max_count).range(3, 100)
color_scale = lambda c: mpl.cm.jet(
    scale.log(min_count, max_count).range(0, 0.85)(c))

xy = []
s = []
c = []
for (i, v_gene) in enumerate(uniq_feature_values['v']):
    for (j, j_gene) in enumerate(uniq_feature_values['j']):
        try:
            count = countdict[v_gene][j_gene]
        except KeyError:  # count == 0
            continue

        xy.append((i, j))
        s.append(size_scale(count))
    raise ValueError, "need input and output names"

data = timeseries.load_timeseries(inhandle)
matrix = data['matrix']
labels = np.asarray(data['labels'])
times = data['times']
sums = data['sums']

streams = matrix / sums

# determine colors for the streamgraph
colors = []
time_idxs = np.arange(streams.shape[1])
onset_time = lambda stream: np.min(time_idxs[stream > 0])
weight = lambda stream: np.sum(stream)
Hscale = scale.linear(range(len(times))).range(0,1-1./len(times))
Lscale = scale.root(streams.sum(axis=1)).range(0.8,0.5).power(4)
for stream in streams:
    h = Hscale(onset_time(stream))
    l = Lscale(weight(stream))
    colors.append( colorsys.hls_to_rgb(h,l,1) + (1.,) )
colors = np.array(colors)

# sort streamgraphs appropriately
argsort_onset = streamgraph.argsort_onset(streams)
streams = streams[argsort_onset]
matrix = matrix[argsort_onset]
colors = colors[argsort_onset]

# argsort_inside_out = streamgraph.argsort_inside_out(streams)
# streams = streams[argsort_inside_out]