bokeh.palettes.Plasma256

Here are the examples of the python api bokeh.palettes.Plasma256 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 View Source File : NeoPredViz.py
License : GNU Lesser General Public License v3.0
Project Creator : MathOnco

    def HeatTable(self):
        ready = {}
        for item in self.sharedCount:
            ready.update({ (item.split(',')[0],item.split(',')[1]): self.sharedCount[item] })

        k = np.array([item for item in ready])
        v = np.array([ready[item] for item in ready])

        unq_keys, key_idx = np.unique(k, return_inverse=True)
        key_idx = key_idx.reshape(-1, 2)
        n = len(unq_keys)
        adj = np.zeros((n, n), dtype=v.dtype)
        adj[key_idx[:, 0], key_idx[:, 1]] = v
        adj += adj.T

        adj = adj.astype(float)
        for i in range(0,adj.shape[0]):
            for k in range(0,adj.shape[1]):
                if k  <  =i:
                    adj[i,k]=np.nan

        dfout = pd.DataFrame(data=np.log10(adj+0.01),index = unq_keys, columns = unq_keys)
        dfout.index.name = 'Sam1'
        dfout.columns.name = 'Sam2'
        df = pd.DataFrame(dfout.stack(), columns=['Neoantigens']).reset_index()

        source = ColumnDataSource(df)

        import bokeh.palettes as p
        colors = p.Plasma256
        mapper = LinearColorMapper(palette=colors, low=df.Neoantigens.min(), high=df.Neoantigens.max())

        p = figure(title = "log10( Shared Neoantigens )", plot_height=400, plot_width=400, x_range=list(dfout.index), y_range=list(reversed(dfout.columns)),
           toolbar_location=None, tools="", x_axis_location="below")
        p.grid.grid_line_color = None
        p.axis.axis_line_color = None
        p.axis.major_tick_line_color = None
        p.axis.major_label_text_font_size = "5pt"
        p.axis.major_label_standoff = 0
        p.xaxis.major_label_orientation = np.pi / 3
        p.rect(x='Sam1',y='Sam2', source=source, width=1, height=1, fill_color={'field':'Neoantigens','transform':mapper}, line_color=None)

        color_bar = ColorBar(color_mapper=mapper, location=(0, 0),
                             ticker=BasicTicker(desired_num_ticks=int(len(colors)/10)))

        p.add_layout(color_bar, 'right')
        return(p)

if __name__=="__main__":