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 passeddataobject- Return type:
NoneType
- funki.analysis.diff_exp(data, design_factor, contrast_var, ref_var, method='pydeseq2')¶
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.obstablecontrast_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_factorcolumnref_var (any | list[any]) – The variable value(s) that defines the refence samples (e.g.
'control'). The value must be present in the specifieddesign_factorcolumnmethod (str) – Which method to use for computing the differential expression. Available methods are
'pydeseq2'or'limma', defaults to'pydeseq2'.
- Returns:
None, results are stored inplace of the passeddataobject- Return type:
NoneType
- funki.analysis.enrich(data, net, contrast=None, method=None, source='source', target='target', 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.)
contrast (str) – Which result of the differential expression to use for the enrichment. Must be present in
data.varm_keysnamed with the format'{contrast_var}_vs_{ref_var}'. Defaults toNone.method (NoneType | str) – Which statistical method to use in order to compute the enrichment, defaults to
None. If none is provided, uses'ulm'. To see all the available methods, you can run decoupler.mt.show() function.source (str) – Column name from the provided
netcontaining the gene sets to enrich for. Defaults to'source'.target (str) – Column name from the provided
netcontaining the gene set components (e.g. gene/protein names) that can be mapped back to the data set variable names. Defaults to'target'.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.mt.decouple() function
- Returns:
None, results are stored inplace of the passeddataobject, which is afunki.input.DataSetinstance. Estimates, p-values and consensus scores (in case of multiple methods) are stored as part of theobsmattribute 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 theobstable.transfer_label (str) – The column from the
obstable 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: