Skip to content

Commit 25db6e5

Browse files
committed
add marker.png
1 parent dbfaace commit 25db6e5

File tree

11 files changed

+374
-350
lines changed

11 files changed

+374
-350
lines changed

PyComplexHeatmap/annotations.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def _calculate_cmap(self):
223223

224224
def _type_specific_params(self):
225225
if self.ylim is None:
226-
Max = np.nanmax(self.df.sum(axis=1).values)
227-
Min = np.nanmin(self.df.sum(axis=1).values)
226+
Max = np.nanmax(self.df.values)
227+
Min = np.nanmin(self.df.values)
228228
gap = Max - Min
229229
self.ylim = [Min - 0.05 * gap, Max + 0.05 * gap]
230230

@@ -490,10 +490,9 @@ def _height(self, height):
490490
def set_plot_kws(self, axis):
491491
shrink = 1 # 1 * mm2inch * 72 # 1mm -> points
492492
if axis == 1: # columns
493-
# relpos = (
494-
# (0, 0) if self.orientation == "up" else (0, 0)
495-
# ) # position to anchor, x: left -> right, y: down -> top
496-
relpos =(0,0)
493+
relpos = (
494+
(0, 0) if self.orientation == "up" else (0, 1)
495+
) # position to anchor, x: left -> right, y: down -> top
497496
rotation = 90 if self.orientation == "up" else -90
498497
ha = "left"
499498
va = "center"
@@ -871,15 +870,15 @@ def _calculate_cmap(self):
871870
# self.set_legend(False)
872871

873872
def _type_specific_params(self):
874-
if self.ylim is None:
875-
Max = np.nanmax(self.df.sum(axis=1).values)
876-
Min = np.nanmin(self.df.sum(axis=1).values)
877-
gap = Max - Min
878-
self.ylim = [Min - 0.05 * gap, Max + 0.05 * gap]
879873
if self.ncols > 1:
880874
self.stacked = True
881875
else:
882876
self.stacked = False
877+
if self.ylim is None:
878+
Max = np.nanmax(self.df.sum(axis=1).values) if self.stacked else np.nanmax(self.df.values)
879+
Min = np.nanmin(self.df.sum(axis=1).values) if self.stacked else np.nanmin(self.df.values)
880+
gap = Max - Min
881+
self.ylim = [Min - 0.05 * gap, Max + 0.05 * gap]
883882

884883
def plot(self, ax=None, axis=1): # add self.gs,self.fig,self.ax,self.axes
885884
if ax is None:
@@ -897,7 +896,7 @@ def plot(self, ax=None, axis=1): # add self.gs,self.fig,self.ax,self.axes
897896

898897
base_coordinates = [0] * self.plot_data.shape[0]
899898
for col, color in zip(self.plot_data.columns, colors):
900-
if axis == 1:
899+
if axis == 1: #columns annotations
901900
ax.set_xticks(ticks=np.arange(0.5, self.nrows, 1))
902901
ax.bar(
903902
x=np.arange(0.5, self.nrows, 1),
@@ -997,8 +996,8 @@ def _calculate_cmap(self):
997996
self.set_legend(False)
998997

999998
def _type_specific_params(self):
1000-
Max = np.nanmax(self.df.sum(axis=1).values)
1001-
Min = np.nanmin(self.df.sum(axis=1).values)
999+
Max = np.nanmax(self.df.values)
1000+
Min = np.nanmin(self.df.values)
10021001
self.gap = Max - Min
10031002
if self.ylim is None:
10041003
self.ylim = [Min - 0.05 * self.gap, Max + 0.05 * self.gap]
@@ -1036,9 +1035,9 @@ def plot(self, ax=None, axis=1): # add self.gs,self.fig,self.ax,self.axes
10361035
c = self.plot_kws.get("c", colors)
10371036
s = self.plot_kws.get("s", self.s)
10381037
scatter_ax = ax.scatter(x=x, y=y, c=c, s=s, cmap=self.cmap, **plot_kws)
1039-
if axis == 0:
1040-
ax.set_xlim(0, self.nrows)
1041-
ax.set_ylim(*self.ylim)
1038+
if axis == 0: #row annotations
1039+
ax.set_ylim(0, self.nrows)
1040+
ax.set_xlim(*self.ylim)
10421041
ax.tick_params(
10431042
axis="both",
10441043
which="both",
@@ -1049,9 +1048,9 @@ def plot(self, ax=None, axis=1): # add self.gs,self.fig,self.ax,self.axes
10491048
)
10501049
# if self.orientation == 'left':
10511050
# ax.invert_xaxis()
1052-
else:
1053-
ax.set_ylim(0, self.nrows)
1054-
ax.set_xlim(*self.ylim)
1051+
else: #columns annotations
1052+
ax.set_xlim(0, self.nrows)
1053+
ax.set_ylim(*self.ylim)
10551054
ax.tick_params(
10561055
axis="both",
10571056
which="both",
@@ -1563,7 +1562,7 @@ def _process_data(self): # add self.annotations,self.names,self.labels
15631562
self.labels = []
15641563
for arg in self.args:
15651564
# print(arg)
1566-
ann = self.args[arg]
1565+
ann = self.args[arg] # Series, anno_* or DataFrame
15671566
if type(ann) == list or isinstance(ann, np.ndarray):
15681567
ann = pd.Series(ann).to_frame(name=arg)
15691568
elif isinstance(ann, pd.Series):
@@ -1598,8 +1597,8 @@ def _process_data(self): # add self.annotations,self.names,self.labels
15981597
self.orientation = "left"
15991598
elif self.axis == 0:
16001599
self.orientation = "right"
1600+
ann.set_orientation(self.orientation)
16011601
self.labels.append(arg)
1602-
ann.set_orientation(self.orientation)
16031602

16041603
def _set_orentation(self, orientation):
16051604
if self.orientation is None:

docs/images/markers.png

1.13 MB
Loading

notebooks/advanced_usage.ipynb

Lines changed: 163 additions & 155 deletions
Large diffs are not rendered by default.

notebooks/clustermap.ipynb

Lines changed: 37 additions & 33 deletions
Large diffs are not rendered by default.

notebooks/composite_heatmaps.ipynb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
" \n",
5555
" \n",
5656
" \n",
57+
" \n",
58+
" \n",
59+
" \n",
60+
" \n",
61+
" \n",
62+
" \n",
63+
" \n",
64+
" \n",
5765
" "
5866
]
5967
},

notebooks/gene_enrichment_analysis.ipynb

Lines changed: 17 additions & 17 deletions
Large diffs are not rendered by default.

notebooks/get_started.ipynb

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

notebooks/kwargs.ipynb

Lines changed: 10 additions & 10 deletions
Large diffs are not rendered by default.

notebooks/oncoPrint.ipynb

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)