pertpy 0.8.0__py3-none-any.whl → 0.9.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pertpy/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  __author__ = "Lukas Heumos"
4
4
  __email__ = "lukas.heumos@posteo.net"
5
- __version__ = "0.8.0"
5
+ __version__ = "0.9.1"
6
6
 
7
7
  import warnings
8
8
 
@@ -48,7 +48,7 @@ class GuideAssignment:
48
48
  """
49
49
  counts = adata.X if layer is None else adata.layers[layer]
50
50
  if scipy.sparse.issparse(counts):
51
- counts = counts.A
51
+ counts = counts.toarray()
52
52
 
53
53
  assigned_grnas = np.where(counts >= assignment_threshold, 1, 0)
54
54
  assigned_grnas = scipy.sparse.csr_matrix(assigned_grnas)
@@ -92,7 +92,7 @@ class GuideAssignment:
92
92
  """
93
93
  counts = adata.X if layer is None else adata.layers[layer]
94
94
  if scipy.sparse.issparse(counts):
95
- counts = counts.A
95
+ counts = counts.toarray()
96
96
 
97
97
  assigned_grna = np.where(
98
98
  counts.max(axis=1).squeeze() >= assignment_threshold,
@@ -152,9 +152,9 @@ class GuideAssignment:
152
152
 
153
153
  if order_by is None:
154
154
  if scipy.sparse.issparse(data):
155
- max_values = data.max(axis=1).A.squeeze()
155
+ max_values = data.max(axis=1).toarray().squeeze()
156
156
  data_argmax = data.argmax(axis=1).A.squeeze()
157
- max_guide_index = np.where(max_values != data.min(axis=1).A.squeeze(), data_argmax, -1)
157
+ max_guide_index = np.where(max_values != data.min(axis=1).toarray().squeeze(), data_argmax, -1)
158
158
  else:
159
159
  max_guide_index = np.where(
160
160
  data.max(axis=1).squeeze() != data.min(axis=1).squeeze(), data.argmax(axis=1).squeeze(), -1
pertpy/tools/__init__.py CHANGED
@@ -1,16 +1,25 @@
1
+ from importlib import import_module
2
+
3
+
4
+ def lazy_import(module_path, class_name, extras):
5
+ def _import():
6
+ try:
7
+ for extra in extras:
8
+ import_module(extra)
9
+ except ImportError as e:
10
+ raise ImportError(
11
+ f"Extra dependencies required: {', '.join(extras)}. "
12
+ f"Please install with: pip install {' '.join(extras)}"
13
+ ) from e
14
+ module = import_module(module_path)
15
+ return getattr(module, class_name)
16
+
17
+ return _import
18
+
19
+
1
20
  from pertpy.tools._augur import Augur
2
21
  from pertpy.tools._cinemaot import Cinemaot
3
- from pertpy.tools._coda._sccoda import Sccoda
4
- from pertpy.tools._coda._tasccoda import Tasccoda
5
22
  from pertpy.tools._dialogue import Dialogue
6
- from pertpy.tools._differential_gene_expression import (
7
- DGEEVAL,
8
- EdgeR,
9
- PyDESeq2,
10
- Statsmodels,
11
- TTest,
12
- WilcoxonTest,
13
- )
14
23
  from pertpy.tools._distances._distance_tests import DistanceTest
15
24
  from pertpy.tools._distances._distances import Distance
16
25
  from pertpy.tools._enrichment import Enrichment
@@ -30,6 +39,19 @@ from pertpy.tools._perturbation_space._simple import (
30
39
  )
31
40
  from pertpy.tools._scgen import Scgen
32
41
 
42
+ # from pertpy.tools._differential_gene_expression import DGEEVAL
43
+
44
+ CODA_EXTRAS = ["toytree", "arviz", "ete3"] # also pyqt5 technically
45
+ Sccoda = lazy_import("pertpy.tools._coda._sccoda", "Sccoda", CODA_EXTRAS)
46
+ Tasccoda = lazy_import("pertpy.tools._coda._tasccoda", "Tasccoda", CODA_EXTRAS)
47
+
48
+ DE_EXTRAS = ["formulaic", "pydeseq2"]
49
+ EdgeR = lazy_import("pertpy.tools._differential_gene_expression", "EdgeR", DE_EXTRAS + ["edger"])
50
+ PyDESeq2 = lazy_import("pertpy.tools._differential_gene_expression", "PyDESeq2", DE_EXTRAS)
51
+ Statsmodels = lazy_import("pertpy.tools._differential_gene_expression", "Statsmodels", DE_EXTRAS + ["statsmodels"])
52
+ TTest = lazy_import("pertpy.tools._differential_gene_expression", "TTest", DE_EXTRAS)
53
+ WilcoxonTest = lazy_import("pertpy.tools._differential_gene_expression", "WilcoxonTest", DE_EXTRAS)
54
+
33
55
  __all__ = [
34
56
  "Augur",
35
57
  "Cinemaot",
@@ -54,4 +76,5 @@ __all__ = [
54
76
  "KMeansSpace",
55
77
  "PseudobulkSpace",
56
78
  "Scgen",
79
+ "DGEEVAL",
57
80
  ]
pertpy/tools/_milo.py CHANGED
@@ -1014,7 +1014,7 @@ class Milo:
1014
1014
  if subset_nhoods is None:
1015
1015
  subset_nhoods = nhood_adata.obs_names
1016
1016
 
1017
- pl_df = pd.DataFrame(nhood_adata[subset_nhoods].X.A, columns=nhood_adata.var_names).melt(
1017
+ pl_df = pd.DataFrame(nhood_adata[subset_nhoods].X.toarray(), columns=nhood_adata.var_names).melt(
1018
1018
  var_name=nhood_adata.uns["sample_col"], value_name="n_cells"
1019
1019
  )
1020
1020
  pl_df = pd.merge(pl_df, nhood_adata.var)
@@ -408,7 +408,7 @@ class PLDataset(Dataset):
408
408
 
409
409
  def __getitem__(self, idx):
410
410
  """Returns a sample and corresponding perturbations applied (labels)"""
411
- sample = self.data[idx].A.squeeze() if scipy.sparse.issparse(self.data) else self.data[idx]
411
+ sample = self.data[idx].toarray().squeeze() if scipy.sparse.issparse(self.data) else self.data[idx]
412
412
  num_label = self.labels.iloc[idx]
413
413
  str_label = self.pert_labels.iloc[idx]
414
414
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pertpy
3
- Version: 0.8.0
3
+ Version: 0.9.1
4
4
  Summary: Perturbation Analysis in the scverse ecosystem.
5
5
  Project-URL: Documentation, https://pertpy.readthedocs.io
6
6
  Project-URL: Source, https://github.com/scverse/pertpy
@@ -41,6 +41,7 @@ Classifier: Operating System :: POSIX :: Linux
41
41
  Classifier: Programming Language :: Python :: 3
42
42
  Classifier: Programming Language :: Python :: 3.10
43
43
  Classifier: Programming Language :: Python :: 3.11
44
+ Classifier: Programming Language :: Python :: 3.12
44
45
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
45
46
  Classifier: Topic :: Scientific/Engineering :: Visualization
46
47
  Requires-Python: >=3.10
@@ -108,7 +109,7 @@ Description-Content-Type: text/markdown
108
109
 
109
110
  # pertpy
110
111
 
111
- ![fig1](https://github.com/scverse/pertpy/assets/99650244/182fa9c3-6d23-4002-b86a-82bf2a243377)
112
+ ![fig1](https://github.com/user-attachments/assets/d2e32d69-b767-4be3-a938-77a9dce45d3f)
112
113
 
113
114
  ## Documentation
114
115
 
@@ -116,7 +117,10 @@ Please read the [documentation](https://pertpy.readthedocs.io/en/latest).
116
117
 
117
118
  ## Installation
118
119
 
119
- You can install _pertpy_ via [pip] from [PyPI]:
120
+ We recommend installing and running pertpy on a recent version of Linux (e.g. Ubuntu 24.04 LTS).
121
+ No particular hardware beyond a standard laptop is required.
122
+
123
+ You can install _pertpy_ in less than a minute via [pip] from [PyPI]:
120
124
 
121
125
  ```console
122
126
  pip install pertpy
@@ -134,6 +138,11 @@ If you want to use the differential gene expression interface, please install pe
134
138
  pip install pertpy[de]
135
139
  ```
136
140
 
141
+ ## Citation
142
+
143
+ [Lukas Heumos, Yuge Ji, Lilly May, Tessa Green, Xinyue Zhang, Xichen Wu, Johannes Ostner, Stefan Peidli, Antonia Schumacher, Karin Hrovatin, Michaela Mueller, Faye Chong, Gregor Sturm, Alejandro Tejada, Emma Dann, Mingze Dong, Mojtaba Bahrami, Ilan Gold, Sergei Rybakov, Altana Namsaraeva, Amir Ali Moinfar, Zihe Zheng, Eljas Roellin, Isra Mekki, Chris Sander, Mohammad Lotfollahi, Herbert B. Schiller, Fabian J. Theis
144
+ bioRxiv 2024.08.04.606516; doi: https://doi.org/10.1101/2024.08.04.606516](https://www.biorxiv.org/content/10.1101/2024.08.04.606516v1)
145
+
137
146
  [pip]: https://pip.pypa.io/
138
147
  [pypi]: https://pypi.org/
139
148
  [usage]: https://pertpy.readthedocs.io/en/latest/usage/usage.html
@@ -1,4 +1,4 @@
1
- pertpy/__init__.py,sha256=GMFyfRErEysnlkYKMqQxtO7QbqjGki7SpvgtLxIuG6o,658
1
+ pertpy/__init__.py,sha256=OaiANyTVOegBAYDyD4004b7LXIWFpN2HkvQpKLC8P3I,658
2
2
  pertpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  pertpy/data/__init__.py,sha256=ah3yvoxkgbdMUNAWxS3SyqcUuVamBOSeuWkF2QRAEwM,2703
4
4
  pertpy/data/_dataloader.py,sha256=fl16n82nun01gGiP7qhr5sShfcDchp0szzZp7aXkfBI,2495
@@ -12,14 +12,14 @@ pertpy/metadata/_metadata.py,sha256=pvarnv3X5pblnvG8AQ8Omu5jQcC5ORzCxRk3FRhOLgs,
12
12
  pertpy/metadata/_moa.py,sha256=u_OcMonjOeeoW5P9xOltquVSoTH3Vs80ztHsXf-X1DY,4701
13
13
  pertpy/plot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  pertpy/preprocessing/__init__.py,sha256=VAPFaeq2_qCvdFkQTCj_Hm460HC4Tersu8Rig_tnp_Y,71
15
- pertpy/preprocessing/_guide_rna.py,sha256=Xrv0cN16Ub1U1z-3LDNTkm98zs9JOjc2h1N7IAt_FaE,7612
16
- pertpy/tools/__init__.py,sha256=yhDyv5J-nd3SDqc3T08Nzca8dzj3SpoVG2m9VU1rFUk,1481
15
+ pertpy/preprocessing/_guide_rna.py,sha256=IgKhXEyfRwEA7ccKJNLA_aIxKHm09QJINM09KaIwn68,7644
16
+ pertpy/tools/__init__.py,sha256=laoRUOIjnjR4D41miOg6tISC_8pNJsu79785_CxMbSE,2603
17
17
  pertpy/tools/_augur.py,sha256=UWro1nIEZe_rWtjlQCBv4ucqeh3Vt1m8IRzKlux72Z8,55683
18
18
  pertpy/tools/_cinemaot.py,sha256=BD_oYC1TktbFMX7fpp0A57QAF6frLEgNQ_2wFUpxjyo,39509
19
19
  pertpy/tools/_dialogue.py,sha256=f2fbhKWdm4Co79ZzVgtVq9xYwjYWFLdGNDeGFOO_pfM,51990
20
20
  pertpy/tools/_enrichment.py,sha256=rjPHK9YBCJZfpa5Rvfxo3Ii7W5Mvm5dOdolAD7QazVg,21440
21
21
  pertpy/tools/_kernel_pca.py,sha256=_EJ9WlBLjHOafF34sZGdyBgZL6Fj0WiJ1elVT1XMmo4,1579
22
- pertpy/tools/_milo.py,sha256=kGnfx-CMOpYSl85fOW62J2X3utVjOsQFne7ixEptDmI,43691
22
+ pertpy/tools/_milo.py,sha256=FDFGmGMkJiVrvATEnOeAMCe-Q2w7F0nbBMuACVbyIQI,43699
23
23
  pertpy/tools/_mixscape.py,sha256=FtH3PKvbLTe03LPgN4O9sS70oj_6AHz4Mz5otzEwRl8,52406
24
24
  pertpy/tools/decoupler_LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
25
25
  pertpy/tools/transferlearning_MMD_LICENSE,sha256=MUvDA-o_j9htRpI8fStVdCRuyLdPkQUuIH0a_EIc57w,1069
@@ -42,7 +42,7 @@ pertpy/tools/_distances/_distances.py,sha256=iuHpBtWZbJhMZNSEjQkZUu6KPJXCjs_fX6Y
42
42
  pertpy/tools/_perturbation_space/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  pertpy/tools/_perturbation_space/_clustering.py,sha256=m52-J8c8OnIXRCf3NoFabIO2yMHIuy1X0m0amtsK2vE,3556
44
44
  pertpy/tools/_perturbation_space/_comparison.py,sha256=rLO-EGU0I7t5MnLw4k1gYU-ypRu-JsDPLat1t4h2U2M,4329
45
- pertpy/tools/_perturbation_space/_discriminator_classifiers.py,sha256=BNMP-2g4X_9jhs3Vf2rwlIjSCAcADkxBAFYGlsQ5Irw,21609
45
+ pertpy/tools/_perturbation_space/_discriminator_classifiers.py,sha256=OA2eZeG_4iuW1T5ilsRIkS0rU-azmwEch7IuB546KSY,21617
46
46
  pertpy/tools/_perturbation_space/_metrics.py,sha256=y8-baP8WRdB1iDgvP3uuQxSCDxA2lcxvEHHM2C_vWHY,3248
47
47
  pertpy/tools/_perturbation_space/_perturbation_space.py,sha256=cZPPzzK4_UZV7ktcD5BQVXEy6ITHrfkg1CLFov3TzsY,18497
48
48
  pertpy/tools/_perturbation_space/_simple.py,sha256=LH5EYvcAbzFMvgd9bH7AUPKFmdioPiy2xG8xGaXzmq0,12624
@@ -51,7 +51,7 @@ pertpy/tools/_scgen/_base_components.py,sha256=Qq8myRUm43q9XBrZ9gBggfa2cSV2wbz_K
51
51
  pertpy/tools/_scgen/_scgen.py,sha256=HPvFVjY9SS9bGqgTkCDuPYjmA4QHW7rKgHnI2yuI_Q4,30608
52
52
  pertpy/tools/_scgen/_scgenvae.py,sha256=v_6tZ4wY-JjdMH1QVd_wG4_N0PoaqB-FM8zC2JsDu1o,3935
53
53
  pertpy/tools/_scgen/_utils.py,sha256=1upgOt1FpadfvNG05YpMjYYG-IAlxrC3l_ZxczmIczo,2841
54
- pertpy-0.8.0.dist-info/METADATA,sha256=cLAhPubizJ7vgCThHv-kHsAAvepUyRTnTHTKRKX9kYQ,6054
55
- pertpy-0.8.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
56
- pertpy-0.8.0.dist-info/licenses/LICENSE,sha256=OZ-ZkXM5CmExJiEMM90b_7dGNNvRpj7kdE-49AnrLuI,1070
57
- pertpy-0.8.0.dist-info/RECORD,,
54
+ pertpy-0.9.1.dist-info/METADATA,sha256=JrAJR7n35TG8BZ30XmTdsrkaI6ADaz1PQE_DGLHT1TM,6848
55
+ pertpy-0.9.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
56
+ pertpy-0.9.1.dist-info/licenses/LICENSE,sha256=OZ-ZkXM5CmExJiEMM90b_7dGNNvRpj7kdE-49AnrLuI,1070
57
+ pertpy-0.9.1.dist-info/RECORD,,
File without changes