brisc 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.
- {brisc-0.2.2 → brisc-0.2.3}/PKG-INFO +1 -1
- {brisc-0.2.2 → brisc-0.2.3}/brisc/single_cell.py +103 -95
- {brisc-0.2.2 → brisc-0.2.3}/brisc/threadpoolctl.py +4 -1
- {brisc-0.2.2 → brisc-0.2.3}/brisc.egg-info/PKG-INFO +1 -1
- brisc-0.2.3/brisc.egg-info/scm_version.json +8 -0
- brisc-0.2.2/brisc.egg-info/scm_version.json +0 -8
- {brisc-0.2.2 → brisc-0.2.3}/.git_archival.txt +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/.gitattributes +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/.gitignore +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/LICENSE +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/MANIFEST.in +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/README.md +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/__init__.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/colorspacious.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/concatenate.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/cysparse.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/cyutils.pxd +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/cyutils.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/de.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/doublets.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/embed.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/harmonize.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/hdf5.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/hvg.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/kmeans.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/knn.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/labels.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/leiden.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/loess.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/norm_factors.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/normalize.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/pca.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/pseudobulk.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/pseudobulk_and_markers.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/qc.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/snn.pyx +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/sparse.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/type_aliases.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/utils.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc/validated_dict.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc.egg-info/SOURCES.txt +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc.egg-info/dependency_links.txt +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc.egg-info/requires.txt +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc.egg-info/scm_file_list.json +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/brisc.egg-info/top_level.txt +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/pyproject.toml +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/setup.cfg +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/setup.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/conftest.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/make_test_data.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_cluster.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_de.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_embedding.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_hvg.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_integration.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_markers.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_neighbors.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_normalize.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_pca.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_pseudobulk.py +0 -0
- {brisc-0.2.2 → brisc-0.2.3}/tests/test_qc.py +0 -0
|
@@ -11391,103 +11391,111 @@ class SingleCell:
|
|
|
11391
11391
|
thread_sums = np.empty((num_threads, max(
|
|
11392
11392
|
dataset._X.shape[1] for dataset in datasets), 3),
|
|
11393
11393
|
dtype=np.uint64)
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
num_cells = X.shape[0]
|
|
11394
|
+
with threadpool_limits(
|
|
11395
|
+
1, user_api=None if num_threads == 1 else 'blas'):
|
|
11396
|
+
for X, cell_mask, gene_indices in batches:
|
|
11397
|
+
num_dataset_genes = X.shape[1]
|
|
11398
|
+
mean = np.empty(num_dataset_genes, dtype=np.float32)
|
|
11399
|
+
var = np.empty(num_dataset_genes, dtype=np.float32)
|
|
11400
|
+
nonzero_count = np.empty(num_dataset_genes, dtype=np.uint32)
|
|
11401
|
+
is_csr = isinstance(X, csr_array)
|
|
11402
|
+
if is_csr:
|
|
11403
|
+
# For CSR, `cell_mask` is either `None` (all cells) or a
|
|
11404
|
+
# pre-computed int64 array of cell indices
|
|
11405
|
+
if cell_mask is None:
|
|
11406
|
+
cell_indices = np.array([], dtype=np.int64)
|
|
11407
|
+
num_cells = X.shape[0]
|
|
11408
|
+
else:
|
|
11409
|
+
cell_indices = cell_mask
|
|
11410
|
+
num_cells = len(cell_indices)
|
|
11411
|
+
counts_sum = np.empty(num_dataset_genes, dtype=np.uint64)
|
|
11412
|
+
squared_counts_sum = np.empty(num_dataset_genes,
|
|
11413
|
+
dtype=np.uint64)
|
|
11414
|
+
gene_mean_and_variance_csr(
|
|
11415
|
+
data=X.data, indices=X.indices, indptr=X.indptr,
|
|
11416
|
+
cell_indices=cell_indices, num_cells=num_cells,
|
|
11417
|
+
num_dataset_genes=num_dataset_genes,
|
|
11418
|
+
thread_sums=thread_sums, counts_sum=counts_sum,
|
|
11419
|
+
squared_counts_sum=squared_counts_sum, mean=mean,
|
|
11420
|
+
var=var, nonzero_count=nonzero_count,
|
|
11421
|
+
num_threads=num_threads)
|
|
11423
11422
|
else:
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11423
|
+
if cell_mask is None:
|
|
11424
|
+
cell_mask = np.array([], dtype=bool)
|
|
11425
|
+
num_cells = X.shape[0]
|
|
11426
|
+
else:
|
|
11427
|
+
# The cast to int is necessary for floating-point
|
|
11428
|
+
# identical results: in NumPy ≥ 2.0, a Python int is a
|
|
11429
|
+
# "weak" scalar (int * float32 array -> float32) but a
|
|
11430
|
+
# NumPy integer is "strong" (np.int64 * float32 array
|
|
11431
|
+
# -> float64 since
|
|
11432
|
+
# `np.promote_types(int64, float32) == float64`).
|
|
11433
|
+
num_cells = int(cell_mask.sum())
|
|
11434
|
+
gene_mean_and_variance_csc(
|
|
11435
|
+
data=X.data, indices=X.indices, indptr=X.indptr,
|
|
11436
|
+
cell_mask=cell_mask, num_cells=num_cells,
|
|
11437
|
+
num_dataset_genes=num_dataset_genes, mean=mean,
|
|
11438
|
+
var=var, nonzero_count=nonzero_count,
|
|
11439
|
+
num_threads=num_threads)
|
|
11436
11440
|
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
norm_gene_var
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11441
|
+
not_constant = var > 0
|
|
11442
|
+
y = np.log10(var[not_constant])
|
|
11443
|
+
x = np.log10(mean[not_constant])
|
|
11444
|
+
model = loess(x, y, span=span)
|
|
11445
|
+
try:
|
|
11446
|
+
model.fit()
|
|
11447
|
+
except ValueError as e:
|
|
11448
|
+
error_message = (
|
|
11449
|
+
f'LOESS model fitting failed; this typically happens '
|
|
11450
|
+
f'when there are very few cells (under ~1000), or '
|
|
11451
|
+
f'when batch_column is specified and certain batches '
|
|
11452
|
+
f'have very few cells')
|
|
11453
|
+
if batch_column is not None:
|
|
11454
|
+
error_message += \
|
|
11455
|
+
': consider not specifying batch_column'
|
|
11456
|
+
raise ValueError(error_message) from e
|
|
11457
|
+
|
|
11458
|
+
estimated_variance = np.zeros(num_dataset_genes,
|
|
11459
|
+
dtype=np.float32)
|
|
11460
|
+
estimated_variance[not_constant] = model.outputs.fitted_values
|
|
11461
|
+
estimated_stddev = np.sqrt(10 ** estimated_variance)
|
|
11462
|
+
clip_val = mean + estimated_stddev * np.sqrt(num_cells,
|
|
11463
|
+
dtype=np.float32)
|
|
11464
|
+
batch_counts_sum = np.empty(num_dataset_genes,
|
|
11465
|
+
dtype=np.float32)
|
|
11466
|
+
squared_batch_counts_sum = np.empty(num_dataset_genes,
|
|
11467
|
+
dtype=np.float32)
|
|
11468
|
+
if is_csr:
|
|
11469
|
+
clipped_sum_csr(
|
|
11470
|
+
data=X.data, indices=X.indices, indptr=X.indptr,
|
|
11471
|
+
num_cells=num_cells,
|
|
11472
|
+
num_dataset_genes=num_dataset_genes,
|
|
11473
|
+
cell_indices=cell_indices, clip_val=clip_val,
|
|
11474
|
+
thread_sums=thread_sums, counts_sum=counts_sum,
|
|
11475
|
+
squared_counts_sum=squared_counts_sum,
|
|
11476
|
+
batch_counts_sum=batch_counts_sum,
|
|
11477
|
+
squared_batch_counts_sum=squared_batch_counts_sum,
|
|
11478
|
+
num_threads=num_threads)
|
|
11479
|
+
else:
|
|
11480
|
+
clipped_sum_csc(
|
|
11481
|
+
data=X.data, indices=X.indices, indptr=X.indptr,
|
|
11482
|
+
cell_mask=cell_mask, clip_val=clip_val,
|
|
11483
|
+
batch_counts_sum=batch_counts_sum,
|
|
11484
|
+
squared_batch_counts_sum=squared_batch_counts_sum,
|
|
11485
|
+
num_threads=num_threads)
|
|
11486
|
+
norm_gene_var = pl.Series(
|
|
11487
|
+
(1 / ((num_cells - 1) * np.square(estimated_stddev))) *
|
|
11488
|
+
((num_cells * np.square(mean)) + squared_batch_counts_sum -
|
|
11489
|
+
2 * batch_counts_sum * mean))
|
|
11490
|
+
|
|
11491
|
+
# `norm_gene_var` and `nonzero_count` are with respect to the
|
|
11492
|
+
# genes in `dataset.var_names`; if needed, map them to the
|
|
11493
|
+
# genes in `genes_in_all_datasets`
|
|
11494
|
+
if gene_indices is not None:
|
|
11495
|
+
norm_gene_var = norm_gene_var[gene_indices]
|
|
11496
|
+
nonzero_count = nonzero_count[gene_indices.to_numpy()]
|
|
11497
|
+
norm_gene_vars.append(norm_gene_var)
|
|
11498
|
+
total_nonzero_count += nonzero_count
|
|
11491
11499
|
|
|
11492
11500
|
rank = pl.exclude('gene').rank('min', descending=True)
|
|
11493
11501
|
final_rank = pl.struct(
|
|
@@ -160,7 +160,10 @@ class _FlexiBLAS(_Library):
|
|
|
160
160
|
|
|
161
161
|
class _MKL(_Library):
|
|
162
162
|
name = 'mkl'
|
|
163
|
-
|
|
163
|
+
# Also match MKL's interface layers (e.g. `libmkl_intel_lp64()`), which
|
|
164
|
+
# export the threading functions when MKL is linked without libmkl_rt
|
|
165
|
+
filename_prefixes = \
|
|
166
|
+
'libmkl_rt', 'mkl_rt', 'libmkl_intel_', 'libmkl_gf_', 'libblas'
|
|
164
167
|
check_symbols = 'MKL_Set_Num_Threads',
|
|
165
168
|
|
|
166
169
|
def get(self):
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|