@@ -13,19 +13,19 @@ def celltype_communication(sdata, kind="heatmap", celltype_key="cell type", vmax
1313
1414 Parameters
1515 ----------
16- sdata : SpatialData object
16+ sdata : spatialdata. SpatialData
1717 The spatial data object containing interaction scores.
18- kind : str, optional
18+ kind : str
1919 Type of plot, either 'heatmap' or 'chord'. Default is 'heatmap'.
20- celltype_key : str, optional
20+ celltype_key : str
2121 Key for cell type colors in `sdata['table'].uns`. Default is 'cell type'.
22- vmax : float, optional
22+ vmax : float
2323 Max value for colormap scaling. Default is None.
24- vmin : float, optional
24+ vmin : float
2525 Min value for colormap scaling. Default is None.
26- cmap : str, optional
26+ cmap : str
2727 Colormap for heatmap or chord diagram. Default is 'BuPu'.
28- ** kwargs : dict
28+ kwargs : dict
2929 Additional arguments passed to the plotting functions.
3030 """
3131 interaction_strength = sdata ["source_score" ].uns ["interaction_strength" ]
@@ -63,21 +63,21 @@ def gene_communication(
6363
6464 Parameters
6565 ----------
66- sdata : SpatialData object
66+ sdata : spatialdata. SpatialData
6767 The spatial data object containing interaction scores.
68- kind : str, optional
68+ kind : str
6969 Type of plot, either 'heatmap' or 'chord'. Default is 'heatmap'.
70- celltype_key : str, optional
70+ celltype_key : str
7171 Key for cell type colors in `sdata['table'].uns`. Default is 'cell type'.
72- gene
72+ gene: str
7373 Name of the gene to be plotted
74- vmax : float, optional
74+ vmax : float
7575 Max value for colormap scaling. Default is None.
76- vmin : float, optional
76+ vmin : float
7777 Min value for colormap scaling. Default is None.
78- cmap : str, optional
78+ cmap : str
7979 Colormap for heatmap or chord diagram. Default is 'BuPu'.
80- ** kwargs : dict
80+ kwargs : dict
8181 Additional arguments passed to the plotting functions.
8282 """
8383 gene_interaction_strength = sdata ["source_score" ].uns ["gene_interaction_strength" ]
@@ -124,34 +124,34 @@ def target_score_by_celltype(
124124 title : str | None = "Target Score by Cell Type" ,
125125 cluster_axis : str = "both" ,
126126 cmap : str = "coolwarm" ,
127- figsize : tuple = ( 10 , 8 ) ,
127+ figsize : tuple = None ,
128128) -> None :
129129 """
130130 Plots a heatmap or clustered heatmap of target scores by cell type.
131131
132132 Parameters
133133 ----------
134- sdata : sd .SpatialData
134+ sdata : spatialdata .SpatialData
135135 A SpatialData object containing `target_score` data.
136- gene_key : str, default="feature_name"
136+ gene_key : str
137137 The key in `obs` that contains gene names.
138- min_counts : int, default=100
138+ min_counts : int
139139 Minimum count threshold for genes to be included.
140- min_value : float, optional
140+ min_value : float
141141 Genes presenting the highest target score below this will be filtered out in visualization
142- max_value : float, optional
142+ max_value : float
143143 Genes presenting the highest target score above this will be filtered out in visualization
144- title : str, optional
144+ title : str
145145 Custom title for the plot.
146- cluster_axis : str, default="both"
146+ cluster_axis : str
147147 Determines clustering:
148148 - "none" (no clustering)
149149 - "x" (cluster columns only)
150150 - "y" (cluster rows only)
151151 - "both" (cluster rows and columns)
152- cmap : str, default="coolwarm"
152+ cmap : str
153153 Colormap for the heatmap.
154- figsize : tuple, default=(10, 8)
154+ figsize : tuple
155155 Size of the figure.
156156
157157 Returns
@@ -164,6 +164,8 @@ def target_score_by_celltype(
164164 target_score ["gene" ] = sdata ["target_score" ].obs [gene_key ]
165165 gene_by_celltype_score = target_score .groupby ("gene" ).mean ()
166166
167+ if figsize is None :
168+ figsize = (10 , 8 )
167169 # Filter genes based on count threshold
168170 genes = sdata ["xrna_metadata" ].var .index [sdata ["xrna_metadata" ].var ["count" ] > min_counts ]
169171 filtered_gene_by_celltype_score = gene_by_celltype_score .loc [gene_by_celltype_score .index .isin (genes ), :]
0 commit comments