- scanpy.external.pp.scrublet(adata, adata_sim=None, batch_key=None, sim_doublet_ratio=2.0, expected_doublet_rate=0.05, stdev_doublet_rate=0.02, synthetic_doublet_umi_subsampling=1.0, knn_dist_metric='euclidean', normalize_variance=True, log_transform=False, mean_center=True, n_prin_comps=30, use_approx_neighbors=True, get_doublet_neighbor_parents=False, n_neighbors=None, threshold=None, verbose=True, copy=False, random_state=0)#
Predict doublets using Scrublet [Wolock19].
Predict cell doublets using a nearest-neighbor classifier of observed transcriptomes and simulated doublets. Works best if the input is a raw (unnormalized) counts matrix from a single sample or a collection of similar samples from the same experiment. This function is a wrapper around functions that pre-process using Scanpy and directly call functions of Scrublet(). You may also undertake your own preprocessing, simulate doublets with scanpy.external.pp.scrublet_simulate_doublets(), and run the core scrublet function scanpy.external.pp.scrublet.scrublet().
More information and bug reports here.
The annotated data matrix of shape
n_vars. Rows correspond to cells and columns to genes. Expected to be un-normalised where adata_sim is not supplied, in which case doublets will be simulated and pre-processing applied to both objects. If adata_sim is supplied, this should be the observed transcriptomes processed consistently (filtering, transform, normalisaton, hvg) with adata_sim.
(Advanced use case) Optional annData object generated by sc.external.pp.scrublet_simulate_doublets(), with same number of vars as adata. This should have been built from adata_obs after filtering genes and cells and selcting highly-variable genes.
Optional adata.obs column name discriminating between batches.
Number of doublets to simulate relative to the number of observed transcriptomes.
Where adata_sim not suplied, the estimated doublet rate for the experiment.
Where adata_sim not suplied, uncertainty in the expected doublet rate.
Where adata_sim not suplied, rate for sampling UMIs when creating synthetic doublets. If 1.0, each doublet is created by simply adding the UMI counts from two randomly sampled observed transcriptomes. For values less than 1, the UMI counts are added and then randomly sampled at the specified rate.
Distance metric used when finding nearest neighbors. For list of valid values, see the documentation for annoy (if use_approx_neighbors is True) or sklearn.neighbors.NearestNeighbors (if use_approx_neighbors is False).
If True, normalize the data such that each gene has a variance of 1. sklearn.decomposition.TruncatedSVD will be used for dimensionality reduction, unless mean_center is True.
Whether to use :func:
~scanpy.pp.log1pto log-transform the data prior to PCA.
If True, center the data such that each gene has a mean of 0. sklearn.decomposition.PCA will be used for dimensionality reduction.
Number of principal components used to embed the transcriptomes prior to k-nearest-neighbor graph construction.
Use approximate nearest neighbor method (annoy) for the KNN classifier.
If True, return (in .uns) the parent transcriptomes that generated the doublet neighbors of each observed transcriptome. This information can be used to infer the cell states that generated a given doublet state.
Number of neighbors used to construct the KNN graph of observed transcriptomes and simulated doublets. If
None, this is automatically set to
np.round(0.5 * np.sqrt(n_obs)).
Doublet score threshold for calling a transcriptome a doublet. If None, this is set automatically by looking for the minimum between the two modes of the doublet_scores_sim_ histogram. It is best practice to check the threshold visually using the doublet_scores_sim_ histogram and/or based on co-localization of predicted doublets in a 2-D embedding.
If True, print progress updates.
True, return a copy of the input
adatawith Scrublet results added. Otherwise, Scrublet results are added in place.
Initial state for doublet simulation and nearest neighbors.
- Return type:
copy=Trueit returns or else adds fields to
adata. Those fields:
Doublet scores for each observed transcriptome
Boolean indicating predicted doublet status
Doublet scores for each simulated doublet transcriptome
.obs_namesused to generate each simulated doublet transcriptome
Dictionary of Scrublet parameters