marsilea 0.5.5__py3-none-any.whl → 0.5.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
marsilea/_version.py CHANGED
@@ -1 +1 @@
1
- version = "0.5.5"
1
+ version = "0.5.6"
marsilea/base.py CHANGED
@@ -440,18 +440,16 @@ class WhiteBoard(LegendMaker):
440
440
  self.add_plot("bottom", plot, name, size, pad, legend)
441
441
 
442
442
  def _render_plan(self):
443
- for plan in self._col_plan:
444
- axes = self.layout.get_ax(plan.name)
445
- plan.render(axes)
443
+ try:
444
+ for plan in self._col_plan + self._row_plan:
445
+ axes = self.layout.get_ax(plan.name)
446
+ plan.render(axes)
446
447
 
447
- # render other plots
448
- for plan in self._row_plan:
449
- axes = self.layout.get_ax(plan.name)
450
- plan.render(axes)
451
-
452
- main_ax = self.get_main_ax()
453
- for plan in self._get_layers_zorder():
454
- plan.render(main_ax)
448
+ main_ax = self.get_main_ax()
449
+ for plan in self._get_layers_zorder():
450
+ plan.render(main_ax)
451
+ except Exception as e:
452
+ raise Exception(f"An error occur during rendering of {plan}") from e
455
453
 
456
454
  def add_layer(self, plot: RenderPlan, zorder=None, name=None, legend=True):
457
455
  """Add a plotter to the main canvas
@@ -655,7 +653,8 @@ class WhiteBoard(LegendMaker):
655
653
  def save(self, fname, **kwargs):
656
654
  """Save the figure to a file
657
655
 
658
- This will force a re-render of the figure
656
+ Save the current opened figure to a file, if no figure is open,
657
+ a render will be performed first.
659
658
 
660
659
  Parameters
661
660
  ----------
@@ -665,7 +664,8 @@ class WhiteBoard(LegendMaker):
665
664
  Additional options for saving the figure, will be passed to :meth:`~matplotlib.pyplot.savefig`
666
665
 
