crispyx 0.2.2__tar.gz → 0.2.3__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.
- {crispyx-0.2.2/src/crispyx.egg-info → crispyx-0.2.3}/PKG-INFO +1 -1
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/__init__.py +6 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_irls.py +0 -51
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_kernels.py +416 -198
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_memory.py +0 -21
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_namespaces.py +26 -1
- crispyx-0.2.3/src/crispyx/_size_factors.py +277 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_statistics.py +2 -203
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_version.py +1 -1
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/data.py +12 -114
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/de.py +642 -1751
- crispyx-0.2.3/src/crispyx/glm.py +3012 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/plotting.py +47 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/pseudobulk.py +3 -1
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/qc.py +222 -0
- {crispyx-0.2.2 → crispyx-0.2.3/src/crispyx.egg-info}/PKG-INFO +1 -1
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx.egg-info/SOURCES.txt +2 -1
- crispyx-0.2.3/tests/test_compare_controls.py +83 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_data_helpers.py +0 -26
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_de_lowexpr_filter.py +18 -19
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_glm_structured.py +0 -2
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_irls.py +0 -28
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_nb_glm.py +93 -573
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_normalisation.py +126 -39
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_pseudobulk_profiles.py +13 -0
- crispyx-0.2.3/tests/test_two_group_deseq2.py +402 -0
- crispyx-0.2.2/src/crispyx/_size_factors.py +0 -380
- crispyx-0.2.2/src/crispyx/glm.py +0 -5896
- crispyx-0.2.2/tests/test_streaming_control.py +0 -401
- {crispyx-0.2.2 → crispyx-0.2.3}/LICENSE +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/README.md +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/pyproject.toml +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/setup.cfg +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_checkpoint.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_disk.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_grouping.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_h5codec.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_messages.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_preflight.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/_provenance.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/batch.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/dimred.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/hvg.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/profiling.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/residual.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx/sample.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx.egg-info/dependency_links.txt +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx.egg-info/requires.txt +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/src/crispyx.egg-info/top_level.txt +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_batch_process.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_cgroup_memory_budget.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_compress_h5ad.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_concat_h5ad.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_convert_format.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_de_edge_cases.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_de_resume.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_dimred.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_disk_dispatch.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_downsample_counts.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_groupby_alias.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_hvg.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_in_memory_input.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_memory_dispatch.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_messages.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_normalized_effects.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_normalized_effects_se.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_obs_writes.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_pickle.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_plotting.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_preflight_dispatch.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_profiling.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_pseudobulk_batch.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_pseudobulk_memory.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_qc_parity.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_rank_genes_groups_outputs.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_read_backed.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_residual_effects.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_result_provenance.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_scanpy_parity.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_standardize.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_stream_on_fast_axis.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_subsample.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_temp_file_cleanup.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_wilcoxon_dispatch.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_wilcoxon_labels.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_wilcoxon_stratified.py +0 -0
- {crispyx-0.2.2 → crispyx-0.2.3}/tests/test_workflow.py +0 -0
|
@@ -66,6 +66,7 @@ from .plotting import (
|
|
|
66
66
|
materialize_rank_genes_groups,
|
|
67
67
|
plot_ma,
|
|
68
68
|
plot_overlap_heatmap,
|
|
69
|
+
plot_control_guide_correlation,
|
|
69
70
|
plot_pca,
|
|
70
71
|
plot_pca_loadings,
|
|
71
72
|
plot_pca_variance_ratio,
|
|
@@ -83,6 +84,8 @@ from .pseudobulk import (
|
|
|
83
84
|
compute_pseudobulk_effects,
|
|
84
85
|
)
|
|
85
86
|
from .qc import (
|
|
87
|
+
compare_controls,
|
|
88
|
+
control_guide_correlation,
|
|
86
89
|
filter_cells_by_gene_count,
|
|
87
90
|
filter_genes_by_cell_count,
|
|
88
91
|
filter_perturbations_by_cell_count,
|
|
@@ -123,6 +126,9 @@ __all__ = [
|
|
|
123
126
|
"filter_genes_by_cell_count",
|
|
124
127
|
"filter_perturbations_by_cell_count",
|
|
125
128
|
"quality_control_summary",
|
|
129
|
+
"compare_controls",
|
|
130
|
+
"control_guide_correlation",
|
|
131
|
+
"plot_control_guide_correlation",
|
|
126
132
|
"highly_variable_genes",
|
|
127
133
|
# Subsampling
|
|
128
134
|
"subsample",
|
|
@@ -30,7 +30,6 @@ from __future__ import annotations
|
|
|
30
30
|
from typing import Literal
|
|
31
31
|
|
|
32
32
|
import numpy as np
|
|
33
|
-
from scipy.linalg import cho_factor, cho_solve
|
|
34
33
|
|
|
35
34
|
__all__ = [
|
|
36
35
|
"EPS",
|
|
@@ -43,13 +42,11 @@ __all__ = [
|
|
|
43
42
|
"irls_weights",
|
|
44
43
|
"PIVOT_FLOOR",
|
|
45
44
|
"precondition_columns",
|
|
46
|
-
"sandwich_variances_2x2",
|
|
47
45
|
"schur_complement",
|
|
48
46
|
"schur_solve",
|
|
49
47
|
"schur_variances",
|
|
50
48
|
"solve_spd_2x2",
|
|
51
49
|
"working_response",
|
|
52
|
-
"wls_solve",
|
|
53
50
|
]
|
|
54
51
|
|
|
55
52
|
#: Division guard. Not a modelling floor -- see the module docstring.
|
|
@@ -186,54 +183,6 @@ def solve_spd_2x2(a, b, c, r0, r1):
|
|
|
186
183
|
return (r0 - b * x1) / d0, x1
|
|
187
184
|
|
|
188
185
|
|
|
189
|
-
def sandwich_variances_2x2(m00, m01, m11, ridge):
|
|
190
|
-
"""Sandwich variances ``e_k' H M H e_k`` of a two-column fit's
|
|
191
|
-
coefficients, for Fisher information ``M = [[m00, m01], [m01, m11]]``
|
|
192
|
-
and ``H = (M + ridge I)^-1``, with ``H e_k`` from :func:`solve_spd_2x2`.
|
|
193
|
-
Returns ``(intercept, second column)``.
|
|
194
|
-
"""
|
|
195
|
-
a, c = m00 + ridge, m11 + ridge
|
|
196
|
-
|
|
197
|
-
def quadratic(v0, v1):
|
|
198
|
-
return v0 * v0 * m00 + 2 * v0 * v1 * m01 + v1 * v1 * m11
|
|
199
|
-
|
|
200
|
-
return (quadratic(*solve_spd_2x2(a, m01, c, 1.0, 0.0)),
|
|
201
|
-
quadratic(*solve_spd_2x2(a, m01, c, 0.0, 1.0)))
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def wls_solve(
|
|
205
|
-
x_weighted: np.ndarray, z_weighted: np.ndarray | None = None, ridge: float = 0.0
|
|
206
|
-
) -> tuple[np.ndarray | None, np.ndarray]:
|
|
207
|
-
"""Coefficients and covariance ``(X'WX + ridge I)^-1`` of a weighted
|
|
208
|
-
least-squares fit, from its weighted design ``W^1/2 X`` (and response
|
|
209
|
-
``W^1/2 z``; without one the coefficients are ``None``).
|
|
210
|
-
|
|
211
|
-
A Cholesky factor of the normal matrix when it is positive definite;
|
|
212
|
-
otherwise an SVD of the weighted design, stacked on ``sqrt(ridge) I``,
|
|
213
|
-
gives the minimum-norm solution and the pseudo-inverse with singular
|
|
214
|
-
values below ``matrix_rank``'s tolerance dropped -- without forming a
|
|
215
|
-
normal matrix whose condition number is the design's squared.
|
|
216
|
-
"""
|
|
217
|
-
n_features = x_weighted.shape[1]
|
|
218
|
-
gram = x_weighted.T @ x_weighted
|
|
219
|
-
gram[np.diag_indices(n_features)] += ridge
|
|
220
|
-
try:
|
|
221
|
-
factor = cho_factor(gram, check_finite=False)
|
|
222
|
-
except np.linalg.LinAlgError:
|
|
223
|
-
design, response = x_weighted, z_weighted
|
|
224
|
-
if ridge:
|
|
225
|
-
design = np.vstack([x_weighted, np.sqrt(ridge) * np.eye(n_features)])
|
|
226
|
-
if z_weighted is not None:
|
|
227
|
-
response = np.concatenate([z_weighted, np.zeros(n_features)])
|
|
228
|
-
u, s, vt = np.linalg.svd(design, full_matrices=False)
|
|
229
|
-
keep = s > s.max(initial=0.0) * max(design.shape) * np.finfo(np.float64).eps
|
|
230
|
-
scaled = vt[keep].T / s[keep] # V S^-1
|
|
231
|
-
beta = None if response is None else scaled @ (u[:, keep].T @ response)
|
|
232
|
-
return beta, scaled @ scaled.T
|
|
233
|
-
beta = None if z_weighted is None else cho_solve(factor, x_weighted.T @ z_weighted, check_finite=False)
|
|
234
|
-
return beta, cho_solve(factor, np.eye(n_features), check_finite=False)
|
|
235
|
-
|
|
236
|
-
|
|
237
186
|
def irls_weights(mu: np.ndarray, alpha: np.ndarray | float | None) -> np.ndarray:
|
|
238
187
|
"""Log-link IRLS weights ``mu**2 / V(mu)``.
|
|
239
188
|
|