Skip to content

Commit

Permalink
clone/subclone colormap could handle more reach clones...
Browse files Browse the repository at this point in the history
  • Loading branch information
lchorbadjiev committed Apr 10, 2019
1 parent 6320583 commit ce78bbe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
36 changes: 29 additions & 7 deletions scgv/views/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,48 @@
@author: lubo
'''
import numpy as np

import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from scgv.views.base import ViewerBase
from scgv.utils.color_map import ColorMap


class CloneViewer(ViewerBase):

def __init__(self, model):
super(CloneViewer, self).__init__(model)
self.cmap = ColorMap.make_qualitative06_with_white()
self._select_colormap()

def _select_colormap_size(self, size):
assert size <= 20
if size > 12:
cmap = plt.get_cmap('tab20')
elif size > 7:
cmap = plt.get_cmap('Paired')
else:
cmap = plt.get_cmap('tab10')
colors = ['#FFFFFF']
colors.extend(cmap.colors[:size])
return ListedColormap(colors)

def _select_colormap(self):
self.vmax = np.max(self.model.subclone)
size = int(self.vmax)
self.cmap = self._select_colormap_size(size)

def draw_clone(self, ax):
print(self.model.clone)

if self.model.clone is not None:
ax.imshow(
[self.model.clone],
aspect='auto',
interpolation='nearest',
cmap=self.cmap.colors,
cmap=self.cmap,
# norm=self.cmap.norm,
vmin=0,
vmax=6,
vmax=self.vmax,
extent=self.model.bar_extent)

ax.set_xticks([])
Expand All @@ -31,15 +53,15 @@ def draw_clone(self, ax):
ax.set_yticklabels(["Clone"])

def draw_subclone(self, ax):
print(self.model.subclone)
if self.model.subclone is not None:
ax.imshow(
[self.model.subclone],
aspect='auto',
interpolation='nearest',
cmap=self.cmap.colors,
# norm=self.cmap.norm,
cmap=self.cmap,
vmin=0,
vmax=6,
vmax=self.vmax,
extent=self.model.bar_extent)

ax.set_xticks([])
Expand Down
3 changes: 3 additions & 0 deletions scgv/views/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class TrackViewer(ViewerBase):
@classmethod
def select_colormap(self, track_mapping):
size = len(track_mapping)
return TrackViewer.select_colormap_size(size)

@classmethod
def select_colormap_size(self, size):
assert size <= 20
if size > 12:
cmap = plt.get_cmap('tab20')
Expand Down

0 comments on commit ce78bbe

Please sign in to comment.