Color Space¶
Color mapping from gene set scores to RGB (pipeline steps 2–3).
Blending (2–3 gene sets)¶
blend_to_rgb
¶
blend_to_rgb(
scores: DataFrame,
*,
colors: list[tuple[float, float, float]] | None = None,
) -> NDArray
Map gene set scores to RGB via multiplicative blending from white.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
DataFrame
|
DataFrame returned by :func: |
required |
colors
|
list[tuple[float, float, float]] | None
|
One |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 or more than 3 gene sets are present, or if the number of supplied colours does not match expectations. |
Source code in src/multiscoresplot/_colorspace.py
Dimensionality Reduction (2+ gene sets)¶
reduce_to_rgb
¶
reduce_to_rgb(
scores: DataFrame,
*,
method: str = "pca",
n_components: int = 3,
**kwargs: object,
) -> NDArray
Map gene set scores to RGB via dimensionality reduction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
DataFrame
|
DataFrame returned by :func: |
required |
method
|
str
|
Reduction method: |
'pca'
|
n_components
|
int
|
Number of components to retain (max 3 for RGB). |
3
|
**kwargs
|
object
|
Extra keyword arguments forwarded to the reducer function. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 gene sets are present or method is unknown. |
Source code in src/multiscoresplot/_colorspace.py
Custom Reducers¶
register_reducer
¶
register_reducer(
name: str,
fn: Callable[..., NDArray],
*,
component_prefix: str | None = None,
) -> None
Register a dimensionality reduction method for use with reduce_to_rgb.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Short identifier (e.g. |
required |
fn
|
Callable[..., NDArray]
|
Callable with signature |
required |
component_prefix
|
str | None
|
Label prefix for legend axes (e.g. |
None
|
Source code in src/multiscoresplot/_colorspace.py
Utility¶
get_component_labels
¶
Return ["<prefix>1", "<prefix>2", "<prefix>3"] for a registered method.