scanpy.external.tl.trimap
- scanpy.external.tl.trimap(adata, n_components=2, n_inliers=10, n_outliers=5, n_random=5, metric='euclidean', weight_adj=500.0, lr=1000.0, n_iters=400, verbose=None, copy=False)
TriMap: Large-scale Dimensionality Reduction Using Triplets [Amid19].
TriMap is a dimensionality reduction method that uses triplet constraints to form a low-dimensional embedding of a set of points. The triplet constraints are of the form “point i is closer to point j than point k”. The triplets are sampled from the high-dimensional representation of the points and a weighting scheme is used to reflect the importance of each triplet.
TriMap provides a significantly better global view of the data than the other dimensionality reduction methods such t-SNE, LargeVis, and UMAP. The global structure includes relative distances of the clusters, multiple scales in the data, and the existence of possible outliers. We define a global score to quantify the quality of an embedding in reflecting the global structure of the data.
- Parameters
- adata :
AnnData
AnnData
Annotated data matrix.
- n_components :
int
int
(default:2
) Number of dimensions of the embedding.
- n_inliers :
int
int
(default:10
) Number of inlier points for triplet constraints.
- n_outliers :
int
int
(default:5
) Number of outlier points for triplet constraints.
- n_random :
int
int
(default:5
) Number of random triplet constraints per point.
- metric : {‘angular’, ‘euclidean’, ‘hamming’, ‘manhattan’}
Literal
[‘angular’, ‘euclidean’, ‘hamming’, ‘manhattan’] (default:'euclidean'
) Distance measure: ‘angular’, ‘euclidean’, ‘hamming’, ‘manhattan’.
- weight_adj :
float
float
(default:500.0
) Adjusting the weights using a non-linear transformation.
- lr :
float
float
(default:1000.0
) Learning rate.
- n_iters :
int
int
(default:400
) Number of iterations.
- verbose :
bool
|int
|None
Union
[bool
,int
,None
] (default:None
) If
True
, print the progress report. IfNone
,sc.settings.verbosity
is used.- copy :
bool
bool
(default:False
) Return a copy instead of writing to
adata
.
- adata :
- Return type
- Returns
Depending on
copy
, returns or updatesadata
with the following fields.
Example
>>> import scanpy as sc >>> import scanpy.external as sce >>> pbmc = sc.datasets.pbmc68k_reduced() >>> pbmc = sce.tl.trimap(pbmc, copy=True) >>> sce.pl.trimap(pbmc, color=['bulk_labels'], s=10)