EpiScanpy

repository·master·Indexed 41 days ago

https://github.com/colomemaria/episcanpy

A Python-based toolkit for analyzing single-cell epigenomic data, such as scATAC-seq and scBS-seq, extending the Scanpy framework. It provides modules for building count matrices (epi.ct), preprocessing and quality control (epi.pp), downstream analysis and clustering (epi.tl), and visualization (epi.pl). The toolkit utilizes anndata.AnnData as its primary data structure for storing methylation and ATAC-seq matrices.

Tokens
7K
Snippets
33
Records
41
Agent score
100%

What's inside EpiScanpy

  1. Overview of EpiScanpy

    master

    EpiScanpy is a Python toolkit designed for the analysis of epigenomic single-cell data. It specifically supports:

    • scATAC-seq: Single-cell open chromatin data.
    • scBS-seq: Single-cell DNA methylation data.

    EpiScanpy is built as an epigenomic extension of Scanpy, the widely used tool for single-cell RNA-seq analysis. Users familiar with Scanpy will find the workflows and data structures conceptually similar.

  2. Understand the EpiScanpy data structure

    master
    EpiScanpy uses the anndata.AnnData object as its primary data structure for storing methylation and ATAC-seq matrices. This structure stores observations (n_obs, e.g., cells) and variables (n_vars, e.g., expression, methylation, or chromatin features).
  3. Analyze epigenomic data with tl module

    master

    The episcanpy.api.tl (Tools) module contains functions for downstream analysis, clustering, and dimensionality reduction.

    Dimensionality Reduction & Embedding

    • tl.tsne: t-SNE embedding.
    • tl.umap: UMAP embedding.
    • tl.diffmap: Diffusion maps.
    • tl.pca: Principal Component Analysis.

    Clustering

    • tl.louvain: Louvain community detection.
    • tl.leiden: Leiden clustering.
    • tl.kmeans: K-means clustering.
    • tl.hc: Hierarchical clustering.
    • tl.getNClusters: Determine number of clusters.

    Feature & Gene Analysis

    • tl.rank_features: Rank features.
    • tl.top_feature_genes: Identify top feature genes.
    • tl.var_features_to_genes: Map variable features to genes.
    • tl.geneactivity: Calculate gene activity.
    • tl.find_genes_in_features: Find genes within specific features.
    • tl.load_markers: Load marker genes.
    • tl.identify_cluster: Identify cluster markers.

    Trajectory & Graph Analysis

    • tl.dpt: Diffusion Pseudotime.
    • tl.draw_graph: Visualize graphs.
    • tl.diffmap: Diffusion maps.

    Evaluation Metrics

    • tl.ARI: Adjusted Rand Index.
    • tl.AMI: Adjusted Mutual Information.
    • tl.homogeneity: Homogeneity score.
    • tl.silhouette: Silhouette coefficient.
  4. Install epiScanpy

    master

    You can install the latest stable version of episcanpy via pip, or install the latest development version directly from the GitHub repository if you need specific updates.

    # to install the latest stable version of episcanpy
    pip install episcanpy
    
    # to install the latest development version of episcanpy
    pip install git+https://github.com/colomemaria/epiScanpy@update_load_features
  5. Perform quality control and preprocessing with epi.pp

    master

    All preprocessing and quality control functions are located in the epi.pp module. The input for these functions is an anndata.AnnData object.

    Visualizing coverage and feature commonness

    Use these functions to understand feature distribution and coverage:

    • epi.pp.commoness_features(adata, **processing_params)
    • epi.pp.coverage_cells(adata, **processing_params)

    Filtering cells and features

    To remove low-quality data:

    • epi.pp.filter_cells(adata, min_features=10)
    • epi.pp.filter_features(adata, min_cells=10)

    Feature selection

    To reduce the feature space to the most variable features:

    1. Calculate variability: epi.pl.cal_var(adata)
    2. Select features: epi.pp.select_var_feature(adata, max_score=0.2, nb_features=50000)
    # Quality control examples
    epi.pp.commoness_features(adata, **processing_params)
    epi.pp.coverage_cells(adata, **processing_params)
    
    # Filtering
    epi.pp.filter_cells(adata, min_features=10)
    epi.pp.filter_features(adata, min_cells=10)
    
    # Feature selection
    epi.pl.cal_var(adata)
    epi.pp.select_var_feature(adata, max_score=0.2, nb_features=50000)
  6. Process Cusanovich mouse scATAC-seq atlas

    master

    Use this tutorial to learn how to process and cluster count matrices specifically from the Cusanovich mouse scATAC-seq atlas.

    https://nbviewer.jupyter.org/github/colomemaria/epiScanpy/blob/master/docs/tutorials/Cusanovich2018_BoneMarrow_data_processing_diffmap.html
  7. Build count matrices for single cell DNA methylation

    master

    This tutorial demonstrates how to build count matrices for different feature spaces (such as windows or promoters) across various cytosine contexts for single-cell DNA methylation data.

    https://nbviewer.jupyter.org/github/colomemaria/epiScanpy/blob/master/docs/tutorials/bld_count_matrix_methylation_tutorial.html
  8. Preprocess epigenomic data with pp module

    master

    The episcanpy.api.pp (Preprocessing) module handles data cleaning, normalization, and imputation.

    Methylation Specific Preprocessing

    • pp.imputation_met: Impute missing methylation data.
    • pp.load_met_noimput: Load methylation data without imputation.
    • pp.readandimputematrix: Read and impute a methylation matrix.

    General Preprocessing Tasks

    • Filtering: pp.filter_cells, pp.filter_features, pp.coverage_cells, pp.coverage_features, pp.commonness_features, pp.density_features.
    • Normalization: pp.normalize_total, pp.normalize_per_cell, pp.log1p, pp.binarize.
    • Dimensionality Reduction & Batch Correction: pp.pca, pp.regress_out, pp.neighbors.
    • Data Manipulation: pp.subsample, pp.downsample_counts, pp.sparse, pp.snap2anndata (convert to AnnData format).
  9. Install epiScanpy via Anaconda

    master

    To install episcanpy using Conda, first ensure you have a working Python 3.5 or 3.6 environment. You should install the necessary dependencies (seaborn, scikit-learn, statsmodels, numba, python-igraph, and louvain), create a dedicated environment for scanpy, and then install episcanpy from the annadanese channel.

    Follow these steps in order:

    # Install dependencies
    conda install seaborn scikit-learn statsmodels numba
    conda install -c conda-forge python-igraph louvain
    
    # Create a scanpy environment
    conda create -n scanpy python=3.6 scanpy
    
    # Install episcanpy from the annadanese channel
    conda install -c annadanese episcanpy
  10. Build custom count matrices from 10x outputs

    master

    A tutorial is available for building custom count matrices using standard 10x single cell ATAC outputs (TSV or CellRanger outputs) and performing the corresponding data processing.

    https://nbviewer.jupyter.org/github/colomemaria/epiScanpy/blob/master/docs/tutorials/Tutorial_building_custom_count_matrices_from_tsv_or_cellranger_outputs.ipynb
  11. Build count matrices from ATAC-seq BAM files

    master

    You can build count matrices from ATAC-seq BAM files using different sets of annotations, such as enhancers. The tutorial demonstrates how to handle these files to prepare data for downstream analysis.

    https://nbviewer.jupyter.org/github/colomemaria/epiScanpy/blob/master/docs/tutorials/ATAC_bld_ct_mtx_tutorial.html