densityPlot2D
densityPlot2D ¶
densityPlot2D(
data,
markerA,
markerB=None,
layer=None,
subset=None,
imageId="imageid",
ncols=None,
cmap="jet",
figsize=(3, 3),
hline="auto",
vline="auto",
fontSize=None,
dpi=100,
xticks=None,
yticks=None,
outputDir=None,
fileName="densityPlot2D.pdf",
show=True,
returnData=False,
returnFig=False,
transparent=False,
sdataTable=None,
**kwargs
)
Two-marker density plots, one panel per marker pair.
Pairs are formed by zipping markerA with markerB. Passing a single list to
markerA and leaving markerB as None pairs each marker with the next one,
which is a quick way to sweep a panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(AnnData | SpatialData | str, required)
|
The cell table. An |
required |
markerA
|
(str | list, required)
|
Marker(s) on the x axis. |
required |
markerB
|
str | list
|
Marker(s) on the y axis. When |
None
|
layer
|
str
|
Which matrix to plot. |
None
|
subset
|
str | list
|
Restrict to these values of |
None
|
imageId
|
str
|
Column in |
'imageid'
|
ncols
|
int
|
Panels per row. Defaults to |
None
|
cmap
|
str
|
Matplotlib colormap for the density. |
'jet'
|
figsize
|
tuple
|
Size of a single panel in inches. |
(3, 3)
|
hline
|
float
|
Horizontal reference line. |
'auto'
|
vline
|
float
|
Vertical reference line. |
'auto'
|
fontSize
|
int
|
Axis label font size. |
None
|
xticks
|
list
|
Explicit x tick positions. |
None
|
yticks
|
list
|
Explicit y tick positions. |
None
|
**kwargs
|
dict
|
Passed through to |
{}
|
outputDir
|
str
|
Directory to save the figure in. When |
None
|
fileName
|
str
|
File name for the saved figure. The extension decides the format. |
'densityPlot2D.pdf'
|
show
|
bool
|
Call |
True
|
returnData
|
bool
|
Return the |
False
|
returnFig
|
bool
|
Return |
False
|
dpi
|
int
|
Resolution of the saved figure. |
100
|
transparent
|
bool
|
Save with a transparent background. |
False
|
sdataTable
|
str
|
Which |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
None | DataFrame | tuple
|
|
Example
# One biaxial plot with gate lines at the rescaled boundary.
sp.pl.densityPlot2D(
adata, markerA="CD45", markerB="ECAD", layer="rescaled",
hline=0.5, vline=0.5,
)
# Several pairs at once.
sp.pl.densityPlot2D(
adata,
markerA=["CD45", "CD3", "CD8"],
markerB=["ECAD", "CD4", "FOXP3"],
outputDir="figures",
show=False,
)