Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clustergram: app improvements #70

Merged
merged 15 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 112 additions & 43 deletions assets/clustergram-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
top: 0px;
left: 0px;
margin: 0px;
height: 100%;
min-height: 100vh;
width: 100%;
font-family: Helvetica, sans-serif;
background:#000000;
Expand All @@ -12,81 +12,150 @@
color: #dddddd;
}

#clustergram-options::-webkit-scrollbar {
width: 2px;
background-color: #000;
}
#clustergram-body > ::-webkit-scrollbar {
width: 2px;
background-color: #3e0f2e;
margin-right:5px;
}

#clustergram-options::-webkit-scrollbar-thumb {
background: #ddd;
}
#clustergram-body > ::-webkit-scrollbar-thumb {
background: #99003d;
margin-right:5px;
}

#clustergram-header {
width: calc(100% - 40px);
height:auto;
position: static;
margin-top:0px;
margin-left:0px;
font-size:28pt;
padding: 10px;
background:blue;
color:#ffffff;
#clustergram-wrapper::-webkit-scrollbar {
display: none;
}

#clustergram-options {
width: 500px;
position: relative;
width: 200px;
min-width:75px;
float:left;
top: 10px;
border: solid 2px white;
border-radius: 5px;
display: inline-block !important;
left: 20px;
border: solid 1px #3e0f2e;
padding: 20px;
max-height:300px;
overflow:scroll;
font-size: 10pt !important;
margin-top:50px;
margin-left:20px;
margin-bottom:50px;
height: 500px;
overflow-y:scroll;
font-size: 10pt !important;
border-radius: 5px;
}

#clustergram-wrapper {
height: 600px;
width:600px;
float:left;
width: 900px;
display: inline-block !important;
float:right;
padding: 0px;
margin: 0px;
overflow-x: scroll;
margin: 0px;
}
#clustergram-body .Select, #clustergram-body .Select-control, #clustergram-body input, #clustergram-body .Select-menu-outer, #clustergram-body .Select-value-label {
background-color: black !important;
color: white !important;
border-color: #3e0f2e;
}
#clustergram-file-upload-container {
width: 450px !important;
margin-left: 10px !important;
width: 80% !important;
margin-left: 5%;
margin-top: 20px;
height:20px !important;
}
#clustergram-body .Select-control {
width: 450px;
margin-left: -100px;
width: 100%;
}

#clustergram-body .Select, #clustergram-body input {
width: 225px;
width: 100%;
margin:auto;
}
#clustergram-body button {
#clustergram-body #submit-group-marker, #clustergram-body #remove-all-group-markers {
float: left;
width:110px;
margin: 6px;
font-size:8pt !important;
padding: 0px;
margin-top: 10px;
color: white;
font-weight: 100;
border-color: #99003d;
text-align: center;
width:48% !important;
transition-duration: 500ms;
}


#clustergram-body #submit-group-marker:hover, #clustergram-body #remove-all-group-markers:hover {
border-color: white;
}

#clustergram-body #submit-group-marker {
margin-right:2%;
}
#clustergram-body #remove-all-group-markers {
margin-left: 2%;
}

#clustergram-body #group-number, #clustergram-body #color {
width: 48% !important;
}
#clustergram-body #group-number {
margin-right: 2% !important;
}
#clustergram-body #color {
margin-left: 2% !important;
}
#clustergram-body input {
float:left;
width: 70px !important;
margin: 6px !important;
width: 100%;
margin: 0px;
margin-top:5px !important;
}
#clustergram-info {
margin-top: 20px;
margin-top: 50px;
margin-left: 20px;
margin-bottom:50px;
display: inline-block;
float: left;
width: 500px;
width: calc(100% - 500px);
border-radius: 5px;
padding: 20px;
border: 1px solid white;
border: 1px solid #3e0f2e;
}

#clustergram-file-upload-container{
border: dotted 1px #99003d;
width: 80%;
border-radius: 5px;
padding: 10px;
}

#clustergram-body #file-upload-name {
display: block;
width: 80%;
margin-left: 10%;
margin-top: 10px;
font-size: 10px;
}
.clustergram-option-name {
text-align: center;
font-size: 14pt;
}
#clustergram-body .Select-value {
border-color: #320f2e;
}

#clustergram-body .Select-value-icon {
color: #99003d;
border-right: 1px solid #320f2e;
}

#clustergram-body .rc-slider-track {
background-color: #99003d;
}

#clustergram-body .rc-slider-handle {
border: solid 2px #320f2e;
background-color: #99003d;
}

54 changes: 45 additions & 9 deletions dash_bio/component_factory/_clustergram.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ def figure(
[{}, {'colspan': 2}, None, {}]
],
vertical_spacing=0,
horizontal_spacing=0
horizontal_spacing=0,
print_grid=False
)

fig['layout']['hovermode'] = 'closest'
Expand All @@ -369,22 +370,56 @@ def figure(

# for column dendrogram, leaves are at bottom (y=0)
for i in range(len(t['col'])):
xs = t['col'][i]['x']
ys = t['col'][i]['y']

# during serialization (e.g., in a dcc.Store, the NaN
# values become None and the arrays get turned into lists;
# they must be converted back
if(isinstance(xs, list)):
xs = [x if x is not None else np.nan for x in xs]
xs = np.array(xs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of speed looping explicitely over arrays in python is slover than using pandas or numpy functions, it would only be important for superlarge datasets though

t['col'][i].update(
x=xs
)
if(isinstance(ys, list)):
ys = [y if y is not None else np.nan for y in ys]
ys = np.array(ys)
t['col'][i].update(
y=ys
)
tickvals_col += [
t['col'][i]['x'].flatten()[j]
for j in range(len(t['col'][i]['x'].flatten()))
if t['col'][i]['y'].flatten()[j] == 0.0 and
t['col'][i]['x'].flatten()[j] % 10 == 5
xs.flatten()[j]
for j in range(len(xs.flatten()))
if ys.flatten()[j] == 0.0 and
xs.flatten()[j] % 10 == 5
]
tickvals_col = list(set(tickvals_col))

# for row dendrogram, leaves are at right(x=0, since we
# horizontally flipped it)
for i in range(len(t['row'])):
xs = t['row'][i]['x']
ys = t['row'][i]['y']

if(isinstance(xs, list)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost the same code as above but with 'row' instead of 'col', could be done in a function for easier maintenance

xs = [x if x is not None else np.nan for x in xs]
xs = np.array(xs)
t['row'][i].update(
x=xs
)
if(isinstance(ys, list)):
ys = [y if y is not None else np.nan for y in ys]
ys = np.array(ys)
t['row'][i].update(
y=ys
)

tickvals_row += [
t['row'][i]['y'].flatten()[j]
for j in range(len(t['row'][i]['y'].flatten()))
if t['row'][i]['x'].flatten()[j] == 0.0 and
t['row'][i]['y'].flatten()[j] % 10 == 5
ys.flatten()[j]
for j in range(len(ys.flatten()))
if xs.flatten()[j] == 0.0 and
ys.flatten()[j] % 10 == 5
]

tickvals_row = list(set(tickvals_row))
Expand Down Expand Up @@ -701,6 +736,7 @@ def _dendrogramTraces(
}
self._rowLabels = scp.array(Prow['ivl'])
trace_list['row'] = self._colorDendroClusters(Prow_tmp, 'row')

return trace_list

def _colorDendroClusters(
Expand Down
Loading