Skip to content

Commit f36d314

Browse files
committed
pass args to wrapper functions
1 parent a5470a6 commit f36d314

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

snp2cell/snp2cell_class.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ def add_score(
289289
score_key: str = "score",
290290
propagate: bool = True,
291291
statistics: bool = True,
292+
num_rand: int = 1000,
292293
num_cores: Optional[int] = None,
293294
log: logging.Logger = logging.getLogger(),
294295
) -> None:
@@ -304,7 +305,9 @@ def add_score(
304305
propagate :
305306
whether to propagate the scores
306307
statistics :
307-
whether to calculate statistics
308+
whether to calculate statistics (only if propagate is True)
309+
num_rand :
310+
number of permutations to compute if statistics is True
308311
num_cores :
309312
number of cores to use
310313
log :
@@ -330,9 +333,9 @@ def add_score(
330333
f"overwriting existing score self.scores_prop['{score_key}']"
331334
)
332335
self.scores_prop[score_key] = self.scores_prop.index.map(p_scr_dct) # type: ignore
333-
if statistics:
334-
self.rand_sim(score_key=score_key, num_cores=num_cores)
335-
self.add_score_statistics(score_keys=score_key)
336+
if statistics:
337+
self.rand_sim(score_key=score_key, num_cores=num_cores, n=num_rand)
338+
self.add_score_statistics(score_keys=score_key)
336339
self._defrag_pandas()
337340

338341
def propagate_score(self, score_key: str = "score") -> tuple[str, dict[str, float]]:
@@ -742,6 +745,7 @@ def adata_combine_de_scores(
742745
group_key: str = "celltype",
743746
score_key: str = "score",
744747
suffix: str = "",
748+
scale: bool = False,
745749
statistics: bool = True,
746750
) -> None:
747751
"""
@@ -755,6 +759,8 @@ def adata_combine_de_scores(
755759
score key to combine the DE scores with. E.g. may be a score key for a GWAS based score.
756760
suffix :
757761
suffix to use for combining scores. E.g. may be "__zscore" to combine zscores instead of directly combining the propagated scores.
762+
scale :
763+
whether to scale scores between 0 and 1 before combining
758764
statistics :
759765
whether to calculate statistics based on random perturbation background.
760766
@@ -768,10 +774,10 @@ def adata_combine_de_scores(
768774
combine = [
769775
(f"DE_{grp}__score{suffix}", f"{score_key}{suffix}") for grp in groups
770776
]
771-
self.combine_scores(combine)
777+
self.combine_scores(combine, scale=scale)
772778

773779
if statistics:
774-
self.combine_scores_rand([(f"DE_{group_key}__score", score_key, suffix)])
780+
self.combine_scores_rand([(f"DE_{group_key}__score", score_key, suffix)], scale=scale)
775781

776782
self.add_score_statistics(
777783
score_keys={

0 commit comments

Comments
 (0)