Module 1 · From DNA to array data · step 10 of 11
1.10The formats you will meet most often
Related pages: File formats (small example files for every format) and Lecture slides.
In short
We read small invented examples to learn what common genetic file fields mean. We examine example conversion commands without running them, so we can understand what conversions preserve and what they may lose.
What you do
Command
No code to run. This is a reading-only step. The shell examples are in the "Example syntax, do not run" boxes.
You need
Step 1.9 and the linked invented examples. No classroom data or password is needed.
What we do
Reading, about 9 minutes. You can come back to it later.
Read fields in tiny invented examples. Conversion commands below are examples to read, not instructions to run.
Why
The files in examples/formats (opens in a new tab) are labelled invented example. S1 to S4 are invented samples. S3 has unknown sex. Five two-allele SNPs have invented GRCh38-style positions on chromosomes 1, 2 and X. One genotype is missing. S1 is male and has one allele copy at these X sites. Two reads belong to the separate 60-base contig toy1.
A header (opens in a new tab) describes a file before its records. Magic bytes (opens in a new tab) are patterns that identify some binary encodings. The supplied binary files have .hex.txt companions showing their first bytes.
FASTQ
Open the read example (opens a file viewer). Each read occupies four lines.
| Field | Meaning |
|---|---|
| Identifier line | Starts with @, then the read name and an optional description. |
| Sequence line | The measured DNA bases. |
| Separator line | Starts with +. |
| Quality line | One quality character per sequence base. |
Phred quality (opens in a new tab) describes an estimated base-error probability. In Phred+33 encoding, I means quality 40.
Common mistakes
- The quality line must have the same length as the sequence.
- Base quality describes a base call, not confidence in its genomic placement.
Alignment software takes reads and a reference, then produces alignment records.
FASTA and FAI
Open the reference (opens a file viewer) and its index (opens a file viewer).
| Field | Meaning |
|---|---|
| FASTA header | Starts with > and names the sequence, here toy1. |
| FASTA sequence | The bases belonging to that named sequence. |
| FAI name | The sequence identifier. |
| FAI length | Number of bases in the sequence. |
| FAI offset | Byte position of the first sequence base, counting from zero. |
| FAI line bases | Number of sequence bases per full line. |
| FAI line width | Bytes per full line, including newline characters. |
Common mistakes
- Changing FASTA line breaks can invalidate its byte offsets.
- A reference name alone does not prove that two sequences match.
SAM, BAM, CRAM and unaligned BAM
Read the SAM example (opens a file viewer). BAM stores the same logical fields in binary. CRAM compresses read records, often against a reference. uBAM (opens in a new tab) stores reads before genomic alignment.
| Field | Meaning |
|---|---|
@HD | Header line giving the format version and declared sort order. |
@SQ | Header line naming a reference sequence and its length. |
@CO | Header comment. |
QNAME | Read name. |
FLAG | Bit flags (opens in a new tab) combining alignment properties. |
RNAME | Reference name, or * without a placement. |
POS | One-based alignment start, or zero without a placement. |
MAPQ | Mapping quality, distinct from individual base qualities. |
CIGAR | Operations describing how read and reference bases align. |
RNEXT | Mate reference name; * when unavailable. |
PNEXT | Mate position; zero when unavailable. |
TLEN | Template length; zero when unavailable. |
SEQ | Read bases. |
QUAL | Encoded base qualities. |
| Optional tags | Extra fields written as TAG:TYPE:VALUE. |
The example reads are unpaired. FLAG zero means an unpaired forward alignment with no flags set. A CIGAR (opens in a new tab) of 4M1I5M describes four aligned bases, one inserted read base, then five aligned bases.
Common mistakes
- A BAM file can be unaligned. Its extension does not prove genomic placement.
- CIGAR
Mdoes not distinguish a matching base from a mismatch. - CRAM may need the exact reference used to encode it. Its index must match the current file.
samtools view -b -o reads.bam invented_example_alignments.sam
samtools sort -o sorted.bam reads.bam
samtools index sorted.bam
view -b writes BAM. -o names the output. sort orders records by coordinate. index creates the region index. These operations do not call variants.
VCF and gVCF
Read the multi-sample VCF (opens a file viewer), gVCF (opens a file viewer) and dosage VCF (opens a file viewer). Lines beginning with ## declare metadata. A single-hash header names the columns.
| Field | Meaning |
|---|---|
CHROM | Chromosome or contig name. |
POS | One-based position of the first reference base. |
ID | Variant identifier. |
REF | Reference allele. |
ALT | Alternative allele or alleles. |
QUAL | Variant quality. |
FILTER | Filter status; PASS means no listed filter failed. |
INFO | Site annotations declared in the header. |
FORMAT | Names and order of fields in each sample column. |
| Sample columns | Values for that sample, following FORMAT. |
GT (sample field) | Allele indices (opens in a new tab): zero is REF and one is the first ALT. |
DS (sample field) | Dosage (opens in a new tab), the expected ALT count. |
GP (sample field) | Genotype probabilities (opens in a new tab). |
R2 (INFO field) | An imputation-quality annotation whose definition depends on its producer. |
END (INFO field) | Last included position of a gVCF reference block. |
A dot marks missing information. 0/1 means REF/first ALT; ./. is missing. A slash leaves allele order unknown. A vertical bar records phase (opens in a new tab), the arrangement across chromosome copies. A gVCF reference block uses <NON_REF> and END to represent a non-variant stretch.
For diploid calls, GP lists 0/0,0/1,1/1. Then DS = GP(0/1) + 2 * GP(1/1). For S1 on X, GP lists 0,1 and DS equals GP(1).
Common mistakes
PASSdoes not prove a correct genotype.- REF/ALT order must agree with the stated genome build.
- Rounding dosage discards uncertainty. A dosage of one need not be a certain heterozygote.
plink2 --vcf invented_example_multisample.vcf --double-id --update-sex invented_example_plink2.psam --make-pgen --out converted
--vcf selects the input. --double-id sets both PLINK identifiers from each sample name. --update-sex reads sex metadata. --make-pgen creates the native trio. --out sets its prefix. To import DS instead of calls, --vcf additionally needs the documented dosage=DS modifier.
Illumina Final Report, IDAT and GTC
Open the Final Report (opens a file viewer). IDAT holds earlier scanner intensities. GTC holds binary calls and related measurements. DRAGEN Array (opens in a new tab) can convert GTC to VCF.
| Field | Meaning |
|---|---|
[Header] | Introduces file information. |
[Data] | Introduces the measurement table. |
SNP Name | Array marker identifier. |
Sample ID | Sample identifier. |
Allele1 - Forward | First called allele on the declared forward strand. |
Allele2 - Forward | Second called allele on that strand. |
GC Score | Calling confidence. |
X | First illustrative normalised intensity. |
Y | Second illustrative normalised intensity. |
Common mistakes
- GC Score is not a disease probability.
- "Forward" is Illumina's dbSNP (opens in a new tab)-based forward strand. It is not always the GRCh38 plus strand. See 2.5.
- Actual exports can select different columns. Check the header before importing.
- Missing calls use
-here. Strand labels need the matching manifest and the checks at 2.5.
Conversion to analysis files depends on the selected export columns and manifest.
PLINK 1 text and binary sets
Inspect PED (opens a file viewer), MAP (opens a file viewer), TPED (opens a file viewer), TFAM (opens a file viewer), BIM (opens a file viewer) and FAM (opens a file viewer). The binary PLINK BED (opens a file viewer) stores calls. Compare it with UCSC BED (opens a file viewer), a text interval file: the shared extension is a classic source of confusion.
| Field | Meaning |
|---|---|
| FID | Family identifier in FAM, TFAM and PED. |
| IID | Individual identifier in those files. |
| Father ID | Father identifier; zero means unknown. |
| Mother ID | Mother identifier; zero means unknown. |
| Sex | In FAM/TFAM/PED: 1 male, 2 female, 0 unknown. |
| Phenotype | In case-control data, 1 is control and 2 is case. -9 is missing. |
| Allele pairs | Two alleles per variant in PED, or per sample in TPED; 0 0 means missing. |
| Chromosome | First variant field in MAP, TPED and BIM. |
| Variant ID | Second variant field. |
| Genetic distance | Distance in centimorgans (opens in a new tab), units based on inherited chromosome exchanges. Zero when no genetic map is supplied. |
| Base-pair position | Fourth variant field, counting from one. |
| A1 and A2 | Two extra BIM fields naming the stored alleles. |
| BED bytes | Packed calls; this variant-major file starts 6c 1b 01. |
Common mistakes
- Keep each companion set together and preserve its sample and variant order.
- PLINK 1.9 often uses A1/A2 as minor/major labels. Those describe sample frequencies, not genomic REF/ALT.
- A PLINK BED cannot be read as a UCSC interval table.
plink2 --bfile invented_example_plink1 --make-pgen --out converted
--bfile reads the BED/BIM/FAM prefix. --make-pgen creates PGEN/PVAR/PSAM. --out sets the new prefix.
PLINK 2 native sets
Read PVAR (opens a file viewer) and PSAM (opens a file viewer) alongside PGEN (opens a file viewer).
| Field | Meaning |
|---|---|
PVAR CHROM | Chromosome. |
PVAR POS | One-based position. |
PVAR ID | Variant identifier. |
PVAR REF | Reference allele. |
PVAR ALT | Alternative allele. |
PVAR FILTER | Optional filter status, included in this example. |
PSAM FID | Family identifier. |
PSAM IID | Individual identifier. |
PSAM SEX | Sex code; NA means unknown here. |
| PGEN bytes | Genotypes and optionally dosages; starts 6c 1b, then storage-mode information. |
Common mistakes
- A reference allele imported from BIM can remain provisional. Conversion does not check it against GRCh38.
- Column names matter. Read the PVAR and PSAM headers rather than assuming an order.
BGEN
Inspect the BGEN bytes (opens a file viewer) and sample table (opens a file viewer). This BGEN 1.2 example encodes the supplied calls as certainty, with eight bits per probability.
| Field | Meaning |
|---|---|
| Binary header | Variant/sample counts and encoding flags. |
bgen signature | Format marker at byte offset 16. |
| Variant records | Variant identifiers, chromosome, position and alleles. |
| Probability data | Encoded genotype probabilities and chromosome-copy counts. |
ID_1, ID_2 | The two identifiers in the sample table. |
missing | Fraction of missing calls in this export. |
sex | Sex code; NA is unknown here. |
| Sample type row | Second row declaring column types. |
.bgi companion | Index used to retrieve variants from the matching BGEN. |
Common mistakes
- Do not assume allele order. Declare the order documented by the producer.
- BGEN layout and probability precision affect decoding. Use the specification (opens in a new tab).
- An index must match the BGEN file it describes.
plink2 --bgen invented_example.bgen ref-first --sample invented_example.sample --make-pgen --out converted
--bgen selects the file. ref-first declares that its first allele is reference. --sample supplies sample descriptions. --make-pgen and --out select the output trio and prefix.
Summary statistics
Open the summary table (opens a file viewer). Its effects and uncertainties are invented. Step 6.8 creates the classroom table.
| Field | Meaning |
|---|---|
chromosome | Chromosome label. |
base_pair_location | One-based position. |
variant_id | Variant identifier. |
effect_allele | Allele whose effect is reported (opens in a new tab). |
other_allele | The other allele. |
effect_allele_frequency | Fraction of called alleles (opens in a new tab) matching the effect allele. |
odds_ratio | Effect on disease odds (opens in a new tab), the probability of disease divided by the probability of no disease. |
beta | Natural logarithm (opens in a new tab) of the odds ratio. |
standard_error | Uncertainty of beta (opens in a new tab) on its log-odds scale. |
p_value | Evidence against the tested null model (opens in a new tab) of no association. |
n | Number of samples with a called genotype in this example. |
Common mistakes
- Read beta with its effect allele, scale and genome build.
- A missing effect is not zero.
- GWAS-SSF (opens in a new tab) submissions also need defined study metadata.
References: FASTQ, PMID 20015970 (opens in a new tab); SAM/BAM, PMID 19505943 (opens in a new tab); CRAM, PMID 21245279 (opens in a new tab); CRAM 3.1, PMID 34999766 (opens in a new tab); VCF, PMID 21653522 (opens in a new tab); GATK, PMID 20644199 (opens in a new tab); PLINK, PMID 17701901 (opens in a new tab); second-generation PLINK, PMID 25722852 (opens in a new tab); SAMtools/BCFtools, PMID 33590861 (opens in a new tab); BGEN, DOI 10.1101/308296 (opens in a new tab).
Expected result
Show the expected result
You can explain the header and fields of each example. The genotype files describe five variants, four samples and one missing genotype.
If something goes wrong
If something goes wrong
A binary file will not look like a readable table. Use the description and byte view shown next to the example. The illustrative conversion outputs are not needed for any later step.
Quick check
An imputed sample has probabilities 0.1, 0.8, 0.1. What is its ALT dosage, and is that a certain heterozygous call?
Show the answer
The dosage is 0.8 + 2 * 0.1 = 1. It is not certainty: the two homozygous possibilities still have probability 0.1 each.
Files created
None. The supplied examples are separate reading aids.