Skip to content

Commit 14729c7

Browse files
committed
fix: resolve kaleido/plotly incompatibility and scipy sparse OOM
- Pin kaleido <1.0.0 since kaleido 1.x requires plotly >=6.1.1 while the project uses plotly 5.x - Use two-step sparse matrix indexing in spatial_ldsc to avoid scipy's _get_arrayXarray broadcasting a 51.6 GiB dense intermediate
1 parent e7e6bbe commit 14729c7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"pyranges >=0.0.120, <1.0.0",
3434
"pyfiglet >=0.8",
3535
"plotly >=5.0.0, <6.0.0",
36-
"kaleido >=0.2.0, <2.0.0",
36+
"kaleido >=0.2.0, <1.0.0",
3737
"jinja2 >=3.0.0, <4.0.0",
3838
"scanpy >=1.8.0, <2.0.0",
3939
"zarr >=2.0.0, <3.0.0",

src/gsMap/spatial_ldsc_multiple_sumstats.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ def __init__(self, config: SpatialLDSCConfig, common_snp_among_all_sumstats_pos)
177177
snp_gene_weight_adata = ad.read_h5ad(config.snp_gene_weight_adata_path)
178178
common_genes = mk_score_genes.intersection(snp_gene_weight_adata.var.index)
179179
# common_snps = snp_gene_weight_adata.obs.index
180-
self.snp_gene_weight_matrix = snp_gene_weight_adata[
181-
common_snp_among_all_sumstats_pos, common_genes.to_list()
182-
].X
180+
# Two-step indexing to avoid scipy sparse _get_arrayXarray broadcasting OOM
181+
col_idx = snp_gene_weight_adata.var.index.get_indexer(common_genes)
182+
self.snp_gene_weight_matrix = snp_gene_weight_adata.X[common_snp_among_all_sumstats_pos][
183+
:, col_idx
184+
]
183185
self.mk_score_common = mk_score.loc[common_genes]
184186
self.chunk_starts = list(
185187
range(0, self.mk_score_common.shape[1], self.config.spots_per_chunk_quick_mode)

0 commit comments

Comments
 (0)