Plotting
Mixin for convenient plots/visualization of pAnnData object. Typically a wrapper of functions from the scpviz.plotting module.
PlotMixin
Source code in src/scpviz/pAnnData/plot.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | |
plot_abundance
plot_abundance(
ax=None,
namelist=None,
layer="X",
on="protein",
classes=None,
return_df=False,
order=None,
palette=None,
log=True,
facet=None,
height=4,
aspect=0.5,
plot_points=True,
x_label="gene",
kind="auto",
**kwargs: Any
)
Wrapper for scpviz.plotting.plot_abundance.
Plot abundance of proteins or peptides across samples.
This function visualizes expression values for selected proteins or peptides using violin + box + strip plots, or bar plots when the number of replicates per group is small. Supports grouping, faceting, and custom ordering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
Axis to plot on. Ignored if |
None
|
namelist
|
list of str
|
List of accessions or gene names to plot. If None, all available features are considered. |
None
|
layer
|
str
|
Data layer to use for abundance values. Default is |
'X'
|
on
|
str
|
Data level to plot, either |
'protein'
|
classes
|
str or list of str
|
|
None
|
return_df
|
bool
|
If True, returns the DataFrame of replicate and summary values. |
False
|
order
|
dict or list
|
Custom order of classes. For dictionary input,
keys are class names and values are the ordered categories. |
None
|
palette
|
list or dict
|
Color palette mapping groups to colors. |
None
|
log
|
bool
|
If True, apply log2 transformation to abundance values. Default is True. |
True
|
facet
|
str
|
|
None
|
height
|
float
|
Height of each facet plot. Default is 4. |
4
|
aspect
|
float
|
Aspect ratio of each facet plot. Default is 0.5. |
0.5
|
plot_points
|
bool
|
Whether to overlay stripplot of individual samples. |
True
|
x_label
|
str
|
Label for the x-axis, either |
'gene'
|
kind
|
str
|
Type of plot. Options:
|
'auto'
|
**kwargs
|
Any
|
Additional keyword arguments passed to seaborn plotting functions. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
Axes or FacetGrid
|
The axis or facet grid containing the plot. |
df |
(DataFrame, optional)
|
Returned if |
Example
Plot abundance of two selected proteins:
Source code in src/scpviz/pAnnData/plot.py
plot_abundance_boxgrid
plot_abundance_boxgrid(
namelist=None,
ax=None,
layer="X",
on="protein",
classes="Grouping",
return_df=False,
order=None,
plot_type="box",
log_scale=False,
figsize=(2, 2),
palette=None,
y_min=None,
y_max=None,
label_x=True,
show_n=False,
global_legend=True,
box_kwargs=None,
hline_kwargs=None,
bar_kwargs=None,
bar_error="sd",
violin_kwargs=None,
text_kwargs=None,
strip_kwargs=None,
)
Plot abundance values in a one-row panel of boxplots, mean-lines, bars, or violins.
This function generates a clean horizontal panel, with one subplot per gene,
using plot_type to select boxplots (default), mean-lines, bar plots, or
violin plots. If log_scale=True, abundance values are visualized in log10
units (with zero or negative values clipped to 0 before transformation). The
layout is optimized for compact manuscript figure panels and supports custom
global legends, count annotations, and flexible formatting via keyword
dictionaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namelist
|
list of str
|
List of accessions or gene names to plot. If None, all available features are considered. |
None
|
ax
|
Axes
|
Axis to plot on. Generates a new axis if None. |
None
|
layer
|
str
|
Data layer to use for abundance values. Default is |
'X'
|
on
|
str
|
Data level to plot, either |
'protein'
|
classes
|
str or None
|
Column in the returned abundance DataFrame to use for
grouping samples. Defaults to |
'Grouping'
|
return_df
|
bool
|
If True, returns the DataFrame of replicate and summary values. |
False
|
order
|
list of str
|
Ordered list to plot by (class order). If None, uses the order present in the data. |
None
|
plot_type
|
str
|
Type of plot, select from one of |
'box'
|
log_scale
|
bool
|
If True, plot log10-transformed abundances on a linear axis. If False (default), plot raw abundance values on a linear axis. |
False
|
figsize
|
tuple
|
Figure size as (width, height) in inches. |
(2, 2)
|
palette
|
dict or list
|
Color palette for grouping categories.
Defaults to |
None
|
y_min
|
float or None
|
Lower y-axis limit in plotting units. If |
None
|
y_max
|
float or None
|
Upper y-axis limit in plotting units. If |
None
|
label_x
|
bool
|
Whether to display x tick labels inside each subplot. |
True
|
show_n
|
bool
|
Whether to annotate each subplot with sample counts. |
False
|
global_legend
|
bool
|
Whether to display a single global legend. |
True
|
box_kwargs
|
dict
|
Additional arguments passed to |
None
|
hline_kwargs
|
dict
|
Keyword arguments for mean-lines
(used when |
None
|
bar_kwargs
|
dict
|
Additional arguments passed to bar plotting
(used when |
None
|
bar_error
|
str
|
Error bar for bar plot. Select from one of
|
'sd'
|
violin_kwargs
|
dict
|
Additional arguments passed to |
None
|
text_kwargs
|
dict
|
Keyword arguments for count labels (e.g., fontsize, offset). |
None
|
strip_kwargs
|
dict
|
Keyword arguments for strip (raw points),
e.g. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
The generated figure. |
axes |
list of matplotlib.axes.Axes
|
One axis per gene. |
df |
(DataFrame, optional)
|
Returned if |
Note
Default customizations for keyword dictionaries:
Boxplot styling (used when plot_type="box"):
box_kwargs = {
"showcaps": False,
"whiskerprops": {"visible": False},
"showfliers": False,
"boxprops": {"alpha": 0.6, "linewidth": 1},
"linewidth": 1,
"dodge": True,
}
Mean-line styling (used when plot_type="line"):
half_width sets the half-length of the mean line.
Bar styling (used when plot_type="bar"):
bar_kwargs = {
"alpha": 0.8,
"edgecolor": "black",
"linewidth": 0.6,
"width": 0.3,
"capsize": 2,
"zorder": 3,
}
Violin styling (used when plot_type="violin"):
Strip styling (raw points; used for all plot types):
Text annotation styling (used when show_n=True):
Example
Basic usage (grouped boxplots):
fig, axes = pdata.plot_abundance_boxgrid(
namelist=["Gapdh", "Vcp", "Ahnak"],
classes="condition",
plot_type="box",
figsize=(2,2.5),
)
plt.show()
Bar plots with error bars:
fig, axes = pdata.plot_abundance_boxgrid(
namelist=["Gapdh", "Vcp", "Ahnak"],
classes="condition",
plot_type="bar",
bar_error="sd", # "sd", "sem", None, or callable
figsize=(2,2.5),
)
plt.show()
Mean-lines with count annotations:
fig, axes = pdata.plot_abundance_boxgrid(
namelist=["Gapdh", "Vcp", "Ahnak"],
classes="condition",
plot_type="line",
show_n=True,
figsize=(2,2.5),
)
plt.show()
Violin plots (distribution-focused):
fig, axes = pdata.plot_abundance_boxgrid(
namelist=["Gapdh", "Vcp", "Ahnak"],
classes="condition",
plot_type="violin",
figsize=(2,2.5),
)
plt.show()
Customizing appearance (palette, order, and styling):
palette = {"Control": "#4C72B0", "Treatment": "#DD8452"}
fig, axes = pdata.plot_abundance_boxgrid(
namelist=["Gapdh", "Vcp", "Ahnak"],
classes="condition",
order=["Control", "Treatment"],
palette=palette,
plot_type="box",
box_kwargs={"boxprops": {"alpha": 0.45}, "linewidth": 1.2},
strip_kwargs={"size": 4, "alpha": 0.6},
y_min=2,
y_max=10,
log_scale=True,
figsize=(2,2.5),
)
plt.show()
Return the plotting DataFrame for downstream checks:
Source code in src/scpviz/pAnnData/plot.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
plot_pairwise_correlation
plot_pairwise_correlation(
classes: str | list[str],
on: str = "protein",
layer: str = "X",
method: str = "pearson",
order: list | None = None,
show_samples: bool = False,
cmap: str = "RdBu_r",
vmin: float | None = None,
vmax: float | None = None,
annotation_cmap: str | dict | list = "default",
figsize: tuple | None = None,
text_size: int = 9,
colorbar_label: str | None = None,
annot: bool = False,
annot_fmt: str = ".2f",
annot_size: int = 7,
title: str | None = None,
force: bool = False,
subset_mask=None,
show_annotation_legend: bool = True,
legend_anchor_x: float = 0.3,
show_ticklabels: bool | None = None,
ticklabels_auto_max_samples: int = 20,
)
Plot a pairwise proteome correlation heatmap across groups or samples in .obs.
Thin wrapper around :func:scpviz.plotting.plot_pairwise_correlation.
See that function's docstring for full parameter documentation.
Note
The order argument lists group labels when show_samples=False
(including combined strings such as "AS, kd" for multi-column classes),
but lists observation names (.prot.obs_names / .pep.obs_names)
when show_samples=True.
Returns:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
The created figure. |
ax |
Axes
|
The heatmap axes. |
Example
Sample-level heatmap with x-axis sample names forced on:
Source code in src/scpviz/pAnnData/plot.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
plot_pca_gsea_bubble
plot_pca_gsea_bubble(
ax,
on="protein",
key_added="pca_gsea",
pcs=None,
top_n=20,
fdr_cutoff=0.1,
size_scale=120.0,
cmap="coolwarm",
title_case_labels=True,
force=False,
gsea_kwargs=None,
top_n_mode="balanced",
include_pathways=None,
exclude_pathways=None,
return_df=False,
)
Wrapper for scpviz.plotting.plot_pca_gsea_bubble.
Bubble chart of pathways by principal component: color is NES, size reflects FDR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
Target axis. |
required |
on
|
str
|
|
'protein'
|
key_added
|
str
|
|
'pca_gsea'
|
pcs
|
list of int or None
|
PCs to show; |
None
|
top_n
|
int
|
Cap on pathways after ranking; must be >= 1. |
20
|
fdr_cutoff
|
float or None
|
FDR threshold (default |
0.1
|
size_scale
|
float
|
Scales bubble area from |
120.0
|
cmap
|
str or Colormap
|
Colormap for NES. |
'coolwarm'
|
title_case_labels
|
bool
|
Format pathway tick labels. |
True
|
force
|
bool
|
Re-run |
False
|
gsea_kwargs
|
dict or None
|
Forwarded to |
None
|
top_n_mode
|
str
|
|
'balanced'
|
include_pathways
|
str, iterable, or None
|
Restrict to these names. |
None
|
exclude_pathways
|
str, iterable, or None
|
Drop these names. |
None
|
return_df
|
bool
|
If True, return |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Axes | tuple
|
The axis, or |
Source code in src/scpviz/pAnnData/plot.py
plot_pca_gsea_heatmap
plot_pca_gsea_heatmap(
ax,
on="protein",
key_added="pca_gsea",
pcs=None,
top_n=30,
fdr_cutoff=0.1,
cmap="coolwarm",
title_case_labels=True,
force=False,
gsea_kwargs=None,
top_n_mode="balanced",
include_pathways=None,
exclude_pathways=None,
return_df=False,
)
Wrapper for scpviz.plotting.plot_pca_gsea_heatmap.
Heatmap of NES values (pathways × principal components) from PCA-GSEA results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
Target axis. |
required |
on
|
str
|
|
'protein'
|
key_added
|
str
|
|
'pca_gsea'
|
pcs
|
list of int or None
|
PCs as columns; |
None
|
top_n
|
int
|
Cap on pathways after ranking; must be >= 1. |
30
|
fdr_cutoff
|
float or None
|
FDR threshold (default |
0.1
|
cmap
|
str or Colormap
|
Heatmap colormap. |
'coolwarm'
|
title_case_labels
|
bool
|
Format pathway labels on the axis. |
True
|
force
|
bool
|
Re-run |
False
|
gsea_kwargs
|
dict or None
|
Forwarded to |
None
|
top_n_mode
|
str
|
|
'balanced'
|
include_pathways
|
str, iterable, or None
|
Restrict to these names. |
None
|
exclude_pathways
|
str, iterable, or None
|
Drop these names. |
None
|
return_df
|
bool
|
If True, return |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Axes | tuple
|
The axis, or |
Source code in src/scpviz/pAnnData/plot.py
plot_pca_gsea_pathway_vectors
plot_pca_gsea_pathway_vectors(
ax,
on="protein",
key_added="pca_gsea",
plot_pc=[1, 2],
n_vectors=plotting.N_VECTORS_UNSET,
fdr_cutoff=0.1,
arrow_scale=0.25,
pca_kwargs=None,
show_samples=True,
title_case_labels=True,
force=False,
gsea_kwargs=None,
adjust_labels=True,
adjust_text_kwargs=None,
text_positions=None,
lock_text_positions=False,
top_n_mode="balanced",
exclude_pathways=None,
namelist=None,
cmap=None,
xlim=None,
ylim=None,
return_df=False,
)
Overlay PCA-GSEA pathways as arrows in a two-dimensional PCA sample space.
Delegates to scpviz.plotting.plot_pca_gsea_pathway_vectors with pdata=self.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
Target axis (2D). |
required |
on
|
str
|
Data level, |
'protein'
|
key_added
|
str
|
|
'pca_gsea'
|
plot_pc
|
list of int
|
Exactly two 1-based PCs, e.g. |
[1, 2]
|
n_vectors
|
int, sequence, ``None``, or unset
|
Auto top-N on rows not in |
N_VECTORS_UNSET
|
fdr_cutoff
|
float or None
|
FDR threshold for the default ranking path; with |
0.1
|
arrow_scale
|
float
|
Scale factor for arrow length relative to axis span. |
0.25
|
pca_kwargs
|
dict or None
|
Additional arguments passed to |
None
|
show_samples
|
bool
|
If True, plot samples first; if False, draw only axes, grid lines, and arrows. |
True
|
title_case_labels
|
bool
|
If True, format pathway labels for display. |
True
|
force
|
bool
|
If True, re-run |
False
|
gsea_kwargs
|
dict or None
|
Forwarded to |
None
|
adjust_labels
|
bool
|
If True, run |
True
|
adjust_text_kwargs
|
dict or None
|
Extra keyword arguments for |
None
|
text_positions
|
dict or None
|
Optional manual label positions. |
None
|
lock_text_positions
|
bool
|
If True, labels with entries in |
False
|
top_n_mode
|
str
|
|
'balanced'
|
exclude_pathways
|
str, iterable, or None
|
Remove pathways matching these names. |
None
|
namelist
|
list of str or None
|
Pathways to plot first; optional extra top-N from |
None
|
cmap
|
dict or None
|
Per-pathway colors (raw, formatted, then case-insensitive keys). |
None
|
xlim
|
tuple or None
|
X-axis limits applied before arrow scaling (releases fixed aspect first). |
None
|
ylim
|
tuple or None
|
Y-axis limits, same stage as |
None
|
return_df
|
bool
|
If True, also return a DataFrame with NES, FDR, and label positions. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Axes | tuple
|
The axis, or |
Source code in src/scpviz/pAnnData/plot.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
plot_pca_protein_vectors
plot_pca_protein_vectors(
ax,
on="protein",
plot_pc=(1, 2),
gene_col="Genes",
n_vectors=plotting.N_VECTORS_UNSET,
arrow_scale=0.25,
pca_kwargs=None,
show_samples=True,
title_case_labels=False,
adjust_labels=True,
adjust_text_kwargs=None,
text_positions=None,
lock_text_positions=False,
min_abs_loading_for_top_n=None,
top_n_mode="balanced",
exclude_genes=None,
namelist=None,
cmap=None,
xlim=None,
ylim=None,
return_df=False,
)
Overlay protein PCA loadings as arrows in a two-dimensional sample PCA space.
Delegates to scpviz.plotting.plot_pca_protein_vectors with pdata=self. Arrows use feature
loadings from adata.uns['pca']['PCs'] (from pAnnData.pca), not GSEA NES. Geometry matches
plot_pca_gsea_pathway_vectors: each arrow runs from the origin in the direction
(loading_on_PCx, loading_on_PCy), with length rescaled from the current axis limits for visibility.
Labels default to the gene_col column in .var when present, otherwise .var_names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
Target axis (2D). |
required |
on
|
str
|
Data level, |
'protein'
|
plot_pc
|
tuple or list of int
|
Exactly two 1-based PCs. |
(1, 2)
|
gene_col
|
str
|
Column in |
'Genes'
|
n_vectors
|
int, sequence, ``None``, or unset
|
Auto top-N on rows not in |
N_VECTORS_UNSET
|
arrow_scale
|
float
|
Scale factor for arrow length relative to axis span. |
0.25
|
pca_kwargs
|
dict or None
|
Forwarded to |
None
|
show_samples
|
bool
|
If True, draw the sample PCA scatter first; if False, only axes and arrows. |
True
|
title_case_labels
|
bool
|
If True, lightly format gene text (underscores to spaces, title case). |
False
|
adjust_labels
|
bool
|
If True, run |
True
|
adjust_text_kwargs
|
dict or None
|
Extra keyword arguments for |
None
|
text_positions
|
dict or None
|
Manual label positions keyed by gene or formatted label. |
None
|
lock_text_positions
|
bool
|
If True, manual positions are excluded from |
False
|
min_abs_loading_for_top_n
|
float or None
|
If set, ranking scores on a PC are zero when
|
None
|
top_n_mode
|
str
|
|
'balanced'
|
exclude_genes
|
str, iterable, or None
|
Remove genes/features matching these strings (gene label or
|
None
|
namelist
|
list of str or None
|
Gene labels (matrix index, exact |
None
|
cmap
|
dict or None
|
Map gene label (as in matrix or after |
None
|
xlim
|
tuple or None
|
If set, applied with |
None
|
ylim
|
tuple or None
|
If set, |
None
|
return_df
|
bool
|
If True, return |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Axes | tuple
|
The axis, or |
Example
Top-loading genes on PC1 vs PC2 over the sample PCA scatter, returning arrow and text coordinates:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax, vec = pdata.plot_pca_protein_vectors(
ax,
plot_pc=[1, 2],
n_vectors=25,
return_df=True,
)
Split-axis selection: top loadings on PC1 and PC3 separately, then union:
fig, ax = plt.subplots()
pdata.plot_pca_protein_vectors(
ax,
plot_pc=[1, 3],
n_vectors=[5, 3],
adjust_labels=False,
)
Explicit genes with colors and axis limits:
fig, ax = plt.subplots()
pdata.plot_pca_protein_vectors(
ax,
plot_pc=[1, 2],
namelist=["TP53", "EGFR"],
cmap={"TP53": "crimson", "egfr": "steelblue"},
xlim=(-6, 6),
ylim=(-5, 5),
)
Loading arrows only (no sample points) for a compact biplot-style panel:
Source code in src/scpviz/pAnnData/plot.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
plot_rs
Visualize connectivity in the RS (protein × peptide) matrix.
Generates side-by-side histograms:
- Left: Number of peptides mapped to each protein
- Right: Number of proteins associated with each peptide
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
figsize
|
tuple
|
Size of the matplotlib figure (default: (10, 4)). |
(10, 4)
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
None
|
No return value; shows the figure interactively or closes it when using a non-interactive backend. |