squidpy.gr.ligrec
- squidpy.gr.ligrec(adata, cluster_key, interactions=None, complex_policy='min', threshold=0.01, corr_method=None, corr_axis='clusters', use_raw=True, copy=False, key_added=None, gene_symbols=None, *, n_perms=1000, rng=None, clusters=None, alpha=0.05, n_jobs=None, show_progress_bar=True, interactions_params=mappingproxy({}), transmitter_params=mappingproxy({'categories': 'ligand'}), receiver_params=mappingproxy({'categories': 'receptor'}), table_key=None)[source]
Perform the permutation test as described in [Efremova et al., 2020].
- Parameters:
adata (
AnnData|SpatialData) – Annotated data object.use_raw (
bool) – Whether to accessanndata.AnnData.raw.table_key (
str|None) – Key inspatialdata.SpatialData.tableswhere the table is stored. Required whenadatais aspatialdata.SpatialDataobject and ignored otherwise.interactions (
DataFrame|Mapping[str,Sequence[str]] |Sequence[str] |tuple[Sequence[str],Sequence[str]] |Sequence[tuple[str,str]] |None) –Interaction to test. The type can be one of:
pandas.DataFrame- must contain at least 2 columns named ‘source’ and ‘target’.dict- dictionary with at least 2 keys named ‘source’ and ‘target’.typing.Sequence- Either a sequence ofstr, in which case all combinations are produced, or a sequence oftupleof 2stror atupleof 2 sequences.
If None, the interactions are extracted from omnipath. Protein complexes can be specified by delimiting the components with ‘_’, such as ‘alpha_beta_gamma’.
complex_policy (
Literal['min','all']) –Policy on how to handle complexes. Valid options are:
’min’ - select gene with the minimum average expression. This is the same as in [Efremova et al., 2020].
’all’ - select all possible combinations between ‘source’ and ‘target’ complexes.
interactions_params (
Mapping[str,Any]) – Keyword arguments foromnipath.interactions.import_intercell_network()defining the interactions. These datasets from [Türei et al., 2016] are used by default: omnipath, pathwayextra, kinaseextra and ligrecextra.transmitter_params (
Mapping[str,Any]) – Keyword arguments foromnipath.interactions.import_intercell_network()defining the transmitter side of intercellular connections.receiver_params (
Mapping[str,Any]) – Keyword arguments foromnipath.interactions.import_intercell_network()defining the receiver side of intercellular connections.cluster_key (
str) – Key inanndata.AnnData.obswhere clustering is stored.clusters (
Sequence[str] |tuple[Sequence[str],Sequence[str]] |Sequence[tuple[str,str]] |None) – Clusters fromanndata.AnnData.obs['{cluster_key}']. Can be specified either as a sequence oftupleor just a sequence of cluster names, in which case all combinations considered.n_perms (
int) – Number of permutations for the permutation test.threshold (
float) – Do not perform permutation test if any of the interacting components is being expressed in less thanthresholdpercent of cells within a given cluster.rng (
int|integer|Sequence[int] |SeedSequence|Generator|BitGenerator|None) – Pseudorandom number generator state, following SPEC 7. When None, a newnumpy.random.Generatoris created using entropy from the operating system. Types other thannumpy.random.Generatorare passed tonumpy.random.default_rng()to instantiate a generator.corr_method (
str|None) – Correction method for multiple testing. Seestatsmodels.stats.multitest.multipletests()for valid options.corr_axis (
Literal['interactions','clusters']) –Axis over which to perform the FDR correction. Only used when
corr_method != None. Valid options are:’interactions’ - correct interactions by performing FDR correction across the clusters.
’clusters’ - correct clusters by performing FDR correction across the interactions.
alpha (
float) – Significance level for FDR correction. Only used whencorr_method != None.copy (
bool) – IfTrue, return the result, otherwise save it to theadataobject.key_added (
str|None) – Key inanndata.AnnData.unswhere the result is stored ifcopy = False. If None,'{cluster_key}_ligrec'will be used.n_jobs (
int|None) – Number of numba threads used for the permutations. Peak memory grows linearly with it. If None, numba’s default thread count (usually all cores) is used; negative values count down from the maximum.show_progress_bar (
bool) – Whether to show the progress bar or not.gene_symbols (
str|None) – Key inanndata.AnnData.varto use instead ofanndata.AnnData.var_names.
- Return type:
- Returns:
If
copy = True, returns adictwith following keys:’means’ -
pandas.DataFramecontaining the mean expression.’pvalues’ -
pandas.DataFramecontaining the possibly corrected p-values.’metadata’ -
pandas.DataFramecontaining interaction metadata.
Otherwise, modifies the
adataobject with the following key:anndata.AnnData.uns['{key_added}']- the above mentioneddict.
NaN p-values mark combinations for which the mean expression of one of the interacting components was 0 or it didn’t pass the
thresholdpercentage of cells being expressed within a given cluster.