marsilea 0.4.3__py3-none-any.whl → 0.4.5__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/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Declarative creation of composable visualization"""
2
2
 
3
- __version__ = "0.4.3"
3
+ __version__ = "0.4.5"
4
4
 
5
5
  import marsilea.plotter as plotter
6
6
  from ._deform import Deformation
marsilea/dataset.py CHANGED
@@ -10,15 +10,15 @@ BASE_URL = "https://raw.githubusercontent.com/Marsilea-viz/marsilea-data/main"
10
10
  def load_data(name, cache=True):
11
11
  """To load marsilea dataset
12
12
 
13
- - 'cooking_oils': Cooking oils dataset
14
- - 'imdb': The IMDB Top 100 Movies
15
- - 'pbmc3k': single-cell RNA-seq dataset from 10X Genomics
16
- - 'oncoprint': Subsample of Breast Invasive Carcinoma
17
- (TCGA, PanCancer Atlas)
18
- - 'mouse_embryo': Spatial mapping of mouse embryo at E12.5
19
- - 'seq_align': Sequence alignment data
20
- - 'les_miserables': Characters in Les Misérables
21
- - 'sc_multiomics': Single-cell multi-omics dataset from COVID-19 patients
13
+ - `cooking_oils`: Cooking oils dataset
14
+ - `imdb`: The IMDB Top 100 Movies
15
+ - `pbmc3k`: single-cell RNA-seq dataset from 10X Genomics
16
+ - `oncoprint`: Subsample of Breast Invasive Carcinoma (TCGA, PanCancer Atlas)
17
+ - `mouse_embryo`: Spatial mapping of mouse embryo at E12.5
18
+ - `seq_align`: Sequence alignment data
19
+ - `les_miserables`: Characters in Les Misérables
20
+ - `sc_multiomics`: Single-cell multi-omics dataset from COVID-19 patients
21
+ - `track`: Track data from GEO GSE137105 for MYC gene
22
22
 
23
23
  Parameters
24
24
  ----------
@@ -47,6 +47,8 @@ def load_data(name, cache=True):
47
47
  return _load_cooking_oils(cache)
48
48
  elif name == "les_miserables":
49
49
  return _load_les_miserables(cache)
50
+ elif name == "track":
51
+ return _load_track(cache)
50
52
  else:
51
53
  raise NameError("Dataset not found")
52
54
 
@@ -151,3 +153,8 @@ def _load_les_miserables(cache=True):
151
153
  cache=cache,
152
154
  )
153
155
  return {"nodes": pd.read_csv(nodes), "links": pd.read_csv(links)}
156
+
157
+
158
+ def _load_track(cache=True):
159
+ data = _cache_remote("track.parquet", cache=cache)
160
+ return pd.read_parquet(data)
@@ -23,6 +23,9 @@ __all__ = [
23
23
  "Chunk",
24
24
  "FixedChunk",
25
25
  "Area",
26
+ "Image",
27
+ "Emoji",
28
+ "Range",
26
29
  ]
27
30
 
28
31
  from ._seaborn import Bar, Box, Boxen, Violin, Point, Strip, Swarm
@@ -33,5 +36,6 @@ from .bio import SeqLogo
33
36
  from .mesh import Colors, ColorMesh, SizedMesh, MarkerMesh, TextMesh
34
37
  from .text import Labels, AnnoLabels, Title, Chunk, FixedChunk
35
38
 
36
- from ._images import Emoji, Image
39
+ from .images import Emoji, Image
37
40
  from .area import Area
41
+ from .range import Range
@@ -96,7 +96,7 @@ class _SeabornBase(StatsBase):
96
96
  df["hue"] = hue
97
97
  dfs.append(df)
98
98
 
99
- pdata = pd.concat(dfs)
99
+ pdata = pd.concat(dfs).reset_index(drop=True)
100
100
  self.kws["hue"] = "hue"
101
101
  self.kws["hue_order"] = self.hue
