funki.analysis¶
- funki.analysis.clustering(data, alg='leiden', resolution=1.0, neigh_kwargs={}, alg_kwargs={})¶
Computes the clustering of the cells/samples according to the selected algorithm and resolution parameter. You can plot the resulting clustering with your dimensionality reduction approach of choice (
funki.plots.plot_pca()
,funki.plots.plot_tsne()
orfunki.plots.plot_umap()
) by passing the clustering algorithm name to the keyword argumentcolor
(e.g.:plot_tsne(mydata, color='leiden')
)- Parameters:
data (
funki.input.DataSet
) – The data set instance from which to compute the clustering.alg (str, optional) – The algorithm to use for computing the clusters, can be either
'leiden'
or'louvain'
, defaults to'leiden'
resolution (float, optional) – The resolution of the clustering, a higher number generates more and smaller clusters, defaults to
1.0
**neigh_kwargs (dict[str, any], optional) – Other keyword arguments that are passed to scanpy.pp.neighbors() function, defaults to
{}
**alg_kwargs (dict[str, any], optional) – Other keyword arguments that are passed to the clustering algorithm scanpy.tl.louvain() or scanpy.tl.leiden() functions, defaults to
{}
- Returns:
None
, results are stored inplace of the passeddata
object- Return type:
NoneType
- funki.analysis.diff_exp(data, design_factor, contrast_var, ref_var, n_cpus=8)¶
Computes differential expression analysis on the provided data based on a given design factor and both the contrast and reference variables (e.g. treatment and control).
- Parameters:
data (
funki.input.DataSet
) – The data from which to compute the differential expressiondesign_factor (str) – Name of the column containing the variables which the contrasting samples are assigned. The column must be present in the
data.obs
tablecontrast_var (any | list[any]) – The variable value(s) that defines the samples that are to be contrasted against the reference (e.g.
'treatment'
). The value must be present in the specifieddesign_factor
columnref_var (any | list[any]) – The variable value(s) that defines the refence samples (e.g.
'control'
). The value must be present in the specifieddesign_factor
columnn_cpus (int, optional) – Number of CPUs used for the calculation, defaults to
8
- Returns:
None
, results are stored inplace of the passeddata
object- Return type:
NoneType
- funki.analysis.enrich(data, net, methods=None, source=None, target=None, weight=None, **kwargs)¶
Performs enrichment analysis using Decoupler based on a given network (e.g. gene set collection) and statistical method(s).
- Parameters:
data (
funki.input.DataSet
) – The data set from which to perform the enrichmentnet (pandas.DataFrame) – The network linking the features of the data to the attributes (e.g. pathways, gene sets, transcription factors, etc.)
methods (NoneType | str | list[str]) – Which statistical method(s) to use in order to compute the enrichment, defaults to
None
. If none is provided, uses'mlm'
,'ulm'
and'wsum'
. The option'all'
performs all methods. To see all the available methods, you can run decoupler.show_methods() functionsource (str) – Column name from the provided
net
containing the gene sets to enrich for.target (str) – Column name from the provided
net
containing the gene set components (e.g. gene/protein names) that can be mapped back to the data set variable names.weight (NoneType | str) – Defines the column in the network containing the weights to use in the enrichment, defaults to
None
.**kwargs (optional) – Other keyword arguments that passed to decoupler.decouple() function
- Returns:
None
, results are stored inplace of the passeddata
object, which is afunki.input.DataSet
instance. Estimates, p-values and consensus scores (in case of multiple methods) are stored as part of theobsm
attribute of the object.- Return type:
NoneType
- funki.analysis.label_transfer(data, ref_data, transfer_label, **kwargs)¶
Performs label transfer between the provided reference and target data sets.
- Parameters:
data (
funki.input.DataSet
) – The target data set for the labels to be transferred to.ref_data (
funki.input.DataSet
| anndata.AnnData) – The reference data set to transfer the labels from. The labels to transfer must be present in theobs
table.transfer_label (str) – The column from the
obs
table which contains the labels that are to be transferred.**kwargs (optional) – Other keyword arguments that are passed to the label transfer function scanpy.tl.ingest().
- funki.analysis.sc_trans_qc_metrics(data, var_name='mito')¶
Takes a single-cell transcriptomics data set and computes several quality control (QC) metrics according to the provided variable annotation.
- Parameters:
data (
funki.input.DataSet
) – A single-cell transcriptomic data set instancevar_name (str, optional) – The variable over which to compute the QC metrics. This name should exist in
DataSet.var_names
, defaults to'mito'
- Returns:
The resulting filtered data set after applying the specified thresholds
- Return type: