Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cepo

R-CMD-check Bioconductor Platform Documentation

πŸ“– Documentation: https://zaoqu-liu.github.io/Cepo/

Cepo (Cell identity gene prioritization) is a method to explore cell identities from single-cell RNA-sequencing data using differential stability as a new metric to define cell identity genes.

πŸš€ This fork includes significant performance optimizations using Rcpp/C++, achieving 5-50x speedup over the original implementation.

✨ Key Features

  • πŸ“Š Differential Stability Analysis: Identifies genes with stable expression patterns specific to cell types
  • ⚑ High Performance: C++ backend for computationally intensive operations
  • πŸ”„ Multiple Methods: Supports CV, SD, MAD, IQR stability measures
  • πŸ“ˆ Scalable: Handles large atlas-scale datasets with DelayedArray/HDF5 support
  • πŸ–₯️ Cross-Platform: Works on Linux, macOS, and Windows

πŸ“¦ Installation

From GitHub (Recommended - includes performance optimizations)

# install.packages("remotes")
remotes::install_github("Zaoqu-Liu/Cepo")

From Bioconductor (Original version)

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("Cepo")

πŸš€ Quick Start

library(Cepo)
library(SingleCellExperiment)

# Load example data
data("cellbench", package = "Cepo")

# Run Cepo analysis
result <- Cepo(
    exprsMat = logcounts(cellbench),
    cellTypes = cellbench$celltype
)

# View top identity genes for each cell type
topGenes(result, n = 5)

Output:

$HCC827
[1] "CASC9" "AC011632.1" "SPESP1" "AC078962.4" "LINC01980"

$H1975
[1] "AC092447.7" "CT45A3" "AL049870.3" "TDRD9" "TNNI3"

$H2228
[1] "HLA-DRB6" "AR" "NDN" "DNAJC15" "TIMP3"

⚑ Performance Benchmark

Tested on cellbench dataset (894 genes Γ— 895 cells, 3 cell types):

Operation Time
Basic Cepo 0.028s
With CV stability 0.016s
With SD stability 0.016s
With MAD stability 0.038s
With IQR stability 0.033s
Bootstrap p-values (100Γ—) 1.84s

Benchmarked on Apple M1 Pro. Performance may vary by hardware.

πŸ“– Usage Examples

Basic Analysis

# Standard analysis with default parameters
result <- Cepo(
    exprsMat = logcounts(sce),
    cellTypes = sce$celltype
)

With Gene Filtering

# Filter lowly expressed genes (expressed in >5% cells)
result <- Cepo(
    exprsMat = logcounts(sce),
    cellTypes = sce$celltype,
    exprsPct = 0.05
)

# Filter by log fold change
result <- Cepo(
    exprsMat = logcounts(sce),
    cellTypes = sce$celltype,
    logfc = 1
)

Computing P-values

# Fast p-value computation using normal approximation
result <- Cepo(
    exprsMat = logcounts(sce),
    cellTypes = sce$celltype,
    computePvalue = 200,        # Number of bootstrap iterations
    computeFastPvalue = TRUE    # Use fast approximation
)

# Access p-values
head(result$pvalues)

Different Stability Measures

# Coefficient of Variation (default)
result_cv <- Cepo(exprsMat, cellTypes, variability = "CV")

# Standard Deviation
result_sd <- Cepo(exprsMat, cellTypes, variability = "SD")

# Median Absolute Deviation
result_mad <- Cepo(exprsMat, cellTypes, variability = "MAD")

# Interquartile Range
result_iqr <- Cepo(exprsMat, cellTypes, variability = "IQR")

Batch-aware Analysis

# Run analysis accounting for batch effects
result <- Cepo(
    exprsMat = logcounts(sce),
    cellTypes = sce$celltype,
    block = sce$batch,
    minCelltype = 2
)

# Access batch-specific and averaged results
names(result)  # Individual batches + "average"

Parallel Processing

# Use multiple cores for faster computation
result <- Cepo(
    exprsMat = logcounts(sce),
    cellTypes = sce$celltype,
    computePvalue = 200,
    workers = 4  # Number of cores
)

Visualization

# Plot gene expression densities
plotDensities(
    x = sce,
    cepoOutput = result,
    nGenes = 2,
    assay = "logcounts",
    celltypeColumn = "celltype"
)

# Plot specific genes
plotDensities(
    x = sce,
    cepoOutput = result,
    genes = c("GENE1", "GENE2", "GENE3"),
    assay = "logcounts",
    celltypeColumn = "celltype"
)

Large-scale Data (Out-of-memory)

library(DelayedArray)
library(HDF5Array)

# Convert to HDF5-backed DelayedArray
da_matrix <- DelayedArray(realize(logcounts(sce), "HDF5Array"))

# Run Cepo (automatically uses R backend for DelayedArray)
result <- Cepo(
    exprsMat = da_matrix,
    cellTypes = sce$celltype
)

πŸ”§ Performance Optimizations (v1.17.0)

This fork includes major performance improvements:

C++ Backend (Rcpp)

  • computeSegIndex_cpp: Core segmentation index computation
  • rowCV_cpp, rowMAD_cpp, rowIQR_cpp: Fast stability measures
  • fastRank_cpp: Optimized ranking with tie handling
  • consensusSegIdx_cpp: Efficient consensus computation

Vectorized R Code

  • Eliminated all for loops in critical paths
  • Pre-computed cell type indices using split()
  • Vectorized gene statistics computation
  • Integer indexing instead of character indexing

Bug Fixes

  • Fixed prefilterGenes() where mean(x - mean(x)) always returned 0

πŸ“š Documentation

πŸ“– Citation

If you use Cepo in your work, please cite:

Kim H.J., Wang K., Yang P. (2021). Cepo uncovers cell identity through differential stability. bioRxiv. DOI: 10.1101/2021.01.10.426138

@article{kim2021cepo,
  title={Cepo uncovers cell identity through differential stability},
  author={Kim, Hani Jieun and Wang, Kevin and Yang, Pengyi},
  journal={bioRxiv},
  year={2021},
  doi={10.1101/2021.01.10.426138}
}

πŸ‘₯ Contributors

Original Authors:

Performance Optimization:

πŸ“„ License

MIT License

🀝 Contact

About

Uncovering cell identity genes using differential stability of expression in single cells.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages