### Install scFates from GitHub Source: https://github.com/louisfaure/scfates/blob/master/docs/installation.md Installation command for the latest development version. ```default pip install git+https://github.com/LouisFaure/scFates ``` -------------------------------- ### Install scFates via PyPI Source: https://github.com/louisfaure/scfates/blob/master/docs/installation.md Standard installation command for the latest stable release. ```default pip install scFates ``` -------------------------------- ### Install scFates with GPU support Source: https://github.com/louisfaure/scfates/blob/master/docs/installation.md Setup for leveraging CUDA computations via the rapids framework. ```default conda create -n scFates-gpu -c rapidsai -c nvidia -c conda-forge -c defaults cuml=21.12 cugraph=21.12 python=3.8 cudatoolkit=11.0 -y conda activate scFates-gpu pip install git+https://github.com/j-bac/elpigraph-python.git pip install scFates ``` -------------------------------- ### Setup GPU Environment Source: https://github.com/louisfaure/scfates/blob/master/README.md Configuration for leveraging NVIDIA GPU acceleration with scFates. ```bash conda create --solver=libmamba -n scFates-gpu -c rapidsai -c conda-forge -c nvidia \ cuml=23.12 cugraph=23.12 python=3.10 cuda-version=11.2 conda activate scFates-gpu pip install git+https://github.com/j-bac/elpigraph-python.git pip install scFates ``` -------------------------------- ### Install scFates with R dependencies Source: https://github.com/louisfaure/scfates/blob/master/docs/installation.md Setup for functions requiring mgcv and rpy2. ```default conda create -n scFates -c conda-forge -c r python=3.11 r-mgcv rpy2 -y conda activate scFates pip install scFates ``` -------------------------------- ### Install scFates Source: https://github.com/louisfaure/scfates/blob/master/README.md Standard installation commands for the package from PyPI or the development version from GitHub. ```bash pip install -U scFates ``` ```bash pip install git+https://github.com/LouisFaure/scFates ``` -------------------------------- ### Install Pixi Source: https://github.com/louisfaure/scfates/blob/master/AGENTS.md Command to install the Pixi package manager if it is not already present on the system. ```bash curl -fsSL https://pixi.sh/install.sh | sh ``` -------------------------------- ### Install CellRank Dependency Source: https://github.com/louisfaure/scfates/blob/master/README.md Required installation for the tl.cellrank_to_tree function. ```bash pip install cellrank ``` -------------------------------- ### Root Selection Strategies Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Examples of different root selection methods for the root() function. ```python root(adata, 0) ``` ```python root(adata, 'CD34') ``` ```python root(adata, 'CytoTRACE') ``` ```python root(adata, 'CD34', min_val=True) ``` -------------------------------- ### Install mgcv on Apple Silicon Source: https://github.com/louisfaure/scfates/blob/master/README.md Workaround for installing mgcv on Apple Silicon to resolve dynamic library issues. ```bash mamba create -n scFates -c conda-forge -c bioconda -c defaults python numpy=1.24.4 "libblas=*=*accelerate" rpy2 -y mamba activate scFates Rscript -e 'install.packages("mgcv",repos = "http://cran.us.r-project.org")' ``` -------------------------------- ### Visualize principal graph with scFates.pl.graph Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-plotting.md Examples demonstrating basic tree visualization, coloring by pseudotime or metadata, customizing appearance, and labeling specific nodes. ```python # Basic tree visualization scFates.pl.graph(adata) # Color cells by pseudotime scFates.pl.graph(adata, color_cells='t') # Customize appearance scFates.pl.graph(adata, basis='umap', size_nodes=50, linewidth=3, color_cells='cell_type', save='tree.pdf') # Show specific nodes scFates.pl.graph(adata, nodes=[0, 5, 10]) ``` -------------------------------- ### Infer principal trees with scFates Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-tree-inference.md Examples demonstrating tree inference using default PPT, ElPiGraph, and GPU-accelerated settings. ```python import scFates import scanpy as sc # Load and preprocess data adata = sc.datasets.pbmc68k_reduced() sc.pp.pca(adata) sc.pp.neighbors(adata) sc.tl.umap(adata) # Infer tree using default PPT method scFates.tl.tree(adata, Nodes=100, use_rep='pca', method='ppt') # Or use ElPiGraph algorithm scFates.tl.tree(adata, Nodes=50, use_rep='pca', method='epg', epg_lambda=0.01, epg_mu=0.1) # With GPU acceleration (if available) scFates.tl.tree(adata, Nodes=500, device='gpu', method='ppt') ``` -------------------------------- ### Usage Examples for test_association Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-statistical-testing.md Examples demonstrating how to run association tests with different parameters and retrieve significant genes. ```python # Test all genes for association with trajectory scFates.tl.test_association(adata) # More stringent threshold scFates.tl.test_association(adata, fdr_cut=1e-5, A_cut=2) # Using multiple cell mappings scFates.tl.test_association(adata, n_map=5, n_jobs=4) # Get significant genes sig_genes = adata.var_names[adata.var.signi] ``` -------------------------------- ### Visualize trajectory and cell metadata Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-plotting.md Examples showing how to plot cells with pseudotime coloring or highlight specific paths using milestones. ```python # Plot cells with tree and pseudotime colors scFates.pl.trajectory(adata, basis='umap', color='t') # Highlight specific path scFates.pl.trajectory(adata, color='cell_type', root_milestone='0', milestones=['3']) ``` -------------------------------- ### Configure R Dependencies Source: https://github.com/louisfaure/scfates/blob/master/README.md Setup for functions requiring the R mgcv package via rpy2, including environment configuration to ensure R is found. ```bash conda create -n scFates -c conda-forge -c r python=3.11 r-mgcv rpy2=3.4.2 -y conda activate scFates pip install scFates ``` ```python import os, sys os.environ['R_HOME'] = sys.exec_prefix+"/lib/R/" import scFates ``` -------------------------------- ### scFates.tl.root() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md Defines the root (starting point) of the inferred trajectory within an AnnData object. ```APIDOC ## scFates.tl.root() ### Description Define the root (starting point) of the inferred trajectory. ### Signature `scFates.tl.root(adata, root, tips_only=False, min_val=False, layer=None, copy=False)` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with a computed tree - **root** (int or str) - Required - Either node index (int) or key for automatic selection (str). If string, can be from adata.obs or adata.var_names - **tips_only** (bool) - Optional - When using automatic selection, restrict to only terminal nodes. Default: False - **min_val** (bool) - Optional - Use minimum value instead of maximum for automatic selection. Default: False - **layer** (str) - Optional - Layer to use when root is a gene name. Default: None - **copy** (bool) - Optional - Return a copy. Default: False ### Returns - **Optional[AnnData]** - Returns the modified AnnData object if copy is True. ### Fields Added to adata - **.uns['graph']['root']** (int) - Index of selected root node - **.uns['graph']['pp_info']** (DataFrame) - For each principal point: distance to root and segment assignment - **.uns['graph']['pp_seg']** (DataFrame) - Segment network information ### Example ```python # Set root manually by node index scFates.tl.root(adata, root=0) # Automatically select root using CytoTRACE values scFates.tl.root(adata, root='CytoTRACE') # Automatically select root using a gene expression scFates.tl.root(adata, root='CD34') # Select root from tips only (terminal nodes) scFates.tl.root(adata, root='CytoTRACE', tips_only=True) ``` ``` -------------------------------- ### Visualize feature trends Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-plotting.md Examples for plotting fitted features along trajectories with various filtering and highlighting options. ```python # Plot fitted features along full trajectory scFates.pl.trends(adata) # Highlight high-amplitude features scFates.pl.trends(adata, highlight_features="A", n_features=15) # Plot specific module scFates.pl.trends(adata, module='0', n_features=20) # Specific branch scFates.pl.trends(adata, root_milestone='0', milestones=['3']) ``` -------------------------------- ### Configure R environment for rpy2 Source: https://github.com/louisfaure/scfates/blob/master/docs/installation.md Import command to ensure rpy2 correctly locates the R installation. ```python import os, sys os.environ['R_HOME'] = sys.exec_prefix+"/lib/R/" import scFates ``` -------------------------------- ### Define Trajectory Root Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md Examples of setting the root node manually via index or automatically using gene expression or cell state metrics. ```python # Set root manually by node index scFates.tl.root(adata, root=0) # Automatically select root using CytoTRACE values scFates.tl.root(adata, root='CytoTRACE') # Automatically select root using a gene expression scFates.tl.root(adata, root='CD34') # Select root from tips only (terminal nodes) scFates.tl.root(adata, root='CytoTRACE', tips_only=True) ``` -------------------------------- ### Identify overdispersed genes with scFates.pp.find_overdispersed Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-preprocessing.md Use these examples to identify highly variable genes using a generalized linear model approach. ```python # Identify overdispersed genes scFates.pp.find_overdispersed(adata, aspect=0.08) # Keep top 2000 genes scFates.pp.find_overdispersed(adata, n_genes=2000) # Filter to overdispersed genes adata = adata[:, adata.var.overdispersed] ``` -------------------------------- ### Filter cells with scFates.pp.filter_cells Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-preprocessing.md Use these examples to remove low-quality cells or flag outliers based on gene-to-molecule relationships. ```python # Filter cells and subset scFates.pp.filter_cells(adata) # Identify outliers without removing scFates.pp.filter_cells(adata, subset=False, plot=True) # More lenient filtering scFates.pp.filter_cells(adata, p_level=1e-2) # GPU acceleration scFates.pp.filter_cells(adata, device='gpu') ``` -------------------------------- ### Build Documentation Source: https://github.com/louisfaure/scfates/blob/master/AGENTS.md Command to build the project documentation using the configured Pixi environment. ```bash pixi run -e docs docs ``` -------------------------------- ### Manage Development Environment Source: https://github.com/louisfaure/scfates/blob/master/README.md Commands for setting up the development environment and running tests using pixi. ```bash pixi install ``` ```bash pixi run test ``` -------------------------------- ### Quick Exploration Workflow Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md A default pipeline for rapid analysis using fewer nodes and lenient parameters. ```python # Fast defaults: fewer nodes, single mapping scFates.tl.tree(adata, Nodes=50, use_rep='pca') scFates.tl.root(adata, root=0) scFates.tl.pseudotime(adata, n_map=1) scFates.tl.test_association(adata, fdr_cut=1e-2) # Lenient scFates.tl.fit(adata) scFates.pl.trends(adata, n_features=5) ``` -------------------------------- ### Subset tree in scFates Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-graph-operations.md Extracts a subtree connecting specified milestones starting from a root node. ```python # Extract subtree from node 0 to nodes 3 and 5 scFates.tl.subset_tree(adata, root_milestone='0', milestones=['3', '5']) ``` -------------------------------- ### scFates.datasets.test_adata() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Loads a small test dataset for quick demonstrations. ```APIDOC ## scFates.datasets.test_adata() ### Description Load a small test dataset for quick demonstrations. ### Signature `def test_adata() -> AnnData` ### Returns - **Type:** `AnnData` - A small single-cell RNA-seq dataset for testing and demonstration purposes. ### Example ```python # Load test data adata = scFates.datasets.test_adata() print(f"Shape: {adata.shape}") ``` ``` -------------------------------- ### Execute minimal workflow Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Standard pipeline for tree inference, pseudotime calculation, and trend visualization. ```python # Tree inference scFates.tl.tree(adata, Nodes=100, use_rep='pca') # Define root and pseudotime scFates.tl.root(adata, root=0) scFates.tl.pseudotime(adata) # Test associations and fit scFates.tl.test_association(adata) scFates.tl.fit(adata) # Visualize scFates.pl.trends(adata) ``` -------------------------------- ### Compute Multi-Path Correlations Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-correlation-clustering.md Compares gene coordination across multiple branches starting from a root milestone. ```python # Compare correlations across both branches from root scFates.tl.synchro_path_multi(adata, root_milestone='0', milestones=['3', '4']) ``` -------------------------------- ### Run Project Tests Source: https://github.com/louisfaure/scfates/blob/master/AGENTS.md Commands to execute the project test suite, with or without coverage reporting. ```bash pixi run test ``` ```bash pixi run test-cov ``` -------------------------------- ### scFates.tl.explore_sigma() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-tree-inference.md Explore optimal sigma values for PPT tree inference by fitting multiple values and comparing reconstruction error. ```APIDOC ## scFates.tl.explore_sigma() ### Description Explore optimal sigma values for PPT tree inference by fitting multiple values and comparing reconstruction error. ### Signature `scFates.tl.explore_sigma(adata, Nodes=None, use_rep=None, ndims_rep=None, sigma_range=[0.05, 0.1, 0.15, 0.2, 0.3], ppt_lambda=1, ppt_metric='euclidean', device='cpu', copy=False, **kwargs)` ### Returns - **Type** (dict) - Dictionary mapping sigma values to reconstruction errors. ### Example ```python sigma_results = scFates.tl.explore_sigma(adata, Nodes=100, use_rep='pca') ``` ``` -------------------------------- ### Enable GPU Acceleration Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Utilize GPU hardware for tree construction and clustering tasks. ```python scFates.tl.tree(adata, device='gpu') scFates.tl.cluster(adata, device='gpu') ``` -------------------------------- ### Set environment variables for threading Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Configure numerical library threading by setting environment variables before importing scFates. ```python import os # Disable threading in numerical libraries os.environ['OPENBLAS_NUM_THREADS'] = '1' os.environ['OMP_NUM_THREADS'] = '1' os.environ['MKL_NUM_THREADS'] = '1' import scFates ``` -------------------------------- ### Import scFates Source: https://github.com/louisfaure/scfates/blob/master/docs/api.md Standard import convention for accessing the scFates library. ```default import scFates as scf ``` -------------------------------- ### tl.pseudotime(n_map=1, n_jobs=1, seed=None) Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Configures parameters for calculating pseudotime, including probabilistic mapping settings. ```APIDOC ## tl.pseudotime() ### Description Calculates pseudotime based on the defined root, with options for probabilistic mapping to handle uncertainty. ### Parameters - **n_map** (int) - Optional - Number of probabilistic cell mappings (Default: 1) - **n_jobs** (int) - Optional - CPU processes for parallel mapping (Default: 1) - **seed** (int) - Optional - Random seed for reproducibility (Default: None) ``` -------------------------------- ### Configure scFates settings Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Adjust global settings for verbosity, logging, and plot file naming conventions. ```python # Set verbosity scFates.settings.verbosity = 2 # Set log file scFates.settings.logfile = "scfates.log" # Configure plot output scFates.settings.plot_prefix = "myanalysis_" scFates.settings.plot_suffix = "_v1" ``` -------------------------------- ### Load test dataset with scFates.datasets.test_adata Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Retrieves a small AnnData object for quick demonstrations and testing. ```python # Load test data adata = scFates.datasets.test_adata() print(f"Shape: {adata.shape}") print(f"Observations: {adata.obs.columns}") print(f"Variables: {adata.var.columns}") ``` -------------------------------- ### Load and Preprocess Data Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Initializes the AnnData object and performs standard quality control, normalization, and scaling using Scanpy. ```python import scanpy as sc import scFates # Load data as AnnData adata = sc.read_h5ad('data.h5ad') # Quality control sc.pp.filter_genes(adata, min_cells=3) sc.pp.filter_cells(adata, min_genes=200) # Normalization and scaling sc.pp.normalize_total(adata) sc.pp.log1p(adata) sc.pp.scale(adata) ``` -------------------------------- ### Infer tree structure with PPT Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Configure the Principal Principal Tree (PPT) method for tree inference. ```python scFates.tl.tree( adata, method='ppt', Nodes=100, ppt_sigma=0.1, # Higher = smoother ppt_lambda=1, # Higher = shorter ppt_metric='euclidean', device='cpu' ) ``` -------------------------------- ### scFates.tl.tree() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-tree-inference.md Infer a principal tree from single-cell data using either the Simple PPT or ElPiGraph algorithm. ```APIDOC ## scFates.tl.tree(adata, ...) ### Description Infer a principal tree from single-cell data using either the Simple PPT or ElPiGraph algorithm. This function modifies the provided AnnData object in-place or returns a copy. ### Parameters - **adata** (AnnData) - Required - Annotated data matrix. - **Nodes** (int) - Optional - Number of nodes composing the principal tree. - **use_rep** (str) - Optional - Name of the representation to use (e.g., 'pca'). - **method** (Literal['ppt', 'epg']) - Optional - Algorithm to use: 'ppt' or 'epg'. - **device** (Literal['cpu', 'gpu']) - Optional - Hardware to run computations on. - **copy** (bool) - Optional - Return a copy instead of modifying adata in-place. ### Returns - **Optional[AnnData]** - Returns modified AnnData object if copy=True, otherwise None. ### Example ```python import scFates import scanpy as sc # Infer tree using default PPT method scFates.tl.tree(adata, Nodes=100, use_rep='pca', method='ppt') # Or use ElPiGraph algorithm scFates.tl.tree(adata, Nodes=50, use_rep='pca', method='epg', epg_lambda=0.01, epg_mu=0.1) ``` ``` -------------------------------- ### scFates.settings.set_figure_pubready() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Configures matplotlib settings to ensure figures are generated in a publication-ready format. ```APIDOC ## scFates.settings.set_figure_pubready() ### Description Configure matplotlib for publication-quality figure output. This sets SVG font types, font families, PDF font types, and tight bounding boxes for saved figures. ### Signature `def set_figure_pubready() -> None` ### Example ```python scFates.set_figure_pubready() ``` ``` -------------------------------- ### Statistical Thresholding Configurations Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Common thresholding configurations for test_association() based on stringency requirements. ```python fdr_cut=1e-5, A_cut=2, st_cut=0.9 ``` ```python fdr_cut=1e-4, A_cut=1, st_cut=0.8 ``` ```python fdr_cut=0.05, A_cut=0.5, st_cut=0.6 ``` -------------------------------- ### Define multi-root trajectory with scFates.tl.roots Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md Sets multiple root nodes and a convergence point for trajectory analysis. ```python # Multi-root trajectory: two roots converging at node 5 scFates.tl.roots(adata, roots=[0, 20], meeting=5) ``` -------------------------------- ### Accessing .obs Columns Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Key observation metadata columns populated after analysis, including pseudotime and structural assignments. ```python .obs['t'] # Pseudotime value .obs['edge'] # Edge assignment (categorical) .obs['seg'] # Segment assignment (categorical) .obs['milestone'] # Milestone type (categorical) .obs['t_sd'] # Pseudotime std dev (if n_map>1) ``` -------------------------------- ### scFates.tl.pseudotime() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md Projects cells onto the tree and computes pseudotime values based on distance from the root. ```APIDOC ## scFates.tl.pseudotime() ### Description Project cells onto the tree and compute pseudotime values based on distance from root. ### Signature `scFates.tl.pseudotime(adata: AnnData, n_jobs: int = 1, n_map: int = 1, seed: Optional[int] = None, copy: bool = False) -> Optional[AnnData]` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with tree and root defined - **n_jobs** (int) - Optional - Number of CPU processes for parallel mapping (Default: 1) - **n_map** (int) - Optional - Number of probabilistic mappings (Default: 1) - **seed** (int) - Optional - Random seed for reproducible results - **copy** (bool) - Optional - Return a copy (Default: False) ### Returns - **Type** (Optional[AnnData]) ### Fields Added to adata - **.obs['t']** (float) - Pseudotime value for each cell - **.obs['edge']** (categorical) - Edge assigned to each cell - **.obs['seg']** (categorical) - Segment assigned to each cell - **.obs['milestone']** (categorical) - Milestone region - **.obs['t_sd']** (float) - Standard deviation of pseudotime - **.uns['pseudotime_list']** (dict) - Mapping results ### Example ```python scFates.tl.pseudotime(adata, n_map=10, n_jobs=4, seed=42) ``` ``` -------------------------------- ### scFates.datasets.morarach20() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Loads the neural crest developmental dataset (Morarach et al., 2020). ```APIDOC ## scFates.datasets.morarach20() ### Description Load neural crest developmental dataset (Morarach et al., 2020). ### Signature `def morarach20() -> AnnData` ### Returns - **Type:** `AnnData` - A large dataset of neural crest cell differentiation. ### Example ```python # Load neural crest dataset adata = scFates.datasets.morarach20() ``` ``` -------------------------------- ### Compute pseudotime with scFates.tl.pseudotime Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md Projects cells onto the tree to calculate pseudotime values. Supports both deterministic likelihood mapping and probabilistic mapping. ```python # Single mapping with likelihood assignment scFates.tl.pseudotime(adata) # Multiple probabilistic mappings scFates.tl.pseudotime(adata, n_map=10, n_jobs=4, seed=42) # Access pseudotime values pseudotime_values = adata.obs['t'].values ``` -------------------------------- ### Load neural crest dataset with scFates.datasets.morarach20 Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Retrieves the Morarach et al. (2020) neural crest developmental dataset. ```python # Load neural crest dataset adata = scFates.datasets.morarach20() ``` -------------------------------- ### Explore optimal sigma values for tree inference Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-tree-inference.md Fits multiple sigma values to compare reconstruction errors, helping to identify the optimal parameter for PPT tree inference. ```python def explore_sigma( adata: AnnData, Nodes: int = None, use_rep: str = None, ndims_rep: Optional[int] = None, sigma_range: list = [0.05, 0.1, 0.15, 0.2, 0.3], ppt_lambda: Optional[Union[float, int]] = 1, ppt_metric: str = "euclidean", device: Literal["cpu", "gpu"] = "cpu", copy: bool = False, **kwargs ) -> dict ``` ```python # Find optimal sigma sigma_results = scFates.tl.explore_sigma(adata, Nodes=100, use_rep='pca') ``` -------------------------------- ### Infer Principal Tree Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Constructs the trajectory graph using either PPT or ElPiGraph algorithms and visualizes the result. ```python # Infer tree (default: PPT with ~n_obs/2 nodes) scFates.tl.tree(adata, Nodes=100, use_rep='pca') # Or: ElPiGraph algorithm scFates.tl.tree(adata, Nodes=50, use_rep='pca', method='epg') # Visualization scFates.pl.graph(adata, basis='umap') ``` -------------------------------- ### Configure publication-ready figures Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Sets matplotlib parameters for publication-quality output, including font settings and tight bounding boxes. ```python # Set publication-ready figure styling scFates.set_figure_pubready() # Now all saved figures will use these settings scFates.pl.graph(adata, save='tree.pdf') ``` -------------------------------- ### Fit function signature Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-statistical-testing.md Function signature for scFates.tl.fit. ```python def fit( adata: AnnData, features: Optional[Iterable] = None, layer: Optional[str] = None, n_map: int = 1, n_jobs: int = 1, gamma: float = 1.5, knots: int = -1, save_raw: bool = True, copy: bool = False ) -> Optional[AnnData] ``` -------------------------------- ### scFates.datasets.neucrest19() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Loads the neural crest dataset (Soldatov et al., 2019). ```APIDOC ## scFates.datasets.neucrest19() ### Description Load neural crest dataset (Soldatov et al., 2019). ### Signature `def neucrest19() -> AnnData` ### Returns - **Type:** `AnnData` - Neural crest developmental trajectory dataset. ``` -------------------------------- ### scFates.tl.synchro_path_multi() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-correlation-clustering.md Compute correlations across multiple paths for comparison of gene coordination. ```APIDOC ## scFates.tl.synchro_path_multi() ### Description Compute correlations across multiple paths for comparison of gene coordination. ### Signature `def synchro_path_multi(adata: AnnData, root_milestone: str, milestones: list, features: Union[None, str] = None, layer: Optional[str] = None, copy: bool = False) -> Optional[AnnData]` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix - **root_milestone** (str) - Required - Starting milestone - **milestones** (list) - Required - Ending milestones to compare - **features** (str or None) - Optional - Features to correlate - **layer** (str) - Optional - Expression layer to use - **copy** (bool) - Optional - Return a copy ### Returns - **Optional[AnnData]** - Returns an AnnData object with multi-path correlation results ### Example ```python scFates.tl.synchro_path_multi(adata, root_milestone='0', milestones=['3', '4']) ``` ``` -------------------------------- ### scFates.tl.simplify() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-graph-operations.md Reduces the number of nodes in the tree by merging nearby nodes to reach a target node count. ```APIDOC ## scFates.tl.simplify(adata, n_nodes=10, copy=False) ### Description Reduce the number of nodes in the tree by merging nearby nodes. ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with tree - **n_nodes** (int) - Optional (Default: 10) - Target number of nodes (approximately) - **copy** (bool) - Optional (Default: False) - Return a copy ### Returns - **Optional[AnnData]** ### Example ```python # Reduce tree from ~100 nodes to ~10 scFates.tl.simplify(adata, n_nodes=10) ``` ``` -------------------------------- ### tl.fit(gamma=1.5, knots=-1, n_map=1, n_jobs=1, save_raw=True) Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Configures spline fitting parameters for trajectory modeling. ```APIDOC ## tl.fit() ### Description Fits splines to the trajectory data to model gene expression trends. ### Parameters - **gamma** (float) - Optional - Smoothing penalty (Default: 1.5) - **knots** (int) - Optional - Number of spline knots (Default: -1) - **n_map** (int) - Optional - Number of cell mappings to average (Default: 1) - **n_jobs** (int) - Optional - CPU processes (Default: 1) - **save_raw** (bool) - Optional - Save unfiltered data in .raw (Default: True) ``` -------------------------------- ### Accessing .var Columns Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Key variable metadata columns populated after test_association, containing statistical results and module assignments. ```python .var['p_val'] # Raw p-value .var['fdr'] # Adjusted p-value .var['A'] # Amplitude of change .var['st'] # Stability across mappings .var['signi'] # Significant? (boolean) .var['clusters'] # Module assignment (if clustered) ``` -------------------------------- ### Debugging Root Not Set Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Resolution for missing root errors by explicitly setting the root node. ```python scFates.tl.root(adata, root=0) ``` -------------------------------- ### Configure CPU parallelization Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Control the number of cores used for testing and fitting functions via the n_jobs parameter. ```python # Use all available cores scFates.tl.test_association(adata, n_jobs=-1) # Use 4 specific cores scFates.tl.test_fork(adata, root_milestone='0', milestones=['2', '3'], n_jobs=4) ``` -------------------------------- ### Parallel Testing Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Use all available CPU cores for association testing. ```python scFates.tl.test_association(adata, n_jobs=-1) # All cores ``` -------------------------------- ### scFates.tl.roots() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md Defines multiple roots for multi-root trajectory analysis by specifying node indices and a convergence point. ```APIDOC ## scFates.tl.roots() ### Description Define multiple roots for multi-root trajectory analysis. ### Signature `scFates.tl.roots(adata: AnnData, roots: list, meeting: int, copy: bool = False) -> Optional[AnnData]` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with computed tree - **roots** (list) - Required - List of node indices to use as roots - **meeting** (int) - Required - Node index where all roots converge (single trunk point) - **copy** (bool) - Optional - Return a copy (Default: False) ### Returns - **Type** (Optional[AnnData]) ### Fields Added to adata - **.uns['graph']['root']** (list) - List of root node indices - **.uns['graph']['root2']** (int) - Convergence point ### Example ```python scFates.tl.roots(adata, roots=[0, 20], meeting=5) ``` ``` -------------------------------- ### pp.diffusion() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Performs diffusion analysis on the dataset. ```APIDOC ## pp.diffusion() ### Description Computes diffusion components for trajectory inference. ### Parameters - **n_components** (int) - Default: 10 - Number of diffusion components - **knn** (int) - Default: 30 - Nearest neighbors for graph construction - **alpha** (float) - Default: 0 - Diffusion operator normalization (0-1) - **multiscale** (bool) - Default: True - Use multiscale diffusion space - **n_eigs** (int) - Default: None - Components to retain if multiscale (None = keep all) - **n_pcs** (int) - Default: 50 - PCA dimensions for initial preprocessing - **device** (str) - Default: "cpu" - 'cpu' or 'gpu' ``` -------------------------------- ### scFates.tl.slide_cors() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-correlation-clustering.md Compute correlations between features in sliding windows along the trajectory. ```APIDOC ## scFates.tl.slide_cors() ### Description Compute correlations between features in sliding windows along the trajectory. ### Signature ```python def slide_cors( adata: AnnData, root_milestone: str, milestones: list, features: Union[None, str] = None, layer: Optional[str] = None, n_slide: int = 10, copy: bool = False ) -> Optional[AnnData] ``` ### Returns - **Type**: Optional[AnnData] ### Fields Added to adata - **.uns['root_milestone->milestoneA<>milestoneB']['slide_cors']** (DataFrame) - Sliding window correlations ### Example ```python scFates.tl.slide_cors(adata, root_milestone='0', milestones=['3'], n_slide=15) ``` ``` -------------------------------- ### scFates.datasets.pancreas() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Loads the Pancreas developmental trajectory dataset. ```APIDOC ## scFates.datasets.pancreas() ### Description Load Pancreas developmental trajectory dataset (Bastidas-Ponce et al.). ### Signature `def pancreas() -> AnnData` ### Returns - **Type:** `AnnData` - A dataset containing single-cell transcriptomics of pancreatic development. ### Example ```python # Load pancreas dataset adata = scFates.datasets.pancreas() ``` ``` -------------------------------- ### Infer tree structure with ElPiGraph Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Configure the ElPiGraph method for tree inference. ```python scFates.tl.tree( adata, method='epg', Nodes=50, epg_lambda=0.01, # Stretching epg_mu=0.1, # Bending device='cpu' ) ``` -------------------------------- ### scFates.get.fork_stats() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Extracts summary statistics from bifurcation test results. ```APIDOC ## scFates.get.fork_stats() ### Description Extract summary statistics from bifurcation test results. ### Signature `def fork_stats(adata: AnnData, root_milestone: str, milestones: list) -> dict` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix after test_fork - **root_milestone** (str) - Required - Progenitor milestone - **milestones** (list) - Required - Terminal milestones ### Returns - **dict** - Summary statistics ### Example ```python stats = scFates.get.fork_stats(adata, root_milestone='0', milestones=['2', '3']) ``` ``` -------------------------------- ### scFates.tl.attach_tree() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-graph-operations.md Attaches a new tree as a branch on an existing tree at a specified node. ```APIDOC ## scFates.tl.attach_tree() ### Description Attach a new tree as a branch on an existing tree at a specified node. ### Signature `scFates.tl.attach_tree(adata: AnnData, adata_new: AnnData, node: int, copy: bool = False) -> Optional[AnnData]` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with existing tree - **adata_new** (AnnData) - Required - Annotated data matrix with new tree to attach - **node** (int) - Required - Node index in existing tree to attach new tree to - **copy** (bool) - Optional - Return a copy (default: False) ### Returns - **Type** (Optional[AnnData]) ### Example ```python # Attach tree from adata2 to node 5 of adata1 scFates.tl.attach_tree(adata1, adata2, node=5) ``` ``` -------------------------------- ### Accessing .uns Keys Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Unstructured data keys storing graph topology, algorithm results, and bifurcation information. ```python .uns['graph']['B'] # Adjacency matrix .uns['graph']['F'] # Node coordinates .uns['graph']['root'] # Root node index .uns['ppt'] or .uns['epg'] # Algorithm results .uns['0->2<>3']['fork'] # Bifurcation results .uns['pseudotime_list'] # All cell mappings (if n_map>1) ``` -------------------------------- ### scFates.tl.activation() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-statistical-testing.md Tests for genes activated or repressed along each branch from a progenitor to a terminal state. ```APIDOC ## scFates.tl.activation() ### Description Test for genes activated or repressed along each branch from progenitor to terminal state. ### Signature ```python def activation( adata: AnnData, root_milestone: str, milestones: list, features: Union[None, str] = None, layer: Optional[str] = None, n_jobs: int = 1, n_map: int = 1, copy: bool = False ) -> Optional[AnnData] ``` ### Returns - **Type**: Optional[AnnData] ### Example ```python scFates.tl.activation(adata, root_milestone='0', milestones=['2', '3']) ``` ``` -------------------------------- ### scFates.tl.synchro_path() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-correlation-clustering.md Compute gene-to-gene correlations along specific tree paths. ```APIDOC ## scFates.tl.synchro_path() ### Description Compute gene-to-gene correlations along specific tree paths. ### Signature `def synchro_path(adata: AnnData, root_milestone: str, milestones: list, features: Union[None, str] = None, layer: Optional[str] = None, rescale: bool = False, copy: bool = False) -> Optional[AnnData]` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with tree and pseudotime - **root_milestone** (str) - Required - Starting milestone - **milestones** (list) - Required - Ending milestones - **features** (str or None) - Optional - Features to correlate. If None, uses all - **layer** (str) - Optional - Expression layer to use - **rescale** (bool) - Optional - Rescale pseudotime to [0,1] for correlation - **copy** (bool) - Optional - Return a copy ### Returns - **Optional[AnnData]** - Returns an AnnData object with correlation results added to .uns ### Example ```python scFates.tl.synchro_path(adata, root_milestone='0', milestones=['3']) ``` ``` -------------------------------- ### scFates.pl.trajectory() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-plotting.md Plots cell distributions along the tree with pseudotime and segment information. ```APIDOC ## scFates.pl.trajectory(adata, basis=None, color=None, root_milestone=None, milestones=None, s=30, alpha=0.8, cmap='viridis', show_milestones=True, ax=None, show=None, save=None, **kwargs) ### Description Plot cell distributions along the tree with pseudotime and segment information. ### Parameters - **adata** (AnnData) - Required - Annotated data matrix - **basis** (str) - Optional - Embedding to use ('umap', 'tsne', 'pca') - **color** (str or list) - Optional - Key(s) to color cells by - **root_milestone** (str) - Optional - Highlight specific starting milestone - **milestones** (list) - Optional - Highlight specific ending milestones - **s** (int) - Optional - Cell size - **alpha** (float) - Optional - Cell opacity - **cmap** (str) - Optional - Colormap for continuous variables - **show_milestones** (bool) - Optional - Label milestone regions - **ax** (Axes) - Optional - Matplotlib axis - **show** (bool) - Optional - Show the plot - **save** (str or bool) - Optional - Save path - **kwargs** (dict) - Optional - Additional scanpy arguments ### Returns - **Optional[Axes]** - Returns an Axes object if show=False ### Example ```python # Plot cells with tree and pseudotime colors scFates.pl.trajectory(adata, basis='umap', color='t') # Highlight specific path scFates.pl.trajectory(adata, color='cell_type', root_milestone='0', milestones=['3']) ``` ``` -------------------------------- ### Root Function Signature Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-trajectory-analysis.md The function signature for scFates.tl.root, defining the expected parameters and return type. ```python def root( adata: AnnData, root: Union[int, str], tips_only: bool = False, min_val: bool = False, layer: Optional[str] = None, copy: bool = False ) -> Optional[AnnData] ``` -------------------------------- ### scFates.pl.test_fork() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-plotting.md Plot bifurcation test results showing branch-specific expression. ```APIDOC ## scFates.pl.test_fork() ### Description Plot bifurcation test results showing branch-specific expression. ### Signature `def test_fork(adata: AnnData, root_milestone: str, milestones: list, top: int = 10, log_fdr: bool = True, ax=None, show: Optional[bool] = None, save: Union[str, bool, None] = None) -> Optional[Axes]` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix after test_fork - **root_milestone** (str) - Required - Progenitor milestone - **milestones** (list) - Required - Terminal milestones - **top** (int) - Optional (Default: 10) - Number of top genes to label - **log_fdr** (bool) - Optional (Default: True) - Log-transform FDR for plot - **ax** (Axes) - Optional (Default: None) - Matplotlib axis - **show** (bool) - Optional (Default: None) - Show plot - **save** (str or bool) - Optional (Default: None) - Save path ### Returns - **Type** (Optional[Axes]) ### Example ```python scFates.pl.test_fork(adata, root_milestone='0', milestones=['2', '3']) ``` ``` -------------------------------- ### scFates.tl.getpath() Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-graph-operations.md Extracts cells and pseudotime values along a path between two milestones. ```APIDOC ## scFates.tl.getpath() ### Description Extract cells and pseudotime values along a path between two milestones. ### Signature `scFates.tl.getpath(adata: AnnData, root_milestone: str, milestones: list, include_root: bool = False) -> tuple` ### Parameters - **adata** (AnnData) - Required - Annotated data matrix with tree and pseudotime - **root_milestone** (str) - Required - Starting milestone - **milestones** (list) - Required - Ending milestones - **include_root** (bool) - Optional - Include root milestone cells (default: False) ### Returns - **Type** (tuple) - Returns a tuple of (cell indices, node path, pseudotime values) ### Example ```python # Get cells and pseudotime along path from 0 to 3 cell_indices, nodes, pseudotime = scFates.tl.getpath(adata, '0', ['3']) ``` ``` -------------------------------- ### Execute fork test and retrieve results Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-statistical-testing.md Run the bifurcation test between specified terminal states and access the resulting DataFrame from the AnnData object. ```python # Test for branch-specific expression between two terminal states # With progenitor as root_milestone and two terminal branches scFates.tl.test_fork(adata, root_milestone='0', milestones=['2', '3']) # Get results fork_results = adata.uns['0->2<>3']['fork'] ``` -------------------------------- ### Load pancreas dataset with scFates.datasets.pancreas Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-utilities.md Retrieves the Bastidas-Ponce et al. pancreatic development dataset. ```python # Load pancreas dataset adata = scFates.datasets.pancreas() ``` -------------------------------- ### Common Plotting Parameters Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/configuration-and-parameters.md Parameters shared across most scFates plotting functions. ```APIDOC ## Common Plotting Parameters ### Description Shared parameters for customizing plots in scFates. ### Parameters - **basis** (str) - Default: None - Embedding name ('umap', 'tsne', 'pca'). Auto-detected if None - **color** (str or list) - Default: None - Key in .obs or .var for coloring - **ax** (Axes) - Default: None - Matplotlib axis to plot on - **show** (bool) - Default: None - Show figure (None = use IPython detection) - **save** (str or bool) - Default: None - Save path or True for auto-naming ``` -------------------------------- ### Debugging Graph Not Found Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/quick-reference.md Resolution for missing graph errors by initializing the tree structure. ```python scFates.tl.tree(adata, Nodes=100, use_rep='pca') ``` -------------------------------- ### Compute sliding window correlations with scFates Source: https://github.com/louisfaure/scfates/blob/master/_autodocs/api-reference-correlation-clustering.md Calculates feature correlations in sliding windows along a specified trajectory path. ```python # Compute correlations in 15 windows along path scFates.tl.slide_cors(adata, root_milestone='0', milestones=['3'], n_slide=15) ```