Skip to main content
Loading navigation
Back to prompt library

Build a Single-Cell Sequence Quality and Cross-Batch Contamination Assessor — implementation

Linked challenge: Build a Single-Cell Sequence Quality and Cross-Batch Contamination Assessor

Prompt source

implementation86 lines11 sectionsNo variables1 code block
## Build
Analyze single-cell count matrices and sequence metrics to identify cross-batch barcode swapping and alien sequence contamination. Synthesize batch quality scores and flag aberrant cell droplets for biocuration.

## User
Single-Cell Genomics Biocurator

## Workflow
1. Load single-cell count matrices and sample sequence metrics via Scanpy and AnnData structures.
2. Calculate mitochondrial read fractions, total unique molecular identifiers, and foreign gene counts.
3. Apply statistical outlier detection to uncover ambient contamination and barcode bleeding.
4. Export an AnnData quality report highlighting contaminated droplets for research filtering.

## Interface
Quality control dashboard displaying violin distribution plots, UMI scatter charts, and droplet filtering gates.

## Data
Generate synthetic AnnData objects using Scanpy APIs containing simulated cell barcodes and count matrices.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Scanpy single-cell analysis](https://raw.githubusercontent.com/scverse/scanpy/main/README.md)
Employ Scanpy preprocessing functions (pp.calculate_qc_metrics) and AnnData structures to compute droplet quality.

## Tools
ray-serve, scanpy, anndata, numpy.
ray-serve scales distributed matrix preprocessing across multi-sample single-cell batches with fast HTTP endpoints.
Local Python runtime with ray serving; optional small local LLM for narrative summary generation.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Loads AnnData formats and calculates QC metrics including mitochondrial percentages.
- Detects aberrant droplets exceeding predefined contamination cutoffs.
- Exposes a scalable Ray Serve endpoint returning structured droplet status summaries.
- Enables interactive biocurator sign-off on filtered count matrices.

## Starter Examples
```json
[
  {
    "input": {
      "batch_id": "SC-BATCH-10",
      "cells": [
        {
          "cell_barcode": "BC-01",
          "total_counts": 5000,
          "pct_mito": 3.2,
          "foreign_reads": 2
        },
        {
          "cell_barcode": "BC-02",
          "total_counts": 250,
          "pct_mito": 28.5,
          "foreign_reads": 45
        }
      ],
      "max_mito_pct": 20,
      "min_counts": 500
    },
    "expected_output": {
      "batch_id": "SC-BATCH-10",
      "total_cells": 2,
      "filtered_cells": 1,
      "retained_barcodes": [
        "BC-01"
      ],
      "flagged_barcodes": [
        {
          "barcode": "BC-02",
          "reason": "high_mito_low_counts"
        }
      ]
    }
  },
  {
    "input": {
      "batch_id": "SC-BATCH-11",
      "cells": [],
      "max_mito_pct": 20,
      "min_counts": 500
    },
    "expected_output": {
      "batch_id": "SC-BATCH-11",
      "total_cells": 0,
      "filtered_cells": 0,
      "retained_barcodes": [],
      "flagged_barcodes": []
    }
  }
]
```

## Safety
Research assay quality analysis tool; purely computational sequence QA; no diagnostic use or health recommendations.
Use mock external writes. Require human review before any real deployment.