# 04. From Sequencer Output to a Cell by Gene Matrix

> How cell addresses and molecule labels are read from sequencer output while RNA-derived sequences are assigned to genes to produce a cell-by-gene count matrix.

Primary processing of single-cell RNA measurements joins two kinds of short sequence fragment, or **read**. One carries a cell address called a **cell barcode** and an original-molecule label called a **unique molecular identifier** (UMI). The other carries **complementary DNA** (cDNA), a DNA copy of RNA, that can be aligned to a gene. A **FASTQ file** stores each read sequence and its quality scores. Two FASTQ records from the same molecule are paired to form a **feature-barcode count matrix**. Here, a feature is a measured gene, a barcode is a candidate cell, and each value is the deduplicated number of RNA molecules.

> **Question for this lesson**: How do cell-address and cDNA reads become gene counts for each cell?

## Fix the inputs and output first

Exact read lengths and barcode positions depend on the **chemistry version**, the laboratory specification used to build the collection of molecules prepared for sequencing, or library. When several libraries are sequenced together, a **sample index** is a separate address that identifies the source library. Alignment also requires a reference genome and **Gene Transfer Format** (GTF) annotation containing gene coordinates. The data roles remain stable.

| input | information |
| --- | --- |
| Read 1 FASTQ | cell barcode + UMI |
| Read 2 FASTQ | cDNA copied from mRNA |
| sample index | source library |
| reference genome + [GTF gene annotation](/en/reference/gtf/) | genome sequence and gene coordinates |

Each output cell is the number of original RNA molecules assigned to one gene in one candidate cell. Most genes are not detected in a given cell, so most values are `0` and the matrix is sparse.

## Five steps produce one count

### 1. Read and validate the cell barcode

The observed barcode is checked against the valid list for the chemistry. A mismatch may be corrected using base quality and a nearby valid barcode. Reads that cannot be assigned confidently are excluded.

### 2. Align the cDNA read

The cDNA sequence is aligned to the reference genome and transcript annotation. Exon boundaries and splice junctions matter, as they do in bulk RNA-seq.

### 3. Assign the read to a gene

The alignment is compared with GTF annotation. Reads that overlap several genes ambiguously may be left out of confident counts.

### 4. Collapse UMI duplicates

Reads are grouped by `cell barcode + gene + UMI`. Copies created during polymerase chain reaction (PCR) amplification in the same group collapse to one count, and likely UMI sequencing errors can be corrected using sequence distance and read support.

### 5. Select barcodes associated with real cells

A nonzero barcode is not necessarily a cell. An empty droplet can contain ambient RNA released from broken cells into the surrounding solution. Selecting barcodes that appear to contain captured cells from total UMI counts and expression profiles is called **cell calling**.

## Keep matrices from before and after cell calling

Cell Ranger reports a **raw matrix** before cell calling and a **filtered matrix** containing only candidate cells selected by cell calling.

| output | included barcodes |
| --- | --- |
| raw feature-barcode matrix | valid barcodes with at least one read, including background |
| filtered feature-barcode matrix | barcodes called as cell-associated |

The raw matrix supports ambient-RNA estimation and review of low-RNA cells that default calling may miss.

A 10x **Matrix Exchange** (MEX) matrix consists of three files.

```text
filtered_feature_bc_matrix/
  matrix.mtx.gz
  features.tsv.gz
  barcodes.tsv.gz
```

- `features.tsv.gz` maps row numbers to feature IDs, names, and types.
- `barcodes.tsv.gz` maps column numbers to barcode sequences.
- `matrix.mtx.gz` stores only nonzero row, column, and UMI-count entries.

The 10x file has **features in rows and barcodes in columns**. AnnData, the data object used by the Python package Scanpy, typically exposes the same data as observations, cells, by variables, genes. Always name both axes instead of guessing from shape.

## Cell Ranger is an implementation, not the concept

Cell Ranger is the official 10x Chromium pipeline. The v10.1 documentation checked in August 2026 covers barcode processing, alignment, UMI counting, and feature-barcode output.

Other implementations can produce the same data type. Reproducibility still requires the chemistry, pipeline version, genome and GTF version, cell-calling settings, UMI correction, and raw versus filtered output paths.

## Summary

Primary analysis reads cell and molecule addresses, assigns cDNA reads to genes, collapses UMI groups, and calls cell-associated barcodes. The result is a raw matrix and a smaller filtered matrix.

Next, [Filtering Empty Droplets and Low-Quality Cells](/en/lessons/single-cell-qc/) inspects the evidence behind the word filtered.

---

### Sources

- Cell Ranger and current version: [10x Genomics Cell Ranger](https://www.10xgenomics.com/support/software/cell-ranger/latest)
- Barcode and UMI counting: [Cell Ranger gene expression algorithm](https://www.10xgenomics.com/support/software/cell-ranger/latest/algorithms-overview/cr-gex-algorithm)
- Raw and filtered MEX structure: [Cell Ranger feature-barcode matrices](https://www.10xgenomics.com/support/software/cell-ranger/latest/analysis/outputs/cr-outputs-mex-matrices)