Skip to content
@skiffyard/genotf

Reading GeneMapper and Peak Scanner tables

GeneMapperâ„¢ (GeneMapper, GeneMapper ID, GeneMapper ID-X) exports its tables as tab-delimited text: the Genotypes table, one row per sample and marker, and the Sizing table, one row per peak. Peak Scannerâ„¢ exports the same Sizing table, with columns of its own. gmtable reads both kinds.

jennifer
import "@skiffyard/genotf/gmtable.j" as gmtable;

def t as gmtable.Table init gmtable.open("Genotypes Table.txt");
io.printf("%s: %d columns, %d rows\n", $t.kind, len($t.columns), len($t.rows));

read / open return the table as text, header and cells. kind says what it is: "genotypes" (a Marker and an Allele 1 column), "sizing" (a Dye/Sample Peak column) or "". cell(t, row, name) reads one cell by column name.

Columns are found by name

Which columns a table has, and their order, depends on the table settings the user exported with and on the program's version. gmtable never reads a column by position:

ColumnsBecome
Allele n, Size n, Height n, Peak Area n (or Area n), Data Point nGenotype.peaks[n - 1], one Peak per number
Sample File (Sample File Name, Sample Filename), Sample Name, Panel, Marker, DyeGenotype fields
Dye/Sample Peak, Allele, Size, Height, Area (Area in Point), Data PointSizedPeak fields
every other column (Run Name, Well, the quality flags ADO AE ... GQ, user columns UD1 ...)fields, by header name, as text

A missing column reads as empty. GeneMapper ends every line with a tab; the empty column that makes is dropped.

Genotypes

jennifer
for (def g in gmtable.genotypes($t)) {
    for (def p in $g.peaks) {
        io.printf("%s\t%s\t%s\t%f|prec=2\t%d\n", $g.sampleName, $g.marker, $p.allele, $p.sizeBp, $p.height);
    }
}
In the fileIn Peak
an empty number cell, or no such column-1 / -1.0
OL (off-ladder, the HID analysis)allele "OL", offLadder true
? (a peak in no bin, the other analyses)allele "?", offLadder true
a size and height without an allele nameallele ""
a number whose cells are all emptyno Peak

A homozygote is a row with one allele. Quality flags stay text in fields: their values differ between versions (false, FALSE, 0.0, -1.0 for not applied, -2.0 for not computed).

Sizing tables

jennifer
def sized as gmtable.Table init gmtable.open("Sizing Table.txt");
for (def p in gmtable.sizing($sized)) {
    if ($p.sizeStandard) {
        continue;
    }
    io.printf("%s,%d\t%f|prec=2\t%d\n", $p.dye, $p.peak, $p.sizeBp, $p.height);
}

Dye/Sample Peak ("B,1") gives dye and peak; a trailing * ("R,1 *") marks a peak the size standard was matched to (sizeStandard). A peak outside the sized range has an empty size (sizeBp -1.0). Peak Scanner's extra columns (Status, Size Standard, Area in BP, Begin Point, Width in BP, ...) are in fields.

To forensicgenetics profiles

typings groups genotype rows by sample file (two injections of one sample stay apart) and lists the alleles per marker, leaving out empty and off-ladder ones. A genotf.Typing's loci is the shape @deckyard/forensicgenetics takes for a mixture; a profile takes a pair per locus:

jennifer
import "@skiffyard/genotf/" as genotf;
import "@deckyard/forensicgenetics/" as fg;

for (def ty in gmtable.typings(gmtable.genotypes($t))) {
    def m as fg.Mixture init fg.mixture($ty.sample, $ty.loci);
    def pairs as list of fg.Genotype init [];
    for (def locus in $ty.loci) {
        def a as list of string init $ty.loci[$locus];
        if (len($a) <= 2) {
            # one allele: a homozygote (or a dropout: the caller's judgement)
            $pairs[] = fg.genotype($locus, $a[0], $a[len($a) - 1]);
        }
    }
    def p as fg.Profile init fg.profile($ty.sample, $pairs);
}

genotf does not depend on @deckyard/forensicgenetics; add it to the consuming project for this.

Text

Tables are read as UTF-8 (a byte-order mark is skipped), or as Windows-1252 when they are not valid UTF-8, which is what GeneMapper on Windows writes for names with accents. Line ends are CRLF or LF. A cell in double quotes ("B,1", or a cell a spreadsheet saved again) is unquoted.

Errors

Error{kind: "genotf"} for a table with no header, an empty or duplicate column name, a row with another number of cells than the header, a number cell that is no number (or a height or data point that is no whole number), a Dye/Sample Peak cell that is no dye,number pair, and genotypes / sizing of the other kind of table.