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() or funki.plots.plot_umap()) by passing the clustering algorithm name to the keyword argument color (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 passed data 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 expression

  • design_factor (str) – Name of the column containing the variables which the contrasting samples are assigned. The column must be present in the data.obs table

  • contrast_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 specified design_factor column

  • ref_var (any | list[any]) – The variable value(s) that defines the refence samples (e.g. 'control'). The value must be present in the specified design_factor column

  • n_cpus (int, optional) – Number of CPUs used for the calculation, defaults to 8

Returns:

None, results are stored inplace of the passed data 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 enrichment

  • net (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() function

  • source (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 passed data object, which is a funki.input.DataSet instance. Estimates, p-values and consensus scores (in case of multiple methods) are stored as part of the obsm 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 the obs 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 instance

  • var_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:

funki.input.DataSet