File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -122,10 +122,26 @@ def node_heatmap(df, outdir=None):
122
122
# order the y-axis of the heatmap according to the node_order, any nodes not in that list can appear after in any order
123
123
heatmap_data = heatmap_data .loc [[x for x in heatmap_data .index if x not in node_order ] + list (reversed (node_order ))]
124
124
annot_data = annot_data .loc [[x for x in annot_data .index if x not in node_order ] + list (reversed (node_order ))]
125
+
126
+ # Sort the columns by the sum of the values in each column
127
+ heatmap_data = heatmap_data [heatmap_data .sum ().sort_values (ascending = False ).index ]
128
+ annot_data = annot_data [heatmap_data .columns ]
129
+
130
+ # Add an overall total column, this should be outside the normalizations
131
+ heatmap_data ['total' ] = heatmap_data .sum (axis = 1 )
132
+ annot_data ['total' ] = annot_data .sum (axis = 1 )
133
+
134
+ heatmap_data = heatmap_data .applymap (lambda x : min (x , limit ))
135
+ annot_data = heatmap_data .applymap (lambda x : \
136
+ #'>{}'.format(limit) \
137
+ '*' \
138
+ if x == limit else '' )
139
+
140
+ # Set the color limit to be 5
125
141
126
142
plt .figure (figsize = (5.5 , 6 ))
127
143
sns .heatmap (heatmap_data ,
128
- cmap = 'Reds' ,
144
+ cmap = 'Greys' ,
129
145
annot = annot_data ,
130
146
fmt = '' ,
131
147
cbar_kws = {'label' : 'Occurrences (* denotes more than 5)' ,
You can’t perform that action at this time.
0 commit comments