NMF (GPU)¶
The CPU twin is bixverse.nmf.
nmf
¶
GPU HALS NMF: one run, stabilised restarts, consensus NMF and the k sweep.
Same inputs and result classes as bixverse.nmf; only the HALS solver runs on
the GPU, which caps the rank at NMF_GPU_MAX_RANK. The consensus step stays on
the CPU.
nmf
¶
nmf(
sc: ScOrMc,
k: int,
*,
cell_ids: Sequence[str] | None = None,
gene_ids: Sequence[str] | None = None,
preprocessing: Preprocessing = "none",
use_second_layer: bool = True,
nmf_hals_params: NmfHalsParams | None = None,
seed: int = 42,
verbose: Verbose = True,
) -> NmfResult
One HALS NMF run on the GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment, a subset or meta cells. |
required |
k
|
int
|
Number of components, at most |
required |
cell_ids
|
Sequence[str] | None
|
Cell (meta cell) ids. |
None
|
gene_ids
|
Sequence[str] | None
|
Gene ids. |
None
|
preprocessing
|
Preprocessing
|
|
'none'
|
use_second_layer
|
bool
|
Factorise the normalised rather than the raw counts. |
True
|
nmf_hals_params
|
NmfHalsParams | None
|
The solver. |
None
|
seed
|
int
|
Seed for a random initialisation. |
42
|
verbose
|
Verbose
|
|
True
|
Returns:
| Type | Description |
|---|---|
NmfResult
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
On |
BixverseError
|
Without a GPU adapter. |
stabilised_nmf
¶
stabilised_nmf(
sc: ScOrMc,
k: int,
*,
cell_ids: Sequence[str] | None = None,
gene_ids: Sequence[str] | None = None,
preprocessing: Preprocessing = "none",
use_second_layer: bool = True,
nmf_hals_params: NmfHalsParams | None = None,
n_runs: int = 30,
seed: int = 42,
verbose: Verbose = True,
) -> StabilisedNmfResult
Randomly initialised HALS NMF restarts on the GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment, a subset or meta cells. |
required |
k
|
int
|
Number of components, at most |
required |
cell_ids
|
Sequence[str] | None
|
Cell (meta cell) ids. |
None
|
gene_ids
|
Sequence[str] | None
|
Gene ids. |
None
|
preprocessing
|
Preprocessing
|
|
'none'
|
use_second_layer
|
bool
|
Factorise the normalised rather than the raw counts. |
True
|
nmf_hals_params
|
NmfHalsParams | None
|
The solver; |
None
|
n_runs
|
int
|
Number of restarts. |
30
|
seed
|
int
|
Base seed of the restarts. |
42
|
verbose
|
Verbose
|
|
True
|
Returns:
| Type | Description |
|---|---|
StabilisedNmfResult
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
On |
BixverseError
|
Without a GPU adapter. |
consensus_nmf
¶
consensus_nmf(
sc: ScOrMc,
k: int,
*,
cell_ids: Sequence[str] | None = None,
gene_ids: Sequence[str] | None = None,
preprocessing: Preprocessing = "none",
use_second_layer: bool = True,
nmf_hals_params: NmfHalsParams | None = None,
nmf_consensus_params: NmfConsensusParams | None = None,
n_runs: int = 30,
seed: int = 42,
verbose: Verbose = True,
) -> ConsensusNmfResult
Consensus HALS NMF (cNMF) with the restarts on the GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment, a subset or meta cells. |
required |
k
|
int
|
Number of components, 2 to |
required |
cell_ids
|
Sequence[str] | None
|
Cell (meta cell) ids. |
None
|
gene_ids
|
Sequence[str] | None
|
Gene ids. |
None
|
preprocessing
|
Preprocessing
|
|
'none'
|
use_second_layer
|
bool
|
Factorise the normalised rather than the raw counts. |
True
|
nmf_hals_params
|
NmfHalsParams | None
|
The solver. |
None
|
nmf_consensus_params
|
NmfConsensusParams | None
|
The consensus step. |
None
|
n_runs
|
int
|
Number of restarts, at least 2. |
30
|
seed
|
int
|
Base seed of the restarts and the consensus k-means. |
42
|
verbose
|
Verbose
|
|
True
|
Returns:
| Type | Description |
|---|---|
ConsensusNmfResult
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
On |
BixverseError
|
Without a GPU adapter. |
References
Kotliar, et al., eLife, 2019.
nmf_k_sweep
¶
nmf_k_sweep(
sc: ScOrMc,
k_range: Sequence[int] | range,
*,
cell_ids: Sequence[str] | None = None,
gene_ids: Sequence[str] | None = None,
preprocessing: Preprocessing = "none",
use_second_layer: bool = True,
nmf_hals_params: NmfHalsParams | None = None,
nmf_consensus_params: NmfConsensusParams | None = None,
n_runs: int = 30,
seed: int = 42,
verbose: Verbose = True,
) -> NmfKSweepResult
Consensus NMF over a range of k with the restarts on the GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment, a subset or meta cells. |
required |
k_range
|
Sequence[int] | range
|
The ranks, unique, 2 to |
required |
cell_ids
|
Sequence[str] | None
|
Cell (meta cell) ids. |
None
|
gene_ids
|
Sequence[str] | None
|
Gene ids. |
None
|
preprocessing
|
Preprocessing
|
|
'none'
|
use_second_layer
|
bool
|
Factorise the normalised rather than the raw counts. |
True
|
nmf_hals_params
|
NmfHalsParams | None
|
The solver. |
None
|
nmf_consensus_params
|
NmfConsensusParams | None
|
The consensus step. |
None
|
n_runs
|
int
|
Restarts per k, at least 2. |
30
|
seed
|
int
|
Base seed of the restarts and the consensus k-means. |
42
|
verbose
|
Verbose
|
|
True
|
Returns:
| Type | Description |
|---|---|
NmfKSweepResult
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
On an invalid |
BixverseError
|
Without a GPU adapter. |
References
Kotliar, et al., eLife, 2019.