102
102
  if self.get_orient() == "h":
@@ -123,7 +123,6 @@ class _SeabornBase(StatsBase):
123
123
  ax.invert_xaxis()
124
124
  # barplot(data=data, orient=orient, ax=ax, **self.kws)
125
125
  plotter = getattr(seaborn, self._seaborn_plot)
126
-
127
126
  plotter(data=pdata, orient=orient, ax=ax, **options)
128
127
  ax.set(xlabel=None, ylabel=None)
129
128
  leg = ax.get_legend()
@@ -0,0 +1,114 @@
1
+ import pandas as pd
2
+ from legendkit import cat_legend
3
+
4
+ from marsilea.plotter.base import StatsBase, RenderSpec
5
+
6
+
7
+ class Range(StatsBase):
8
+ """Range plot
9
+
10
+ The range plot shows the range between two categories.
11
+ The input data should be a DataFrame with two columns.
12
+
13
+ Parameters
14
+ ----------
15
+ data : array-like or DataFrame
16
+ The input data.
17
+ items : array-like, default: None
18
+ The names of the items.
19
+ marker : str, default: 'o'
20
+ The marker style.
21
+ markersize : float, default: 50
22
+ The size of the marker.
23
+ color1 : str, default: '#F75940'
24
+ The color of the first range.
25
+ color2 : str, default: '#3DC7BE'
26
+ The color of the second range.
27
+ edgecolor1 : str, default: 'black'
28
+ The edge color of the first range.
29
+ edgecolor2 : str, default: 'black'
30
+ The edge color of the second range.
31
+ edgewidth : float, default: 1
32
+ The width of the edge.
33
+ linecolor : str, default: 'black'
34
+ The color of the line.
35
+ linewidth : float, default: 1
36
+ The width of the line.
37
+ label : str, default: None
38
+ The label of the plot.
39
+
40
+ Examples
41
+ --------
42
+
43
+ .. plot::
44
+ :context: close-figs
45
+
46
+ >>> import marsilea as ma
47
+ >>> import numpy as np
48
+ >>> data = np.random.rand(10, 2)
49
+ >>> range_data = np.random.randint(1, 100, (10, 2))
50
+ >>> h = ma.Heatmap(data)
51
+ >>> h.add_left(ma.plotter.Range(range_data, items=["A", "B"]))
52
+ >>> h.render()
53
+
54
+
55
+ """
56
+
57
+ def __init__(self,
58
+ data,
59
+ items=None,
60
+ marker='o',
61
+ markersize=50,
62
+ color1='#F75940',
63
+ color2='#3DC7BE',
64
+ edgecolor1='black',
65
+ edgecolor2='black',
66
+ edgewidth=1,
67
+ linecolor='black',
68
+ linewidth=1,
69
+ label=None,
70
+ ):
71
+ if isinstance(data, pd.DataFrame):
72
+ if items is None:
73
+ items = data.columns
74
+ data = data.to_numpy()
75
+ else:
76
+ data = data
77
+ if items is None:
78
+ items = [f"Item {i}" for i in range(data.shape[1])]
79
+ data = self.data_validator(data, target="2d")
80
+ self.set_data(data.T)
81
+ self.set_label(label)
82
+ self.items = items
83
+ self.marker = marker
84
+ self.markersize = markersize
85
+ self.color1 = color1
86
+ self.color2 = color2
87
+ self.edgecolor1 = edgecolor1
88
+ self.edgecolor2 = edgecolor2
89
+ self.edgewidth = edgewidth
90
+ self.linecolor = linecolor
91
+ self.linewidth = linewidth
92
+
93
+ def render_ax(self, spec: RenderSpec):
94
+ ax = spec.ax
95
+ data = spec.data.T
96
+
97
+ for ix, (r1, r2) in enumerate(data):
98
+ ix += .5
99
+ x, y = [ix, ix], [r1, r2]
100
+ if self.is_flank:
101
+ x, y = y, x
102
+ ax.scatter([x[0]], [y[0]], s=self.markersize, marker=self.marker, color=self.color1, edgecolor=self.edgecolor1, zorder=1)
103
+ ax.scatter([x[1]], [y[1]], s=self.markersize, marker=self.marker, color=self.color2, edgecolor=self.edgecolor2, zorder=1)
104
+ ax.plot(x, y, color=self.linecolor, linewidth=self.linewidth, zorder=0)
105
+
106
+ if self.is_flank:
107
+ ax.set_ylim(0, len(data))
108
+ else:
109
+ ax.set_xlim(0, len(data))
110
+ if self.side == "left":
111
+ ax.invert_xaxis()
112
+
113
+ def get_legends(self):
114
+ return [cat_legend(colors=[self.color1, self.color2], labels=self.items, title=self.label)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: marsilea
3
- Version: 0.4.3
3
+ Version: 0.4.5
4
4
  Dynamic: Summary
5
5
  Project-URL: Home, https://github.com/Marsilea-viz/marsilea
6
6
  Author: Zhihang Zheng
@@ -34,7 +34,7 @@ Requires-Python: >=3.8
34
34
  Requires-Dist: legendkit
35
35
  Requires-Dist: matplotlib>=3.6
36
36
  Requires-Dist: numpy
37
- Requires-Dist: pandas
37
+ Requires-Dist: pandas[parquet]
38
38
  Requires-Dist: platformdirs
39
39
  Requires-Dist: scipy
40
40
  Requires-Dist: seaborn
@@ -1,8 +1,8 @@
1
- marsilea/__init__.py,sha256=JcEA1veLIQxh9VhgwDL3yqf0Xo093E0yw3JvhDa5eqc,541
1
+ marsilea/__init__.py,sha256=nkadSbkaa3uQlMyW-30zoKVfLRPUOEh9mWHKKWTC1ag,541
2
2
  marsilea/_api.py,sha256=tymWZHfjhx8-0NNd9762znfdIu36NrARRweEIr5L1mA,283
3
3
  marsilea/_deform.py,sha256=QRz4OGXMsQzbiIkC3ASzZayMPhHhoFsEK38oBzSeQG8,14440
4
4
  marsilea/base.py,sha256=aj15043lJURGR83T3q8Y8UUpeVHHLsi8T9VLol6KB1I,47552
5
- marsilea/dataset.py,sha256=a0mXjPu9_tRGHofnnQaTryFpxftkfqldq_ZLXMSBf7A,4410
5
+ marsilea/dataset.py,sha256=Qh8k1DhTiwP_Me709CkpNwRaYLDzlenRTIk0U6D58_g,4631
6
6
  marsilea/dendrogram.py,sha256=Ung43zseybZKzTEvH5P_ge3WGfsr7i7qsX7YEVDlC74,15590
7
7
  marsilea/exceptions.py,sha256=wN5ElUZxuaJKSnnwWdkNx6P-Oc16dzSuaRPbRKWIBEM,1046
8
8
  marsilea/heatmap.py,sha256=UhRcBFhx1JKrtndZPvQCDaiMt8Pb314PT1BtL-JndCY,4208
@@ -10,21 +10,22 @@ marsilea/layers.py,sha256=puXLlGGpEqAzaTqadpgpsYmIDPH33WyyHIuysRSqFZQ,12163
10
10
  marsilea/layout.py,sha256=X8MGPlAbbr7dcZiqW4pI7sEb8U3jVaiS7t1DKOqMYLI,27758
11
11
  marsilea/upset.py,sha256=U1Rsmo1WpCAV9z3LBlE2L4T0nAW9ols8Z36fXzmXycw,30388
12
12
  marsilea/utils.py,sha256=y_KYs4ToiuKEsiBdmcIVtmxMXFpD4wKiJ0k7iBa11z8,2854
13
- marsilea/plotter/__init__.py,sha256=6O05ShbbXdRmvbpLiEOBEZ_oZJkAMVh3Rh9jBU8QF-A,743
14
- marsilea/plotter/_images.py,sha256=gb0xIQhUch3rNAt3FfvuUoamSGEynoBBBky2eE754ec,9560
15
- marsilea/plotter/_seaborn.py,sha256=-0mtE-C_3zNjYWykJT5EMkJhU8FYCo12bBuJfbWvl3k,8264
13
+ marsilea/plotter/__init__.py,sha256=la30o20zYiHWN2RzElhS8MMCbGKbDDEe0WHXakq9OBQ,806
14
+ marsilea/plotter/_seaborn.py,sha256=ljliCzNLw3nNIPEiNPwjITwFcP16eAW7jIW_Ljl11jc,8286
16
15
  marsilea/plotter/_utils.py,sha256=Efhdk-TrrAanhbXRiEVWThMYvZ4vVHZMVYMs5X3JvIM,710
17
16
  marsilea/plotter/arc.py,sha256=44BKVGvDc_OpghfgEvaiVCovZe7_OwZiM20iepaRMFw,8139
18
17
  marsilea/plotter/area.py,sha256=zjjAhvgKHYe9rqzcseqZqhwfpgvzm0w2FRJ_vr9Fxm4,2650
19
18
  marsilea/plotter/bar.py,sha256=tXM5iR4cTkTrt55ff-aWoh7lxupKtA5vJ9Yn9hr7RkA,12067
20
19
  marsilea/plotter/base.py,sha256=TbnZDjm161RF5OlK4TCfhCFR9lM96MJUrvAk_xTk_kQ,20657
21
20
  marsilea/plotter/bio.py,sha256=34tucmxs4LM3TFZoGsrjnXTolyrzYaHVEiRe4dzDH68,5040
21
+ marsilea/plotter/images.py,sha256=gb0xIQhUch3rNAt3FfvuUoamSGEynoBBBky2eE754ec,9560
22
22
  marsilea/plotter/mesh.py,sha256=eUMXX9PNHJXf9O4wpcRgO6uEFKlpft1LwshHgMuojp8,24176
23
+ marsilea/plotter/range.py,sha256=tkCSTpr1CcmBo5D9PpUF6cugPRCeuS8ZSIB9lHJLMhU,3575
23
24
  marsilea/plotter/text.py,sha256=6S4mnAxLJLMkduKiyor03lPd86oTOJ5TojVREA9oU6s,37466
24
25
  oncoprinter/__init__.py,sha256=efshcAD1h9s-NVJj4HLU9-hXc_LtTeIrNYqLHl-sm_g,106
25
26
  oncoprinter/core.py,sha256=5KPnKW5ivlxPp14uJd0OtfTv-pXV2UEym8EbII2VCcw,11846
26
27
  oncoprinter/preset.py,sha256=mBk2tFCqoTj_1ZZKRYuv4j2I3NTBa6Swc9wjzbmxRVw,8238
27
- marsilea-0.4.3.dist-info/METADATA,sha256=edIeq4SMz38_uWLlkpiesySBghHd-1wEg72AYO7llFk,6576
28
- marsilea-0.4.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
29
- marsilea-0.4.3.dist-info/licenses/LICENSE,sha256=2TLD8FnLJqXzg8YBRs7W3VZBwfWfp4ArDfBl-rn96Qc,1074
30
- marsilea-0.4.3.dist-info/RECORD,,
28
+ marsilea-0.4.5.dist-info/METADATA,sha256=dIb6Uc7Yb53FZ505ixuIUuzcATfOsqsFj7VugAFcKcM,6585
29
+ marsilea-0.4.5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
30
+ marsilea-0.4.5.dist-info/licenses/LICENSE,sha256=2TLD8FnLJqXzg8YBRs7W3VZBwfWfp4ArDfBl-rn96Qc,1074
31
+ marsilea-0.4.5.dist-info/RECORD,,
File without changes