spatialcore 0.2.0__tar.gz → 0.2.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.
Files changed (51) hide show
  1. {spatialcore-0.2.0 → spatialcore-0.2.1}/PKG-INFO +1 -1
  2. {spatialcore-0.2.0 → spatialcore-0.2.1}/pyproject.toml +1 -1
  3. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/__init__.py +1 -1
  4. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/training.py +36 -3
  5. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore.egg-info/PKG-INFO +1 -1
  6. {spatialcore-0.2.0 → spatialcore-0.2.1}/LICENSE +0 -0
  7. {spatialcore-0.2.0 → spatialcore-0.2.1}/README.md +0 -0
  8. {spatialcore-0.2.0 → spatialcore-0.2.1}/setup.cfg +0 -0
  9. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/__init__.py +0 -0
  10. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/acquisition.py +0 -0
  11. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/annotate.py +0 -0
  12. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/cellxgene.py +0 -0
  13. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/confidence.py +0 -0
  14. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/discovery.py +0 -0
  15. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/expression.py +0 -0
  16. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/loading.py +0 -0
  17. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/markers.py +0 -0
  18. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/ontology.py +0 -0
  19. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/patterns.py +0 -0
  20. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/pipeline.py +0 -0
  21. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/synapse.py +0 -0
  22. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/annotation/validation.py +0 -0
  23. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/core/__init__.py +0 -0
  24. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/core/cache.py +0 -0
  25. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/core/logging.py +0 -0
  26. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/core/metadata.py +0 -0
  27. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/core/utils.py +0 -0
  28. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/data/gene_mappings/ensembl_to_hugo_human.tsv +0 -0
  29. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/data/markers/canonical_markers.json +0 -0
  30. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/data/ontology_mappings/ontology_index.json +0 -0
  31. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/__init__.py +0 -0
  32. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/benchmark.py +0 -0
  33. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/celltype.py +0 -0
  34. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/confidence.py +0 -0
  35. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/spatial.py +0 -0
  36. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/utils.py +0 -0
  37. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/plotting/validation.py +0 -0
  38. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/r_bridge/__init__.py +0 -0
  39. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/r_bridge/subprocess_runner.py +0 -0
  40. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/spatial/__init__.py +0 -0
  41. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/spatial/autocorrelation.py +0 -0
  42. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/spatial/distance.py +0 -0
  43. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/spatial/domains.py +0 -0
  44. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/spatial/neighborhoods.py +0 -0
  45. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/stats/__init__.py +0 -0
  46. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/stats/_thresholding.py +0 -0
  47. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore/stats/classify.py +0 -0
  48. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore.egg-info/SOURCES.txt +0 -0
  49. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore.egg-info/dependency_links.txt +0 -0
  50. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore.egg-info/requires.txt +0 -0
  51. {spatialcore-0.2.0 → spatialcore-0.2.1}/src/spatialcore.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatialcore
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Standardized spatial statistics tools for computational biology
5
5
  Author: SpatialCore Contributors
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spatialcore"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Standardized spatial statistics tools for computational biology"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -5,7 +5,7 @@ A thin, robust wrapper around standard libraries to ensure Python and R users
5
5
  get the exact same result for the same biological question.
6
6
  """
7
7
 
8
- __version__ = "0.2.0"
8
+ __version__ = "0.2.1"
9
9
 
10
10
  # Track which modules are available in this installation
11
11
  _available_modules: list[str] = []
@@ -1243,8 +1243,8 @@ def subsample_balanced(
1243
1243
  max_cells_per_type : int, default 5000
1244
1244
  Maximum cells per cell type in output.
1245
1245
  min_cells_per_type : int, default 50
1246
- Cell types with fewer cells than this are kept entirely
1247
- (no subsampling applied).
1246
+ Minimum cells required to keep a cell type. Types with fewer
1247
+ cells are removed before balancing.
1248
1248
  source_column : str, optional, default "reference_source"
1249
1249
  Column identifying which reference each cell came from.
1250
1250
  Set to None to disable source-aware balancing (simple capping).
@@ -1387,8 +1387,41 @@ def subsample_balanced(
1387
1387
  else:
1388
1388
  cell_types = adata.obs[label_column].astype(str)
1389
1389
 
1390
- unique_types = cell_types.unique()
1391
1390
  type_counts = cell_types.value_counts()
1391
+ if min_cells_per_type > 0:
1392
+ low_count_types = type_counts[type_counts < min_cells_per_type].index.tolist()
1393
+ if low_count_types:
1394
+ n_removed = int(type_counts[type_counts < min_cells_per_type].sum())
1395
+ logger.info(
1396
+ f"\nFiltering low-count cell types (<{min_cells_per_type} cells) before balancing:"
1397
+ )
1398
+ logger.info(f" Removing {len(low_count_types)} types, {n_removed:,} cells")
1399
+ for ct in low_count_types[:10]:
1400
+ logger.info(f" {ct}: {type_counts[ct]} cells")
1401
+ if len(low_count_types) > 10:
1402
+ logger.info(f" ... and {len(low_count_types) - 10} more types")
1403
+
1404
+ keep_mask = ~cell_types.isin(low_count_types)
1405
+ adata = adata[keep_mask].copy()
1406
+
1407
+ if group_by_column is not None:
1408
+ cell_types = adata.obs[group_by_column].astype(str)
1409
+ else:
1410
+ cell_types = adata.obs[label_column].astype(str)
1411
+
1412
+ if props:
1413
+ dropped = sorted(set(props) & set(low_count_types))
1414
+ if dropped:
1415
+ for ct in dropped:
1416
+ props.pop(ct, None)
1417
+ logger.warning(
1418
+ "Dropping target_proportions for low-count types: %s",
1419
+ ", ".join(dropped),
1420
+ )
1421
+
1422
+ type_counts = cell_types.value_counts()
1423
+
1424
+ unique_types = cell_types.unique()
1392
1425
  target_totals = _resolve_target_totals(
1393
1426
  type_counts=type_counts,
1394
1427
  min_cells_per_type=min_cells_per_type,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatialcore
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Standardized spatial statistics tools for computational biology
5
5
  Author: SpatialCore Contributors
6
6
  License-Expression: Apache-2.0
File without changes
File without changes
File without changes