MGHome page

GWAS course

Course map

0 of 64 steps done

Start with step 0.1Install R

Saved in this browser only.

Step 2.3

Module 2 · Files and formats · step 3 of 8

2.3Sample and variant tables

Commands tested on Windows

In short

We read the tables that describe the samples and the DNA sites. We inspect their first rows and check the sample identifiers so we can match information to the right sample.

Do this

You should see: The PSAM file has 2,016 rows and the PVAR file has 299,523 rows.

Command

Module setup, needed before this step

R: module setup

source("R/guided.R")cfg <- guided_init()

R command

Type or paste into the RStudio console.

1samples <- guided_table(paste0(guided_path(cfg, "2.2"), ".psam"))variants <- guided_table(paste0(guided_path(cfg, "2.2"), ".pvar"))2head(samples)head(variants)3check_ids(samples, "Laboratory samples", verbose = TRUE)
  1. Note 1: Read the sample and variant tables from the converted files.
  2. Note 2: Show the first rows of both tables.
  3. Note 3: Check that the sample identifiers are valid and unique.

You need

You need the native files from 2.2.

What we do

We read the sample table and the variant table. We do not change them.

Why

FID and IID are text identifiers, not row numbers. Keep any leading zeros, such as in 007. Always join tables by these identifiers.

The variant table (PVAR) has columns for the chromosome, the position, the site ID and the alleles. An rs identifier (opens in a new tab) can be shared by several resources, even when each resource uses a different genome assembly (a full reference sequence of the genome) for the coordinates. An Illumina name may name an array assay (one test on the chip) and not a unique place in the genome.

PLINK terminal equivalent. Optional: you do not need it for the course.

Not applicable: this step needs no PLINK command. The R code above is the complete command.

R reads the files and shows the values. It does not change the genotype files.

Expected result

Show the expected result

The last line printed is Laboratory samples: no ID problems found. A check that prints nothing can leave you unsure whether it ran, so this message confirms that it ran and passed. The PSAM file has 2,016 rows and the PVAR file has 299,523 rows. Different assay IDs do not prove that every site is unique. Two assays can still test the same place in the genome.

The tested PLINK version is defined in config.R and recorded in software_versions.txt. Validation: executable chunks and the expected counts passed on Windows.

If something goes wrong

If something goes wrong

Stop at the first error message. Check the input file named in the message. Check that the previous step finished. Keep the command and the console output (the text printed in R). Do not use files from a different version of the dataset. See troubleshooting (opens in a new tab).

Quick check

Should you join two tables by row number when they have the same length?

Show the answer

No. Match the FID/IID pair or the site identifier. Then check that every required record found its match.

Files created

None.