lotsofcells 0.3.0__tar.gz → 0.4.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lotsofcells
3
- Version: 0.3.0
3
+ Version: 0.4.1
4
4
  Summary: Python port of lotsOfCells: proportion-test statistics and visualization on single-cell metadata. Compatible with scanpy/AnnData and spatial transcriptomics.
5
5
  Author: Oscar Gonzalez-Velasco
6
6
  License: MIT
@@ -6,12 +6,14 @@ from typing import Optional, Sequence, Union
6
6
  import numpy as np
7
7
  import pandas as pd
8
8
 
9
- # Default palette mirrors the R version (alpha 0.95 + slight desaturation).
9
+ # Default categorical palette scanpy `default_20` (Vega-20 with
10
+ # yellow/green hues swapped for higher contrast). The de facto standard in
11
+ # the single-cell community, so colours feel native to scanpy figures.
10
12
  _DEFAULT_PALETTE = [
11
- "#8DA0CB", "#926F99", "#9FBE8F", "#E8D161", "#DD8080",
12
- "#613269", "#B9E8F5", "#CBB8D0", "#F9BE8D", "#B25356",
13
- "#519B84", "#B79C76", "#C1D63C", "#F28D35", "#CA4133",
14
- "#F0DA88", "#7EAB6F", "#666666", "#3C7DA6", "#4AA147",
13
+ "#1F77B4", "#FF7F0E", "#279E68", "#D62728", "#AA40FC",
14
+ "#8C564B", "#E377C2", "#B5BD61", "#17BECF", "#AEC7E8",
15
+ "#FFBB78", "#98DF8A", "#FF9896", "#C5B0D5", "#C49C94",
16
+ "#F7B6D2", "#DBDB8D", "#9EDAE5", "#AD494A", "#8C6D31",
15
17
  ]
16
18
 
17
19
 
@@ -83,6 +83,34 @@ def lots_of_cells(
83
83
  metadata = get_metadata(sc_object, table=table)
84
84
 
85
85
  main_vals = metadata[main_variable].astype(str).to_numpy()
86
+
87
+ if isinstance(label_order[0], list) or isinstance(label_order[1], list):
88
+ if verbose:
89
+ print(f"Multiple sub-groups detected.")
90
+ # If several levels, process:
91
+ flat_order = np.array([a for b in label_order for a in b]).astype(str)
92
+ group_1 = np.array(label_order[0]).astype(str)
93
+ group_2 = np.array(label_order[1]).astype(str)
94
+ # Clean data with unwanted levels:
95
+ mask = np.isin(main_vals, flat_order)
96
+ metadata = metadata.loc[mask].copy()
97
+
98
+ # Obtain group labels:
99
+ mask_g1 = np.isin(main_vals, group_1)
100
+ mask_g2 = np.isin(main_vals, group_2)
101
+ # Define new labels:
102
+ label_1 = "loc_group_one [" + " ".join(group_1)+"]"
103
+ label_2 = "loc_group_two [" + " ".join(group_2)+"]"
104
+ # Create synthetic labels:
105
+ metadata.loc[mask_g1,"loc_tmp_group"] = label_1
106
+ metadata.loc[mask_g2,"loc_tmp_group"] = label_2
107
+ # relevel and recompute
108
+ main_variable = "loc_tmp_group"
109
+ main_vals = metadata[main_variable].astype(str).to_numpy()
110
+ # Copy original and push new:
111
+ label_order_original = label_order
112
+ label_order = [label_1, label_2]
113
+
86
114
  if not all(l in np.unique(main_vals) for l in label_order):
87
115
  missing = [l for l in label_order if l not in np.unique(main_vals)]
88
116
  raise ValueError(f"Some groups in label_order not found in data: {missing}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lotsofcells
3
- Version: 0.3.0
3
+ Version: 0.4.1
4
4
  Summary: Python port of lotsOfCells: proportion-test statistics and visualization on single-cell metadata. Compatible with scanpy/AnnData and spatial transcriptomics.
5
5
  Author: Oscar Gonzalez-Velasco
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lotsofcells"
7
- version = "0.3.0"
7
+ version = "0.4.1"
8
8
  description = "Python port of lotsOfCells: proportion-test statistics and visualization on single-cell metadata. Compatible with scanpy/AnnData and spatial transcriptomics."
9
9
  readme = "README.md"
10
10
  authors = [
File without changes