### Run GSEA with toy data Source: https://decoupler.readthedocs.io/en/latest/api/generated/decoupler.mt.gsea.html This example demonstrates how to run the GSEA method using toy data. Ensure you have the decoupler library installed and toy data loaded. ```python import decoupler as dc adata, net = dc.ds.toy() dc.mt.gsea(adata, net, tmin=3) ``` -------------------------------- ### Install Minimal Decoupler from PyPI Source: https://decoupler.readthedocs.io/en/latest/index.html Installs the latest stable release of decoupler with minimal dependencies from the Python Package Index. ```bash pip install decoupler ``` -------------------------------- ### Install Full Decoupler from PyPI Source: https://decoupler.readthedocs.io/en/latest/index.html Installs the latest stable release of decoupler including extra dependencies from the Python Package Index. ```bash pip install decoupler[full] ``` -------------------------------- ### Install Development Version of Decoupler Source: https://decoupler.readthedocs.io/en/latest/index.html Installs the latest development version of decoupler directly from the GitHub repository. ```bash pip install git+https://github.com/scverse/decoupler.git@main ``` -------------------------------- ### Load Packages and Set Up Source: https://decoupler.readthedocs.io/en/latest/notebooks/spatial/rna_visium.html Imports necessary libraries like scanpy and decoupler, and sets up plotting parameters. Ignores future warnings for cleaner output. ```python import warnings import scanpy as sc import decoupler as dc warnings.filterwarnings("ignore", category=FutureWarning) sc.set_figure_params(figsize=(3, 3), frameon=False) ``` -------------------------------- ### Load RNA Data Source: https://decoupler.readthedocs.io/en/latest/_sources/notebooks/bulk/rna.ipynb Example of loading RNA sequencing data using a common bioinformatics library. Ensure the library is installed and data is in the correct format. ```python from rna_tools import load_rna_data rna_data = load_rna_data("path/to/your/rna_data.csv") ``` -------------------------------- ### Run MDT with toy data Source: https://decoupler.readthedocs.io/en/latest/api/generated/decoupler.mt.mdt.html Demonstrates how to load toy data and run the MDT method with a specified minimum number of targets per source. Ensure data is normalized if using raw counts. ```python import decoupler as dc adata, net = dc.ds.toy() dc.mt.mdt(adata, net, tmin=3) ``` -------------------------------- ### Load Toy Dataset Source: https://decoupler.readthedocs.io/en/latest/_sources/notebooks/example.ipynb Loads a small, sample dataset and a corresponding network for demonstration purposes. This dataset is suitable for quick testing and understanding the package's functionality. ```python adata, net = dc.ds.toy() ``` -------------------------------- ### Example Leading Edge Genes Output Source: https://decoupler.readthedocs.io/en/latest/notebooks/scell/rna_psbk.html This is an example output showing the first five leading edge genes for a pathway. ```text leading edge: ['NR4A2' 'JUN' 'SQSTM1' 'JUNB' 'IER5'] ``` -------------------------------- ### toy_bench() Source: https://decoupler.readthedocs.io/en/latest/api/generated/decoupler.ds.toy_bench.html Generates a toy AnnData and network for testing the benchmark pipeline. It accepts optional parameters for shuffling, seeding, and verbosity. ```APIDOC ## toy_bench() ### Description Generate a toy adata and net for testing the benchmark pipeline. ### Parameters #### Arguments - **shuffle_r** (`float`, optional, default=`0.25`) – Percentage of the ground truth to randomize. - **seed** (`int`, optional, default=`42`) – Random seed to use. - **verbose** (`bool`, optional, default=`False`) – Whether to display progress messages and additional execution details. - **kwargs** – All other keyword arguments are passed to `decoupler.ds.toy`. ### Returns AnnData and net examples. ### Example ```python import decoupler as dc adata, net = dc.ds.toy_bench() adata, net ``` ``` -------------------------------- ### Basic RNA Data Loading and Preprocessing Source: https://decoupler.readthedocs.io/en/latest/_sources/notebooks/scell/rna_psbk.ipynb Demonstrates loading an AnnData object and performing basic preprocessing steps like calculating QC metrics and normalizing counts. ```python import scanpy as sc # Load the dataset adata = sc.read_h5ad('adata.h5ad') # Compute quality control metrics adata.obs['percent_mt'] = sc.pp.calculate_qc_metrics(adata, percent_top=None, log1p=False, inplace=True) # Normalize counts per cell sc.pp.normalize_total(adata, target_sum=1e4) # Logarithmize the data sc.pp.log1p(adata) ``` -------------------------------- ### Install Decoupler from Conda-Forge Source: https://decoupler.readthedocs.io/en/latest/index.html Installs the latest stable version of decoupler from the conda-forge channel using mamba or conda. Ensure to use the '-py' suffix. ```bash mamba create -n=dcp conda-forge::decoupler-py ``` -------------------------------- ### Toy Datasets Source: https://decoupler.readthedocs.io/en/latest/_sources/api/ds.md Functions to access toy datasets for testing and examples. ```APIDOC ## ds.toy ### Description Access the toy dataset. ### Method `ds.toy()` ## ds.toy_bench ### Description Access the toy_bench dataset. ### Method `ds.toy_bench()` ``` -------------------------------- ### Run WAGGR with toy data Source: https://decoupler.readthedocs.io/en/latest/api/generated/decoupler.mt.waggr.html This snippet demonstrates how to use the `waggr` function with toy data. It first loads toy data and then applies the `waggr` method with a specified minimum number of targets per source. ```python import decoupler as dc ada, net = dc.ds.toy() dc.mt.waggr(adata, net, tmin=3) ```