← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-single-cell-data-io / references / usage-guide.md

Single-Cell Data I/O - Usage Guide

Overview

This skill covers reading, writing, creating, and converting single-cell objects across AnnData (Python), Seurat (R), and SingleCellExperiment (R). It emphasizes the decisions that prevent silent data loss: keeping the raw 10X matrix, choosing stable gene identifiers, picking a storage format, and converting between Python and R without dropping layers or transposing the matrix incorrectly.

Prerequisites

Python (Scanpy/AnnData):

pip install scanpy anndata
# multimodal: pip install muon mudata

R (Seurat + conversion):

install.packages('Seurat')
# Conversion (prefer maintained tools; SeuratDisk is abandoned):
remotes::install_github('scverse/anndataR')          # pure-R h5ad/zarr I/O + conversion
BiocManager::install('zellkonverter')                # SCE <-> AnnData
remotes::install_github('cellgeni/schard')           # robust pure-R h5ad reading

Quick Start

Tell the AI agent what is needed: - "Load the raw 10X matrix and keep the antibody-capture features" - "Create an AnnData object from this count matrix and store raw counts" - "Convert this h5ad to a Seurat object without losing the UMAP and layers"

Example Prompts

Loading Data

"Read the raw_feature_bc_matrix folder using Ensembl gene IDs"

"Load this Cell Ranger h5 and report cells x genes"

"Load the 10X output but keep CRISPR guide and antibody features"

Creating Objects

"Build an AnnData from this matrix, put integer counts in a counts layer"

"Create a Seurat v5 object from this sparse matrix with min.cells 3"

Converting

"Convert this AnnData to a SingleCellExperiment, keeping reducedDims and raw"

"Move this Seurat object to h5ad for Python and verify no layers were dropped"

"Why did my gene and cell axes swap after conversion?"

What the Agent Will Do

  1. Identify the input format and whether the raw (unfiltered) 10X matrix is available
  2. Choose gene identifiers (Ensembl IDs for reproducibility) and whether to retain non-GEX features
  3. Read into AnnData or Seurat, placing counts/normalized/embeddings in conventional slots
  4. For conversion, select a maintained converter, apply the transpose, and remap metadata axes
  5. Diff slot inventories before and after conversion to confirm nothing was silently dropped
  6. Write to the appropriate format (h5ad/zarr/RDS/h5mu) and keep the original

Tips