@@ -26,13 +26,23 @@ def fisher_z_test(r1, n1, r2, n2):
2626 Vectorized Fisher Z-test for comparing correlation matrices.
2727 Two-tailed test: H0: r1 = r2, H1: r1 != r2
2828
29- Parameters:
30- r1, r2: correlation matrices (can be 2D arrays)
31- n1, n2: effective sample sizes (scalars)
29+ Parameters
30+ ----------
31+ r1 : array
32+ Correlation matrix for group 1 (can be 2D array).
33+ n1 : int
34+ Effective sample size for group 1.
35+ r2 : array
36+ Correlation matrix for group 2 (can be 2D array).
37+ n2 : int
38+ Effective sample size for group 2.
3239
33- Returns:
34- z_stat: Z statistic matrix
35- p_value: two-tailed p-value matrix
40+ Returns
41+ -------
42+ z_stat : array
43+ Z statistic matrix.
44+ p_value : array
45+ Two-tailed p-value matrix.
3646 """
3747 z1 = fisher_z_transform (r1 )
3848 z2 = fisher_z_transform (r2 )
@@ -594,15 +604,15 @@ def get_anchor_motif_cell_ids(sq_obj,
594604
595605 Parameters
596606 ----------
597- sq_obj :
607+ sq_obj : spatial_query
598608 A spatial_query object.
599609 ct : str
600610 Cell type as the center cells.
601- motif : Union[ str, List[str] ]
611+ motif : str or List[str]
602612 Motif (names of cell types) to be analyzed.
603- max_dist : Optional[ float], default=None
613+ max_dist : float, optional
604614 Maximum distance for considering a cell as a neighbor. Use either max_dist or k.
605- k : Optional[ int], default=None
615+ k : int, optional
606616 Number of nearest neighbors. Use either max_dist or k.
607617 min_size : int, default=0
608618 Minimum neighborhood size for each center cell (only used when max_dist is specified).
@@ -678,28 +688,28 @@ def compute_gene_gene_correlation_adata(sq_obj,
678688 2. Motif cells that are NOT neighbors of center cell type (excluding center type cells)
679689 3. Neighboring cells of center cell type without nearby motif
680690
681- Parameter
682- ---------
683- ct:
691+ Parameters
692+ ----------
693+ ct : str
684694 Cell type as the center cells.
685- motif:
695+ motif : str or List[str]
686696 Motif (names of cell types) to be analyzed. Include all cell types for neighbor finding.
687- genes:
697+ genes : str or List[str], optional
688698 List of genes to analyze. If None, all genes will be used.
689- max_dist:
699+ max_dist : float, optional
690700 Maximum distance for considering a cell as a neighbor. Use either max_dist or k.
691- k:
701+ k : int, optional
692702 Number of nearest neighbors. Use either max_dist or k.
693- min_size:
703+ min_size : int, default=0
694704 Minimum neighborhood size for each center cell (only used when max_dist is specified).
695- min_nonzero:
705+ min_nonzero : int, default=10
696706 Minimum number of non-zero expression values required for a gene to be included.
697- alpha:
698- Significance threshold
707+ alpha : float, optional
708+ Significance threshold.
699709
700- Return
701- ------
702- results_df : DataFrame
710+ Returns
711+ -------
712+ results_df : pd. DataFrame
703713 DataFrame with correlation results between neighbor and non-neighbor groups.
704714 Columns include:
705715 - gene_center, gene_motif: gene pairs
@@ -1128,7 +1138,7 @@ def compute_gene_gene_correlation_binary(sq_obj,
11281138 Minimum neighborhood size for each center cell.
11291139 min_nonzero : int, default=10
11301140 Minimum number of non-zero expression values required for a gene to be included.
1131- alpha:
1141+ alpha : float, optional
11321142 Significance threshold.
11331143
11341144 Returns
@@ -1479,28 +1489,28 @@ def compute_gene_gene_correlation_by_type_adata(sq_obj,
14791489
14801490 Only analyzes motifs with >= 2 cell types besides the center type.
14811491
1482- Parameter
1483- ---------
1484- ct:
1492+ Parameters
1493+ ----------
1494+ ct : str
14851495 Cell type as the center cells.
1486- motif:
1496+ motif : str or List[str]
14871497 Motif (names of cell types) to be analyzed. Include all cell types for neighbor finding.
1488- genes:
1498+ genes : str or List[str], optional
14891499 List of genes to analyze. If None, all genes will be used.
1490- max_dist:
1500+ max_dist : float, optional
14911501 Maximum distance for considering a cell as a neighbor. Use either max_dist or k.
1492- k:
1502+ k : int, optional
14931503 Number of nearest neighbors. Use either max_dist or k.
1494- min_size:
1504+ min_size : int, default=0
14951505 Minimum neighborhood size for each center cell (only used when max_dist is specified).
1496- min_nonzero:
1506+ min_nonzero : int, default=10
14971507 Minimum number of non-zero expression values required for a gene to be included.
1498- alpha:
1499- Significance threshold
1508+ alpha : float, optional
1509+ Significance threshold.
15001510
1501- Return
1502- ------
1503- results_df : DataFrame
1511+ Returns
1512+ -------
1513+ results_df : pd. DataFrame
15041514 DataFrame with correlation results for each cell type and gene pair.
15051515 Columns include:
15061516 - cell_type: the non-center cell type in motif
@@ -1944,7 +1954,7 @@ def compute_gene_gene_correlation_by_type_binary(sq_obj,
19441954 Minimum neighborhood size for each center cell.
19451955 min_nonzero : int, default=10
19461956 Minimum number of non-zero expression values required for a gene to be included.
1947- alpha:
1957+ alpha : float, optional
19481958 Significance threshold.
19491959
19501960 Returns
@@ -2565,29 +2575,29 @@ def compute_gene_gene_correlation_adata_multi_fov(
25652575 2. Motif cells that are NOT neighbors of center cell type (all-to-all across FOVs)
25662576 3. Neighboring cells of center cell type without nearby motif (paired data across FOVs)
25672577
2568- Parameter
2569- ---------
2570- ct:
2578+ Parameters
2579+ ----------
2580+ ct : str
25712581 Cell type as the center cells.
2572- motif:
2582+ motif : str or List[str]
25732583 Motif (names of cell types) to be analyzed.
2574- dataset:
2584+ dataset : str or List[str], optional
25752585 Datasets to include in analysis. If None, use all datasets.
2576- genes:
2586+ genes : str or List[str], optional
25772587 List of genes to analyze. If None, uses intersection of genes across all FOVs.
2578- max_dist:
2588+ max_dist : float, optional
25792589 Maximum distance for considering a cell as a neighbor. Use either max_dist or k.
2580- k:
2590+ k : int, optional
25812591 Number of nearest neighbors. Use either max_dist or k.
2582- min_size:
2592+ min_size : int, default=0
25832593 Minimum neighborhood size for each center cell (only used when max_dist is specified).
2584- min_nonzero:
2594+ min_nonzero : int, default=10
25852595 Minimum number of non-zero expression values required for a gene to be included.
2586- alpha:
2596+ alpha : float, optional
25872597 Significance threshold.
25882598
2589- Return
2590- ------
2599+ Returns
2600+ -------
25912601 results_df : pd.DataFrame
25922602 DataFrame with correlation results between neighbor and non-neighbor groups.
25932603 Columns include:
@@ -2605,7 +2615,7 @@ def compute_gene_gene_correlation_adata_multi_fov(
26052615 # Validate parameters
26062616 if (max_dist is None and k is None ) or (max_dist is not None and k is not None ):
26072617 raise ValueError ("Please specify either max_dist or k, but not both." )
2608-
2618+
26092619 if alpha is None :
26102620 alpha = 0.05
26112621
@@ -3142,29 +3152,29 @@ def compute_gene_gene_correlation_binary_multi_fov(
31423152 2. Motif cells that are NOT neighbors of center cell type (all-to-all across FOVs)
31433153 3. Neighboring cells of center cell type without nearby motif (paired data across FOVs)
31443154
3145- Parameter
3146- ---------
3147- ct:
3155+ Parameters
3156+ ----------
3157+ ct : str
31483158 Cell type as the center cells.
3149- motif:
3159+ motif : str or List[str]
31503160 Motif (names of cell types) to be analyzed.
3151- dataset:
3161+ dataset : str or List[str], optional
31523162 Datasets to include in analysis. If None, use all datasets.
3153- genes:
3163+ genes : str or List[str], optional
31543164 List of genes to analyze. If None, uses intersection of genes across all FOVs.
3155- max_dist:
3165+ max_dist : float, optional
31563166 Maximum distance for considering a cell as a neighbor. Use either max_dist or k.
3157- k:
3167+ k : int, optional
31583168 Number of nearest neighbors. Use either max_dist or k.
3159- min_size:
3169+ min_size : int, default=0
31603170 Minimum neighborhood size for each center cell (only used when max_dist is specified).
3161- min_nonzero:
3171+ min_nonzero : int, default=10
31623172 Minimum number of non-zero expression values required for a gene to be included.
3163- alpha:
3173+ alpha : float, optional
31643174 Significance threshold.
31653175
3166- Return
3167- ------
3176+ Returns
3177+ -------
31683178 results_df : pd.DataFrame
31693179 DataFrame with correlation results between neighbor and non-neighbor groups.
31703180 Columns include:
@@ -3182,7 +3192,7 @@ def compute_gene_gene_correlation_binary_multi_fov(
31823192 # Validate parameters
31833193 if (max_dist is None and k is None ) or (max_dist is not None and k is not None ):
31843194 raise ValueError ("Please specify either max_dist or k, but not both." )
3185-
3195+
31863196 if alpha is None :
31873197 alpha = 0.1
31883198
@@ -3731,7 +3741,7 @@ def compute_gene_gene_correlation_by_type_adata_multi_fov(
37313741 Minimum neighborhood size for each center cell (only used when max_dist is specified).
37323742 min_nonzero : int, default=10
37333743 Minimum number of non-zero expression values required for a gene to be included.
3734- alpha:
3744+ alpha : float, optional
37353745 Significance threshold.
37363746
37373747 Returns
@@ -4350,7 +4360,7 @@ def compute_gene_gene_correlation_by_type_binary_multi_fov(
43504360 Minimum neighborhood size for each center cell (only used when max_dist is specified).
43514361 min_nonzero : int, default=10
43524362 Minimum number of non-zero expression values required for a gene to be included.
4353- alpha:
4363+ alpha : float, optional
43544364 Significance threshold.
43554365
43564366 Returns
0 commit comments