Skip to content

Commit e496501

Browse files
committed
fix return type hints and docstrings to match actual return values
1 parent dc9e576 commit e496501

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

SpatialQuery/spatial_gene_covarying.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from typing import List, Union, Optional, Literal, Dict
2+
from typing import List, Union, Optional, Literal, Dict, Tuple
33

44
import numpy as np
55
import pandas as pd
@@ -586,9 +586,9 @@ def compute_gene_gene_correlation_adata(sq_obj,
586586
min_size: int = 0,
587587
min_nonzero: int = 10,
588588
alpha: Optional[float] = None
589-
) -> pd.DataFrame:
589+
) -> Tuple[pd.DataFrame, dict]:
590590
"""
591-
Compute gene-gene cross correlation between anchor and neighboring motif cells. Only considers inter-cell-type interactions.
591+
Compute gene-gene cross correlation between anchor and neighboring motif cells. Only considers inter-cell-type interactions.
592592
After finding neighbors using the full motif, removes all cells of the center cell type from both neighbor and
593593
non-neighbor groups. For Pearson correlation, uses shifted correlation (subtract cell type mean) to enable
594594
comparison across different niches/motifs.
@@ -1017,7 +1017,7 @@ def compute_gene_gene_correlation_binary(sq_obj,
10171017
min_size: int = 0,
10181018
min_nonzero: int = 10,
10191019
alpha: Optional[float] = None
1020-
) -> pd.DataFrame:
1020+
) -> Tuple[pd.DataFrame, dict]:
10211021
"""
10221022
Compute gene-gene correlation using deviation from global binary mean for binary expression data.
10231023

SpatialQuery/spatial_query.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,8 @@ def plot_gene_pair_heatmap(self,
13481348
title: Optional[str] = None,
13491349
cmap: str = 'GnBu'):
13501350
"""
1351-
Plot a heatmap showing the cross-varying gene pairs.
1352-
1351+
Plot a heatmap showing the cross-varying gene pairs and return cluster assignments.
1352+
13531353
Parameter
13541354
---------
13551355
gene_pair_df:
@@ -1362,10 +1362,14 @@ def plot_gene_pair_heatmap(self,
13621362
Figure title. If None, will use a default title based on center cell type.
13631363
cmap:
13641364
Colormap for the heatmap, default is 'GnBu'
1365-
1365+
13661366
Return
13671367
------
1368-
A figure showing the heatmap of motif cell type distribution.
1368+
pd.DataFrame
1369+
Displays a biclustered heatmap of gene pairs and returns a DataFrame with
1370+
cluster assignments. Columns: gene_center, gene_motif, combined_score,
1371+
cluster_type, cluster_row, cluster_col. If input has 'cell_type' column,
1372+
it will also be included.
13691373
"""
13701374
return plotting.plot_gene_pair_heatmap(gene_pair_df=gene_pair_df, figsize=figsize,
13711375
save_path=save_path)

SpatialQuery/spatial_query_multiple_fov.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,9 +1629,6 @@ def compute_gene_gene_correlation(self,
16291629
DataFrame with correlation results. Columns: gene_center, gene_motif, corr_neighbor,
16301630
corr_non_neighbor, corr_center_no_motif, p_value_test1, p_value_test2,
16311631
delta_corr_test1, delta_corr_test2, combined_score, adj-pval-test1, adj-pval-test2.
1632-
fov_info : dict
1633-
FOV-level information with keys: fov_statistics, total_pairs_neighbor,
1634-
total_pairs_non_neighbor, total_pairs_no_motif, n_fovs_analyzed.
16351632
"""
16361633
if not self.build_gene_index:
16371634
print('Computing covarying genes using expression data ...')

SpatialQuery/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def retrieve_niche_pattern_freq(fp, sp, ct, max_dist):
5757
radius of neighborhood
5858
5959
Return:
60-
AnnData with central cell type and neighboring cells in fp
60+
pd.DataFrame with frequency of each cell type in fp around the central cell type
6161
"""
6262
if ct not in sp.labels.unique():
6363
print(f"{ct} does not exist in FOV.")

0 commit comments

Comments
 (0)