Scarf: A toolkit for memory efficient analysis of large-scale single-cell genomics data

Parashar Dhapola, Johan Rodhe, Rasmus Olofzon, Thomas Bonald, Eva Erlandsson, Shamit Soneji, Göran KarlssonbioRxiv 2021

TL;DR

This paper introduces Scarf, a Python toolkit designed for memory-efficient analysis of massive single-cell genomics datasets. Scarf enables researchers to perform complex analyses, including clustering, dimensionality reduction, and data integration, on standard laptops, overcoming the computational barriers of current state-of-the-art tools.

What Problem Does This Paper Address?

The explosion of single-cell genomics data, with experiments now generating millions of cells, has outpaced the computational resources typically available to researchers. Analyzing these "atlas-scale" datasets often requires specialized, high-performance computing clusters with vast amounts of RAM, creating a significant barrier to entry. Existing tools, while powerful, can be memory-intensive, making it difficult or impossible to run them on standard laptops or even modest servers. This limits the ability of many researchers to explore, re-analyze, or integrate these valuable datasets. Scarf aims to bridge this gap by providing a memory-efficient, modular, and user-friendly solution that democratizes access to large-scale single-cell data analysis.

Methods

Scarf's core innovation lies in its memory-efficient implementations of standard single-cell analysis steps. Key techniques include:

  • Chunking and Compression: Datasets are divided into smaller, manageable chunks, compressed individually, and stored on disk. This significantly reduces the RAM footprint.
  • Out-of-Core/Incremental Algorithms: Algorithms like PCA and KNN are implemented to process data iteratively in chunks, rather than requiring the entire dataset in memory at once.
  • Zarr File Format: Scarf utilizes the Zarr format for storing chunked datasets, which offers advantages in parallel operations and remote data access compared to traditional formats like HDF5.
  • Novel Downsampling Algorithm (TopACeDo): This algorithm leverages the cell-cell neighborhood graph to intelligently select representative cells, preserving rare cell populations and differentiation trajectories while reducing redundancy.
  • Memory-Efficient Data Integration: Scarf employs a reference-based mapping approach using a KNN algorithm, allowing for efficient integration of new datasets into existing reference manifolds without extensive batch correction.
  • Hierarchical Graph Clustering (Paris): A novel approach that creates a dendrogram of cell clusters, offering a richer representation of cell-cell relationships than traditional flat clustering methods.

Datasets

Scarf was evaluated on several large-scale single-cell RNA-Seq and ATAC-Seq datasets, including:

  • scRNA-Seq Datasets: Ranging from 600K to 4 million cells.
  • scATAC-Seq Datasets: Including a >700K single-cell ATAC-Seq dataset.
  • Pancreatic Cell Datasets: Four datasets from different labs and platforms.
  • Mouse Nervous System Atlas: A dataset with 146,093 cells.
  • PBMC Datasets: Including a 10K PBMC dataset and a simulated PBMC dataset with 1.2 million cells.

The paper also uses publicly available datasets for benchmarking and demonstrating specific functionalities like data integration.

Key Insights and Ideas

  • Memory Efficiency is Paramount: The paper strongly argues that memory limitations, not just computation time, are the primary bottleneck for analyzing large single-cell datasets. Scarf's success hinges on addressing this directly.
  • Downsampling Can Preserve Biology: The TopACeDo algorithm demonstrates that intelligent downsampling can effectively reduce dataset size while retaining crucial biological information, such as rare cell types and lineage relationships, which random sampling often misses.
  • Hierarchical Clustering Offers Deeper Insights: The Paris algorithm provides a dendrogram structure that reveals nuanced relationships between cell clusters, offering a more comprehensive view than static partitioning.
  • Laptop-Scale Analysis is Achievable: The most impactful insight is that complex, large-scale single-cell analyses are no longer confined to high-performance computing clusters; Scarf makes them accessible on standard hardware.

Key Results

  • Memory Reduction: Scarf consistently used substantially less memory than Scanpy across various datasets and parameters. For example, it processed a 4 million cell dataset using less than 16GB of RAM, while Scanpy failed to process similar datasets even with 200GB of RAM.
  • Comparable Runtime: Despite its memory efficiency, Scarf's runtime was comparable to Scanpy for many analyses. For instance, it processed a 4 million cell dataset in under 10 hours.
  • Accurate Data Integration: Scarf accurately mapped and co-embedded datasets, preserving cell type identities and relationships, even when integrating multiple datasets from different sources.
  • Effective Downsampling: Scarf's TopACeDo algorithm successfully reduced dataset size (down to ~1% of cells) while preserving all cell clusters and rare cell populations, outperforming random sampling and GeoSketch in preserving cell connectivity and representation of rare clusters.
  • Scalability: Scarf demonstrated scalability to datasets with up to 4 million cells for UMAP and SG-tSNE, and handled large scATAC-Seq datasets efficiently.

Limitations and Future Work

  • Clustering Information for Downsampling: The TopACeDo algorithm requires clustering information, which might not be available or straightforward to obtain in all scenarios. GeoSketch, in contrast, does not have this requirement.
  • UMAP vs. SG-tSNE: While both UMAP and SG-tSNE are useful for visualization, they offer complementary strengths. UMAP excels at preserving global structure and relationships between clusters, while SG-tSNE can reveal finer-grained heterogeneity. The choice depends on the specific research question.
  • Future Work: The authors suggest that Scarf's modular design allows for easy integration of new methods and extensions. The paper also highlights the potential for further development in data integration and visualization techniques.

Summary updated

BibTeX
@misc{dhapola2021scarf,
  author = {Parashar Dhapola and Johan Rodhe and Rasmus Olofzon and Thomas Bonald and Eva Erlandsson and Shamit Soneji and Göran Karlsson},
  title = {{Scarf: A toolkit for memory efficient analysis of large-scale single-cell genomics data}},
  year = {2021},
  doi = {10.1101/2021.05.02.441899},
  howpublished = {bioRxiv},
}
Figure