rectanglepy 0.1.6__tar.gz → 0.1.7__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 (53) hide show
  1. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.bumpversion.cfg +1 -1
  2. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/CHANGELOG.md +6 -0
  3. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/PKG-INFO +2 -1
  4. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/pyproject.toml +2 -1
  5. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/pp/create_signature.py +6 -2
  6. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/rectangle.py +3 -2
  7. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/test_rectangle.py +10 -1
  8. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.cruft.json +0 -0
  9. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.editorconfig +0 -0
  10. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  11. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  12. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  13. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  14. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/workflows/build.yaml +0 -0
  15. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/workflows/release.yaml +0 -0
  16. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/workflows/release_testpypi.yaml +0 -0
  17. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.github/workflows/test.yaml +0 -0
  18. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.gitignore +0 -0
  19. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.pre-commit-config.yaml +0 -0
  20. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/.readthedocs.yaml +0 -0
  21. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/LICENSE +0 -0
  22. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/README.md +0 -0
  23. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/Makefile +0 -0
  24. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/_static/.gitkeep +0 -0
  25. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/_templates/.gitkeep +0 -0
  26. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/_templates/autosummary/class.rst +0 -0
  27. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/api.md +0 -0
  28. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/changelog.md +0 -0
  29. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/conf.py +0 -0
  30. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/contributing.md +0 -0
  31. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/extensions/typed_returns.py +0 -0
  32. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/index.md +0 -0
  33. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/make.bat +0 -0
  34. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/notebooks/example.ipynb +0 -0
  35. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/references.bib +0 -0
  36. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/docs/references.md +0 -0
  37. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/__init__.py +0 -0
  38. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/data/hao1_annotations_small.zip +0 -0
  39. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/data/hao1_counts_small.zip +0 -0
  40. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/data/small_fino_bulks.zip +0 -0
  41. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/pp/__init__.py +0 -0
  42. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/pp/rectangle_signature.py +0 -0
  43. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/tl/__init__.py +0 -0
  44. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/src/rectanglepy/tl/deconvolution.py +0 -0
  45. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/TIL10_signature.txt +0 -0
  46. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/bulk_small.csv +0 -0
  47. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/cell_annotations_small.txt +0 -0
  48. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/quanTIseq_SimRNAseq_mixture_smaller.csv +0 -0
  49. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/quanTIseq_SimRNAseq_read_fractions_small.txt +0 -0
  50. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/sc_object_small.csv +0 -0
  51. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/data/signature_hao1.csv +0 -0
  52. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/test_pp.py +0 -0
  53. {rectanglepy-0.1.6 → rectanglepy-0.1.7}/tests/test_tl.py +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.1.6
2
+ current_version = 0.1.7
3
3
  tag = True
4
4
  commit = True
5
5
 
@@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning][].
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.1.7] - 2024-07-25
14
+
15
+ ### Fixed
16
+
17
+ - Fixed bug in the consensus method.
18
+
13
19
  ## [0.1.6] - 2024-05-07
14
20
 
15
21
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rectanglepy
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Hierarchical deconvolution of bulk transcriptomics
5
5
  Project-URL: Documentation, https://rectanglepy.readthedocs.io/
6
6
  Project-URL: Source, https://github.com/ComputationalBiomedicineGroup/Rectangle
@@ -31,6 +31,7 @@ License: MIT License
31
31
  License-File: LICENSE
32
32
  Requires-Python: >=3.10
33
33
  Requires-Dist: loguru
34
+ Requires-Dist: numpy<2.0.0,>=1.0.0
34
35
  Requires-Dist: pydeseq2==0.4.1
35
36
  Requires-Dist: quadprog==0.1.11
36
37
  Provides-Extra: dev
@@ -4,7 +4,7 @@ requires = ["hatchling"]
4
4
 
5
5
  [project]
6
6
  name = "rectanglepy"
7
- version = "0.1.6"
7
+ version = "0.1.7"
8
8
  description = "Hierarchical deconvolution of bulk transcriptomics"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -22,6 +22,7 @@ dependencies = [
22
22
  "pydeseq2==0.4.1",
23
23
  "quadprog==0.1.11",
24
24
  "loguru",
25
+ "numpy>=1.0.0,<2.0.0",
25
26
  ]
