pie
pie ¶
pie(
data,
phenotype="phenotype",
groupBy="imageid",
ncols=None,
subsetPhenotype=None,
subsetGroupBy=None,
label="auto",
title="auto",
colors=None,
autopct="%1.1f%%",
legend=False,
legendLoc="upper right",
wedgeprops=None,
fileName="pie.pdf",
outputDir=None,
saveDir=None,
show=True,
returnData=False,
returnFig=False,
dpi=300,
transparent=False,
sdataTable=None,
**kwargs
)
Cell-type proportions as a grid of pie charts.
One pie per category of groupBy, with wedges for each category of
phenotype. The counts behind the plot are a pandas.crosstab of the two
columns, which returnData=True hands back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(AnnData | SpatialData | str, required)
|
The cell table. An |
required |
phenotype
|
str
|
Column in |
'phenotype'
|
groupBy
|
str
|
Column in |
'imageid'
|
ncols
|
int
|
Panels per row. Defaults to |
None
|
subsetPhenotype
|
list
|
Keep only these phenotypes. |
None
|
subsetGroupBy
|
list
|
Keep only these groups. |
None
|
label
|
str
|
|
'auto'
|
title
|
str
|
|
'auto'
|
colors
|
list
|
Explicit wedge colours, in the order the phenotypes appear. |
None
|
autopct
|
str
|
Percentage format string passed to Matplotlib, or |
'%1.1f%%'
|
legend
|
bool
|
Draw a legend on each panel instead of relying on wedge labels. |
False
|
legendLoc
|
str
|
Matplotlib legend location. |
'upper right'
|
wedgeprops
|
dict
|
Passed through to |
None
|
outputDir
|
str
|
Directory to save the figure in. When |
None
|
fileName
|
str
|
File name for the saved figure. The extension decides the format. |
'pie.pdf'
|
saveDir
|
str
|
Deprecated alias for |
None
|
show
|
bool
|
Call |
True
|
returnData
|
bool
|
Return the |
False
|
returnFig
|
bool
|
Return |
False
|
dpi
|
int
|
Resolution of the saved figure. |
300
|
transparent
|
bool
|
Save with a transparent background. |
False
|
sdataTable
|
str
|
Which |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
None | DataFrame | tuple
|
|
Example
# One pie per image.
sp.pl.pie(adata, phenotype="phenotype")
# Donut charts for two cell types across selected samples.
sp.pl.pie(
adata,
phenotype="phenotype",
subsetPhenotype=["Treg", "NK cells"],
subsetGroupBy=["sample_1", "sample_2"],
wedgeprops={"width": 0.4},
outputDir="figures",
show=False,
)