667
666
  """
668
- self.render()
667
+ if self.figure is None:
668
+ self.render()
669
669
  save_options = dict(bbox_inches="tight")
670
670
  save_options.update(kwargs)
671
671
  self.figure.savefig(fname, **save_options)
@@ -1364,23 +1364,19 @@ class ClusterBoard(WhiteBoard):
1364
1364
 
1365
1365
  def _render_plan(self):
1366
1366
  deform = self.get_deform()
1367
- for plan in self._col_plan:
1368
- if plan.allow_split:
1369
- plan.set_deform(deform)
1370
- axes = self.layout.get_ax(plan.name)
1371
- plan.render(axes)
1367
+ try:
1368
+ for plan in self._col_plan + self._row_plan:
1369
+ if plan.allow_split:
1370
+ plan.set_deform(deform)
1371
+ axes = self.layout.get_ax(plan.name)
1372
+ plan.render(axes)
1372
1373
 
1373
- # render other plots
1374
- for plan in self._row_plan:
1375
- if plan.allow_split:
1374
+ main_ax = self.get_main_ax()
1375
+ for plan in self._get_layers_zorder():
1376
1376
  plan.set_deform(deform)
1377
- axes = self.layout.get_ax(plan.name)
1378
- plan.render(axes)
1379
-
1380
- main_ax = self.get_main_ax()
1381
- for plan in self._get_layers_zorder():
1382
- plan.set_deform(deform)
1383
- plan.render(main_ax)
1377
+ plan.render(main_ax)
1378
+ except Exception as e:
1379
+ raise Exception(f"An error occur during rending of {plan}") from e
1384
1380
 
1385
1381
  def get_deform(self):
1386
1382
  """Return the deformation object of the cluster data"""
marsilea/plotter/mesh.py CHANGED
@@ -577,7 +577,6 @@ class SizedMesh(MeshBase):
577
577
  self.alpha = alpha
578
578
  self.frameon = frameon
579
579
 
580
- self.edgecolor = None
581
580
  if edgecolor is not None:
582
581
  if is_color_like(edgecolor):
583
582
  self.edgecolor = np.repeat(edgecolor, size.size).reshape(size.shape)
@@ -593,6 +592,9 @@ class SizedMesh(MeshBase):
593
592
  edgecolor = [[to_hex(c) for c in row] for row in edgecolor]
594
593
  self.edgecolor = np.asarray(edgecolor)
595
594
  self._single_edgecolor = False
595
+ else:
596
+ self.edgecolor = np.full_like(size, "#00000000", dtype=object)
597
+ self._single_edgecolor = True
596
598
  self.linewidth = linewidth
597
599
  self.set_label(label, label_loc, label_props)
598
600
  self.grid = grid
@@ -601,6 +603,7 @@ class SizedMesh(MeshBase):
601
603
  self.kwargs = kwargs
602
604
 
603
605
  self._collections = None
606
+ self._transparent_marker = "none" in self.color2d
604
607
  render_data = [self.size_matrix, self.color2d]
605
608
  if self.edgecolor is not None:
606
609
  render_data.append(self.edgecolor)
@@ -624,6 +627,8 @@ class SizedMesh(MeshBase):
624
627
  if self.edgecolor is not None:
625
628
  if self._single_edgecolor:
626
629
  edgecolor = self.edgecolor.flatten()[0]
630
+ if self._transparent_marker & (edgecolor is None):
631
+ edgecolor = "black"
627
632
  handler_kw = dict(edgecolor=edgecolor, linewidth=self.linewidth)
628
633
  options = dict(
629
634
  colors=size_color,
@@ -642,7 +647,7 @@ class SizedMesh(MeshBase):
642
647
  unique_ecs = np.unique(self.edgecolor)
643
648
  if len(self.edgecolor_legend_text) == len(unique_ecs):
644
649
  legend_items = [
645
- ("circle", text, dict(ec=ec, fc="none"))
650
+ ("circle", text, dict(ec=ec, fc="none", lw=self.linewidth))
646
651
  for text, ec in zip(self.edgecolor_legend_text, unique_ecs)
647
652
  ]
648
653
  ec_legend = ListLegend(
@@ -654,8 +659,7 @@ class SizedMesh(MeshBase):
654
659
  "If edgecolor legend text is provided, the number of unique edgecolors "
655
660
  "must match the number of texts"
656
661
  )
657
-
658
- if self._has_colormesh & (self.color != "none"):
662
+ if self._has_colormesh & (self._transparent_marker):
659
663
  if self.palette is not None:
660
664
  labels, colors = [], []
661
665
  for label, c in self.palette.items():
@@ -708,9 +712,9 @@ class SizedMesh(MeshBase):
708
712
  marker=self.marker,
709
713
  )
710
714
  if self.color is not None:
711
- options["c"] = color
715
+ options["c"] = color.flatten()
712
716
  else:
713
- options.update(dict(c=color, norm=self.norm, cmap=self.cmap))
717
+ options.update(dict(c=color.flatten(), norm=self.norm, cmap=self.cmap))
714
718
  self._collections = ax.scatter(xv, yv, **options, **self.kwargs)
715
719
 
716
720
  close_ticks(ax)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marsilea
3
- Version: 0.5.5
3
+ Version: 0.5.6
4
4
  Summary: Declarative creation of composable visualizations
5
5
  Project-URL: Home, https://github.com/Marsilea-viz/marsilea
6
6
  Project-URL: Documentation, https://marsilea.readthedocs.io
@@ -1,8 +1,8 @@
1
1
  marsilea/__init__.py,sha256=mMtII0QzSVGrr1vJXTglr6wBd2AHElrDnDp1iGQbOxo,626
2
2
  marsilea/_api.py,sha256=tymWZHfjhx8-0NNd9762znfdIu36NrARRweEIr5L1mA,283
3
3
  marsilea/_deform.py,sha256=QRz4OGXMsQzbiIkC3ASzZayMPhHhoFsEK38oBzSeQG8,14440
4
- marsilea/_version.py,sha256=v9c8T1qB0Dxuq0vdkPvh2bpcAlRxlK4BxHPcACDymFw,18
5
- marsilea/base.py,sha256=CmzuwFu0JzgkNpPdI1SqAnkUxINShjT73hrJpksKjhE,46872
4
+ marsilea/_version.py,sha256=FtfC8ptaFH0Unc72bPRynMH_N62bxa4tnazGgIcgnTY,18
5
+ marsilea/base.py,sha256=GBgSirueH65nhfkunCVYhV7ePX4i01jog5gzkBBOsi0,46951
6
6
  marsilea/dataset.py,sha256=Qh8k1DhTiwP_Me709CkpNwRaYLDzlenRTIk0U6D58_g,4631
7
7
  marsilea/dendrogram.py,sha256=Ung43zseybZKzTEvH5P_ge3WGfsr7i7qsX7YEVDlC74,15590
8
8
  marsilea/exceptions.py,sha256=wN5ElUZxuaJKSnnwWdkNx6P-Oc16dzSuaRPbRKWIBEM,1046
@@ -20,13 +20,13 @@ marsilea/plotter/bar.py,sha256=RWDsNbyCUKbybpsBOgbl43lVZc_ynZmTOevE-CtJ5KE,12354
20
20
  marsilea/plotter/base.py,sha256=b_NmrW_oNPc-HwQsjx1NsC2lknYK6qSaDp_7SxeoUEM,18938
21
21
  marsilea/plotter/bio.py,sha256=34tucmxs4LM3TFZoGsrjnXTolyrzYaHVEiRe4dzDH68,5040
22
22
  marsilea/plotter/images.py,sha256=gb0xIQhUch3rNAt3FfvuUoamSGEynoBBBky2eE754ec,9560
23
- marsilea/plotter/mesh.py,sha256=t9odi21DtrcSmoBQWtYyqmX5_gYDb4wNZQH_VrBjrtY,27190
23
+ marsilea/plotter/mesh.py,sha256=ARDPWrQLbdIS22B7Ct_aYPXY7IxwVKcICdBBhg8UplE,27482
24
24
  marsilea/plotter/range.py,sha256=sXWKrvpq7nU7giiHPjayM7h9Q7gblhjXxHm8ioB3cm4,3770
25
25
  marsilea/plotter/text.py,sha256=6S4mnAxLJLMkduKiyor03lPd86oTOJ5TojVREA9oU6s,37466
26
26
  oncoprinter/__init__.py,sha256=efshcAD1h9s-NVJj4HLU9-hXc_LtTeIrNYqLHl-sm_g,106
27
- oncoprinter/core.py,sha256=5KPnKW5ivlxPp14uJd0OtfTv-pXV2UEym8EbII2VCcw,11846
28
- oncoprinter/preset.py,sha256=mBk2tFCqoTj_1ZZKRYuv4j2I3NTBa6Swc9wjzbmxRVw,8238
29
- marsilea-0.5.5.dist-info/METADATA,sha256=k47nj_h3fBERMN2AXbhVg9yZkrNujRnDVIASpTk1qKE,7265
30
- marsilea-0.5.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- marsilea-0.5.5.dist-info/licenses/LICENSE,sha256=RhHHDuP61qzKmfHtOQUVLZfCgMkKx9PXzxzkLtmAjHo,1078
32
- marsilea-0.5.5.dist-info/RECORD,,
27
+ oncoprinter/core.py,sha256=XBIwTsAvcA-mJSwHU0xpaTBCxBNh7yusmzblRATmekY,11866
28
+ oncoprinter/preset.py,sha256=lo6Llz31KVFt3QOFgFc0BunloZV1FxcFVpH8kOfarNw,8363
29
+ marsilea-0.5.6.dist-info/METADATA,sha256=Ve7qLr7YzOz8bKG10ZIgJHYxPSiGyOXfdhhQrk4oDTE,7265
30
+ marsilea-0.5.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ marsilea-0.5.6.dist-info/licenses/LICENSE,sha256=RhHHDuP61qzKmfHtOQUVLZfCgMkKx9PXzxzkLtmAjHo,1078
32
+ marsilea-0.5.6.dist-info/RECORD,,
oncoprinter/core.py CHANGED
@@ -168,7 +168,7 @@ class GenomicData:
168
168
  cs = {}
169
169
  for track, df in gb:
170
170
  cs[track] = Counter(df["event"])
171
- return pd.DataFrame(cs).fillna(0.0)
171
+ return pd.DataFrame(cs).fillna(0.0).loc[:, self.tracks]
172
172
 
173
173
  def get_sample_mutation_types(self):
174
174
  gb = self.data.groupby("sample", sort=False, observed=True)
oncoprinter/preset.py CHANGED
@@ -125,6 +125,9 @@ class MatchRule:
125
125
 
126
126
  MATCH_POOL = {
127
127
  Alteration.AMP: MatchRule(startswith="amp"),
128
+ Alteration.BACKGROUND: MatchRule(
129
+ contains=["background", "no", "none", "na", "nan", "bg"], flexible=True
130
+ ),
128
131
  Alteration.GAIN: MatchRule(startswith="gain"),
129
132
  Alteration.HOMDEL: MatchRule(
130
133
  startswith="homdel", contains=["deep", "deletion"], flexible=True