Skip to content

Multi-genome data

Work with data aligned to a combined reference of two species, as in a species-mixing ("barnyard") experiment or a patient-derived xenograft (PDX). Skopia labels each gene by species, sums each cell's counts per species, and calls each cell human, mouse, mixed or unassigned.

Where to find it

Analyze → Multi-genome: Detect species prefixes, Add species column (.var), Sum species counts (from .var), Sum species counts (by name), Assign species. Analyze → Genes: Rename genes, Add boolean column.

The use case

When cells from two species are captured together and aligned to a combined reference, Cell Ranger names every gene with its genome as a prefix: GRCh38_ACTB, mm10___Actb. Each cell's counts then split between the two genomes. A cell with nearly all its counts on one genome is that species; a cell with substantial counts on both is most likely a doublet of one human and one mouse cell. A barnyard experiment uses this to measure the doublet rate; a PDX study uses it to separate the human tumor cells from the mouse stroma.

The steps below take you from prefixed gene names to a per-cell species call, and then to bare gene symbols so the rest of Skopia (gene sets, the gene info lookup, classifiers) recognizes the genes.

Run it

Run these in order, from Analyze → Multi-genome unless stated:

  1. Detect species prefixes. A read-only preview: it lists the genome prefixes found on the gene names and how many genes carry each. Check that it finds the two genomes you expect.
  2. Add species column (.var). Writes a categorical .var column (default species) that names each gene's genome. Do this before stripping the prefixes, so the species of each gene is recorded somewhere other than its name.
  3. Sum species counts (from .var). Sums each cell's counts per species from that column, one .obs column per species: GRCh38_counts, mm10_counts.
  4. Assign species. Calls each cell from those count columns into obs['species'].
  5. Analyze → Genes → Rename genes with the default pattern strips the prefixes, leaving ACTB and Actb. The original names are kept in .var['gene_symbol_original'].

After step 5, you can filter on the species call (for example, keep only the human cells of a PDX with the cell mask) and analyze each species separately.

Detect species prefixes

A prefix is the shortest leading token followed by one or more underscores (GRCh38_, mm10___). A candidate counts as a genome only if it covers at least the Min gene fraction of genes (default 0.01) and at least 2 genes, so ordinary symbols that happen to contain an underscore (MT_ND1, HLA_A) are not mistaken for one. Nothing is written.

Add species column (.var)

Parameter Default What it does
Output column species The new categorical .var column.
Prefixes (optional) blank Comma-separated prefixes, for example GRCh38_, mm10___. Blank uses the detected ones.
Labels (optional) blank Species names aligned to the prefixes, for example human, mouse. Blank uses each prefix without its underscores (GRCh38, mm10).
Min gene fraction 0.01 Detection threshold; ignored when you give prefixes.
Unknown label unknown Label for genes with no genome prefix.
Overwrite existing column false An existing column is kept unless this is true, so re-running is safe.

When one prefix is the start of another (mm10_ and mm10___), each gene is matched to the longest prefix it starts with.

Sum species counts (from .var)

Parameter Default What it does
Species column (.var) species The column from the previous step.
Source matrix counts The layer to sum; falls back to .X if there is no such layer. Use raw counts.
Column suffix _counts Appended to each species label to name its .obs column.
Include unknown genes false Also write a column for genes with no genome prefix.

Because it reads the .var column rather than the gene names, it keeps working after the prefixes are stripped.

Sum species counts (by name)

The older route, which sums the counts of genes whose names match a pattern into one .obs column. It stops working once the prefixes are stripped, so prefer the .var version.

Parameter Default What it does
Gene-name pattern GRCh38_ A prefix, or a regular expression (matched anywhere in the name unless anchored with ^).
Match mode prefix prefix or regex.
Output column (optional) blank Blank derives the name from the pattern's letters and digits: GRCh38_counts.
Source matrix counts As above.

Run it once per species.

Assign species

For each cell, Skopia divides each species' count by the cell's total over the listed columns. The species with the largest share is called if that share reaches the Purity threshold; otherwise the cell is mixed. Cells with no counts in any listed column are unassigned.

Parameter Default What it does
Count columns GRCh38_counts, mm10_counts Two or more numeric .obs columns.
Labels (optional) blank Species labels; blank uses the column names without _counts (GRCh38, mm10).
Output column species The new categorical .obs column.
Purity threshold 0.9 Minimum share of counts to call a species.

Color by the output column and plot GRCh38_counts against mm10_counts to check the call: pure cells lie along the two axes and doublets between them.

What it writes

Where What Step
var['species'] Species of each gene (categorical) Add species column
obs['<label>_counts'] Per-cell count sum for one species Sum species counts
obs['species'] GRCh38, mm10 (or your labels), mixed, unassigned Assign species
var['gene_symbol_original'] Gene names before the first rename Rename genes

Rename genes

Find and replace across all gene names (Analyze → Genes → Rename genes). The default Find pattern is

^(GRCh38|mm10)_+

which removes a leading GRCh38 or mm10 and the underscores after it.

Parameter Default What it does
Find strips a GRCh38 or mm10 prefix (pattern below) A regular expression, or plain text in literal mode.
Replace with blank Blank removes the match. Regex mode supports backreferences (\1).
Match mode regex literal treats the pattern as plain text, replacing it everywhere it occurs.
Make duplicates unique false Only applies when the rename would give two genes the same name.

The original names are kept in .var['gene_symbol_original'] the first time you rename, and later renames do not overwrite them. The rename refuses, with the names involved, when nothing matches, when a gene would be left with an empty name, or when two genes would end up with one name (unless Make duplicates unique is true). Merging two genes under one name would silently combine them in every later lookup, which is why a collision is refused by default.

Collisions after stripping prefixes

Human and mouse orthologs often differ only in case (ACTB, Actb) and stay distinct. Where both genomes use exactly the same symbol, stripping the prefixes collides them, and the rename stops and lists the names. Either keep the prefixes, rename one genome only (^mm10___), or allow unique suffixes knowing the genes stay separate under different names.

Rename genes is also how to fix symbols that contain underscores before training a cell type classifier.

Add boolean column

Flags genes whose names match a pattern as a boolean .var column (Analyze → Genes → Add boolean column). The defaults, column mt from the regex ^mt-, mark mouse mitochondrial genes. Such a column can be chosen as a QC variable in Analyze → Preprocess → QC Metrics, which then reports the share of each cell's counts from those genes; see Preprocess.

Parameter Default What it does
Column name mt The new boolean .var column. An existing non-boolean column of that name is refused.
Gene-name pattern ^mt- A prefix (such as GRCh38_) or a regular expression.
Match mode regex prefix or regex. A regex matches anywhere in the name unless anchored with ^.

For species, a boolean column per genome (for example human from the prefix GRCh38_) lets you compute per-species QC percentages, or restrict another analysis to one genome's genes with a gene-subset pill.

Tips and pitfalls

Order matters

Add the species column before stripping prefixes. Once the prefixes are gone, nothing in the gene names says which genome a gene came from, and Sum species counts (by name) and Detect species prefixes no longer find anything.

Add species column is not in the analysis record

The other steps on this page are recorded and replayed by the notebook export; Add species column (.var) is not. A notebook made from such a session needs that step added by hand before Sum species counts (from .var).

Sum raw counts

The species sums read the counts layer by default. If your raw counts are in .X and there is no counts layer, they fall back to .X; if .X has been normalized, the shares are of normalized values, which shifts the purity call.