Skip to content

Commit

Permalink
handling of whitespace in guide table added...
Browse files Browse the repository at this point in the history
  • Loading branch information
lchorbadjiev committed Mar 27, 2019
1 parent 4ba34d3 commit 1dcd8de
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
9 changes: 8 additions & 1 deletion scgv/models/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def load(self):
self.ratio_df = self.data.get('ratio', None)
self.clone_df = self.data.get('clone', None)
self.tree_df = self.data.get('tree', None)
self.guide_df = self.data.get('guide', None)
self.guide_df = self._guide_clenup(self.data.get('guide', None))
self.featuremat_df = self.data.get('featuremat', None)
self.features_df = self.data.get('features', None)
self.genome = self.data.get('genome', 'hg19')
Expand All @@ -46,6 +46,13 @@ def load(self):
assert self.seg_df is not None
assert self.genome is not None

def _guide_clenup(self, guide_df):
if guide_df is None:
return None
for column in guide_df.select_dtypes(include=[object]).columns:
guide_df[column] = guide_df[column].str.strip()
return guide_df

@classmethod
def _organize_filenames(cls, namelist):
print(namelist)
Expand Down
8 changes: 5 additions & 3 deletions scgv/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ def make_sectors_legend(self):
return None

sectors, sector_mapping = self.make_sector(self.ordering)
print(sector_mapping)

pathology_mapping = {}
for sector_key, sector_value in sector_mapping.items():
sector_df = self.data.guide_df[
Expand All @@ -290,7 +288,11 @@ def make_sectors_legend(self):
.format(
sector_key,
sector_df[self.PATHOLOGY_COLUMN].unique()))
pathology_mapping[str(pathology).strip()] = sector_value

pathology = str(pathology).strip()
assert pathology not in pathology_mapping

pathology_mapping[pathology] = sector_value
return sectors, pathology_mapping


Expand Down
7 changes: 3 additions & 4 deletions scgv/qtviews/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ def show(self):
vmin = min(self.mapping.values())

self.legend.clear()
print(self.mapping)

for key, value in self.mapping.items():
color = self.cmap.colors[int(value) - vmin]
index = int(value) - vmin
color = self.cmap.colors[index]
self.legend.add_entry(
text=str(key),
color=color)
Expand Down Expand Up @@ -257,7 +256,7 @@ def set_model(self, model):

self.legend.set_model(model)
self.model = model
self.tracks = self.model.tracks
self.tracks = self.model.tracks
self.selected_track = None
if not self.tracks:
return
Expand Down
7 changes: 2 additions & 5 deletions scgv/views/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ def select_colormap(self, track_mapping):

assert size <= 20
if size > 12:
print("select_colormap: tab20")
cmap = plt.get_cmap('tab20')
elif size > 7:
print("select_colormap: Paired")
cmap = plt.get_cmap('Paired')
else:
print("select_colormap: tab10")
cmap = plt.get_cmap('tab10')

return ListedColormap(cmap.colors[:size])
colors = cmap.colors[:size]
return ListedColormap(colors)

def __init__(self, model, track_name, track, mapping):
super(TrackViewer, self).__init__(model)
Expand Down

0 comments on commit 1dcd8de

Please sign in to comment.