26
27
 
27
28
  [project.optional-dependencies]
@@ -245,6 +245,7 @@ def build_rectangle_signatures(
245
245
  subsample: bool = False,
246
246
  sample_size: int = 1500,
247
247
  n_cpus: int = None,
248
+ run: int = 0,
248
249
  ) -> RectangleSignatureResult:
249
250
  r"""Builds rectangle signatures based on single-cell count data and annotations.
250
251
 
@@ -272,6 +273,8 @@ def build_rectangle_signatures(
272
273
  The log fold change threshold for the DE analysis (only used if optimize_cutoffs is False).
273
274
  n_cpus
274
275
  The number of cpus to use for the DE analysis. Defaults to the number of cpus available.
276
+ run
277
+ The consensus run number for the analysis. Defaults to 0.
275
278
 
276
279
  Returns
277
280
  -------
@@ -286,7 +289,7 @@ def build_rectangle_signatures(
286
289
 
287
290
  annotations = adata.obs[cell_type_col]
288
291
  if subsample:
289
- annotations = _even(annotations, sample_size)
292
+ annotations = _even(annotations, sample_size, run)
290
293
  adata = adata[annotations.index]
291
294
 
292
295
  if layer is not None:
@@ -448,7 +451,8 @@ def _reduce_to_common_genes(bulks: pd.DataFrame, sc_data: pd.DataFrame):
448
451
  return bulks, sc_data
449
452
 
450
453
 
451
- def _even(annotations: pd.Series, number: int) -> pd.Series:
454
+ def _even(annotations: pd.Series, number: int, run=0) -> pd.Series:
455
+ np.random.seed(run)
452
456
  assert number > 0, "Number of cells must be greater than 0"
453
457
  annotation_counts = annotations.value_counts()
454
458
  selected_cells = []
@@ -94,8 +94,8 @@ def rectangle_consens(
94
94
  rectangle_signature_results = []
95
95
  most_recent_signatures = None
96
96
 
97
- for _i in range(consensus_runs):
98
- logger.info(f"Running consensus run {_i + 1} of {consensus_runs}")
97
+ for i in range(consensus_runs):
98
+ logger.info(f"Running consensus run {i + 1} of {consensus_runs}")
99
99
  signatures = build_rectangle_signatures(
100
100
  adata,
101
101
  cell_type_col,
@@ -108,6 +108,7 @@ def rectangle_consens(
108
108
  n_cpus=n_cpus,
109
109
  subsample=subsample,
110
110
  sample_size=sample_size,
111
+ run=i,
111
112
  )
112
113
  rectangle_signature_results.append(signatures)
113
114
  most_recent_signatures = signatures
@@ -25,12 +25,21 @@ def test_rectangle():
25
25
 
26
26
  def test_rectangle_consensus():
27
27
  sc_data, annotations, bulks = rectanglepy.load_tutorial_data()
28
+ sc_data = sc_data.iloc[:, :500]
28
29
  sc_data_adata = AnnData(sc_data, obs=annotations.to_frame(name="cell_type"))
29
30
 
30
31
  result = rectanglepy.rectangle_consens(
31
- sc_data_adata, bulks, optimize_cutoffs=False, p=0.5, lfc=0.0, consensus_runs=2, sample_size=50
32
+ sc_data_adata, bulks, optimize_cutoffs=False, p=0.5, lfc=0.0, consensus_runs=3, sample_size=50
32
33
  )
33
34
 
34
35
  assert isinstance(result[0], pd.DataFrame)
35
36
  assert isinstance(result[1], RectangleSignatureResult)
36
37
  assert isinstance(result[2], ConsensusResult)
38
+
39
+ # all bias factors should differ, else there is a problem with the random sampling
40
+ consensus_results = result[2]
41
+ signature_results = consensus_results.rectangle_signature_results
42
+ bias_factors = [result.bias_factors for result in signature_results]
43
+ assert bias_factors[0]["Monocytes"] != bias_factors[1]["Monocytes"]
44
+ assert bias_factors[0]["Monocytes"] != bias_factors[2]["Monocytes"]
45
+ assert bias_factors[1]["Monocytes"] != bias_factors[2]["Monocytes"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes