marsilea 0.4.3__tar.gz → 0.4.5__tar.gz

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.
Files changed (33) hide show
  1. {marsilea-0.4.3 → marsilea-0.4.5}/PKG-INFO +2 -2
  2. {marsilea-0.4.3 → marsilea-0.4.5}/pyproject.toml +1 -1
  3. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/__init__.py +1 -1
  4. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/dataset.py +16 -9
  5. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/__init__.py +5 -1
  6. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/_seaborn.py +1 -2
  7. marsilea-0.4.5/src/marsilea/plotter/range.py +114 -0
  8. {marsilea-0.4.3 → marsilea-0.4.5}/.gitignore +0 -0
  9. {marsilea-0.4.3 → marsilea-0.4.5}/LICENSE +0 -0
  10. {marsilea-0.4.3 → marsilea-0.4.5}/README.md +0 -0
  11. {marsilea-0.4.3 → marsilea-0.4.5}/setup.py +0 -0
  12. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/_api.py +0 -0
  13. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/_deform.py +0 -0
  14. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/base.py +0 -0
  15. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/dendrogram.py +0 -0
  16. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/exceptions.py +0 -0
  17. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/heatmap.py +0 -0
  18. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/layers.py +0 -0
  19. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/layout.py +0 -0
  20. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/_utils.py +0 -0
  21. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/arc.py +0 -0
  22. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/area.py +0 -0
  23. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/bar.py +0 -0
  24. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/base.py +0 -0
  25. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/bio.py +0 -0
  26. /marsilea-0.4.3/src/marsilea/plotter/_images.py → /marsilea-0.4.5/src/marsilea/plotter/images.py +0 -0
  27. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/mesh.py +0 -0
  28. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/plotter/text.py +0 -0
  29. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/upset.py +0 -0
  30. {marsilea-0.4.3 → marsilea-0.4.5}/src/marsilea/utils.py +0 -0
  31. {marsilea-0.4.3 → marsilea-0.4.5}/src/oncoprinter/__init__.py +0 -0
  32. {marsilea-0.4.3 → marsilea-0.4.5}/src/oncoprinter/core.py +0 -0
  33. {marsilea-0.4.3 → marsilea-0.4.5}/src/oncoprinter/preset.py +0 -0
@@ -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
@@ -20,7 +20,7 @@ requires-python = ">=3.8"
20
20
  urls = {Home="https://github.com/Marsilea-viz/marsilea"}
21
21
  dependencies = [
22
22
  "numpy",
23
- "pandas",
23
+ "pandas[parquet]",
24
24
  "matplotlib>=3.6",
25
25
  "seaborn",
26
26
  "scipy",
@@ -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
@@ -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)]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes