AnnData functions¶
Need the anndata extra. See AnnData / scanpy.
umap
¶
umap(
adata: AnnData,
*,
n_components: int = 2,
min_dist: float = 0.5,
spread: float = 1.0,
neighbors_key: str = "neighbors",
key_added: str | None = None,
device: str = "cpu",
seed: int = 42,
verbose: int = 0,
copy: bool = False,
**kwargs: Any,
) -> AnnData | None
UMAP on the sc.pp.neighbors graph, stored the way sc.tl.umap does.
The neighbour graph is taken from obsp rather than searched again, so
n_neighbors and the metric are whatever sc.pp.neighbors used. The
representation (use_rep / n_pcs) is read from the same
uns[neighbors_key]["params"]; it feeds the initialisation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
Annotated data matrix, after |
required |
n_components
|
int
|
Output dimensionality. |
2
|
min_dist
|
float
|
How tightly points may pack. Fits the repulsion curve with
|
0.5
|
spread
|
float
|
Scale of the embedding relative to |
1.0
|
neighbors_key
|
str
|
Where |
'neighbors'
|
key_added
|
str | None
|
Store under |
None
|
device
|
str
|
|
'cpu'
|
seed
|
int
|
Fixes the initialisation and the negative sampling. |
42
|
verbose
|
int
|
|
0
|
copy
|
bool
|
Return a modified copy instead of writing into |
False
|
**kwargs
|
Any
|
Any other constructor argument of the chosen estimator, e.g.
|
{}
|
Returns:
| Type | Description |
|---|---|
AnnData | None
|
The copy if |
AnnData | None
|
and |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
tsne
¶
tsne(
adata: AnnData,
n_pcs: int | None = None,
*,
use_rep: str | None = None,
perplexity: float = 30.0,
approx: str = "barnes_hut",
key_added: str | None = None,
device: str = "cpu",
seed: int = 42,
verbose: int = 0,
copy: bool = False,
**kwargs: Any,
) -> AnnData | None
t-SNE on a representation, stored the way sc.tl.tsne does.
Searches its own 3 * perplexity neighbours; sc.pp.neighbors is not
used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
Annotated data matrix. |
required |
n_pcs
|
int | None
|
Leading columns of the representation to use. |
None
|
use_rep
|
str | None
|
|
None
|
perplexity
|
float
|
Effective neighbourhood size. |
30.0
|
approx
|
str
|
|
'barnes_hut'
|
key_added
|
str | None
|
Store under |
None
|
device
|
str
|
|
'cpu'
|
seed
|
int
|
Fixes the initialisation. |
42
|
verbose
|
int
|
|
0
|
copy
|
bool
|
Return a modified copy instead of writing into |
False
|
**kwargs
|
Any
|
Any other constructor argument of the chosen estimator, e.g.
|
{}
|
Returns:
| Type | Description |
|---|---|
AnnData | None
|
The copy if |
AnnData | None
|
and |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the representation is missing or sparse, or |