Introduction, downloads

D: 6 Dec 2024

Recent version history

What's new?

Coming next

[Jump to search box]

General usage

Getting started

Flag usage summaries

Column set descriptors

Citation instructions

Standard data input

PLINK 1 binary (.bed)

PROVISIONAL_REF?

PLINK 2 binary (.pgen)

Autoconversion behavior

VCF/BCF (.vcf[.gz], .bcf)

Oxford genotype (.bgen)

Oxford haplotype (.haps)

PLINK 1 text (.ped, .tped)

PLINK 1 dosage

Sample ID conversion

Dosage import settings

Generate random

Unusual chromosome IDs

Allele frequencies

Phenotypes

Covariates

'Cluster' import

Reference genome (.fa)

Input filtering

Sample ID file

Variant ID file

Interval-BED file

--extract-col-cond

QUAL, FILTER, INFO

Chromosomes

SNPs only

Simple variant window

Multiple variant ranges

Deduplicate variants

Sample/variant thinning

Pheno./covar. condition

Missingness

Category subset

--keep-col-match

Missing genotypes

Number of distinct alleles

Allele frequencies/counts

Hardy-Weinberg

Imputation quality

Sex

Founder status

Main functions

Data management

--make-[b]pgen/--make-bed

--export

--output-chr

--split-par/--merge-par

--set-all-var-ids

--recover-var-ids

--update-map...

--update-ids...

--ref-allele

--ref-from-fa

--normalize

--indiv-sort

--write-covar

--variance-standardize

--quantile-normalize

--split-cat-pheno

--pheno-svd

--pmerge[-list]

--write-samples

Basic statistics

--freq

--geno-counts

--sample-counts

--missing

--genotyping-rate

--hardy

--het

--check-sex/--impute-sex

--fst

--pgen-info

Pairwise diffs

--pgen-diff

--sample-diff

Linkage disequilibrium

--indep...

--r[2]-[un]phased

--ld

Sample-distance matrices

Relationship/covariance

  (--make-grm-bin...)

--make-king...

--king-cutoff

Population stratification

--pca

PCA projection

Association analysis

--glm

--glm ERRCODE values

--gwas-ssf

--adjust-file

Report postprocessing

--clump

Linear scoring

--score[-list]

--variant-score

Distributed computation

Command-line help

Miscellaneous

Flag/parameter reuse

System resource usage

--loop-cats

.zst decompression

Pseudorandom numbers

Warnings as errors

.pgen validation

Resources

1000 Genomes phase 3

HGDP-CEPH

FASTA files

Errors and warnings

Output file list

Order of operations

Developer information

GitHub root

Python library

R library

Compilation

Adding new functionality

Discussion forums

Credits

File formats

Tutorials

Setup

Rules of Thumb

Data Exploration 1 — HWE, Allele Frequency Spectrum

Data Exploration 2 — Genomic Structure

Linkage

Relationship Matrix

Genome-Wide Assocation Analyses (GWAS)

Regressions

Post-Hoc

Formatting Files

bcftools

Variant IDs

Reference Alleles

Format for R

Shortcuts

Quick index search

Plink 2 Tutorial Setup

About the tutorials

These exercises are intended to introduce concepts in genomic analyses and provide some examples for exploring/implementing them using Plink 2. They are not exhaustive How-To's. However, they are a good start for learning the functionalities of Plink 2.

About this document

Setting up plink2, the directory structure, and tutorial files needed to run the tutorials.

Part 1: Setup the directory structure with tutorial files

Download the Plink 2 Tutorial package to a directory that you want to run your analyses from. Decompress the downloaded plink2tut.tar.gz file in this directory. You should see this folder structure.


Part 2: Analysis environment: Plink 2 + R

This tutorial is intended such that Plink 2 is run in a terminal alongside R commands for visualization. Shown below is an example using R Studio where we navigate between the R Studio (command-line, shell) Terminal and the R Console panes. It will look like this.

Under the /GWAS/R/ folder you will find a file called install_packages.R . Once R is installed, run this file to check and install packages.

In the R Console run:

setwd("<path to project1>") source("../R/install_packages.R")

Usage Note: All tutorial exercises expect that you are in the project1 folder, both in the Terminal and R Console.

Part 3: Command-line

Plink is intended to run using a shell terminal. If you are not familiar with shell programming and command lines, then we suggest going through The Missing Semester of Your CS Education, particularly the first 5 lessons.

Part 4: Add Plink to PATH

We have included tutorial-compatible Plink 2 (PLINK v2.00a6) and 1.9 (PLINK v1.90b7.4) executables for macOS M1 in the /GWAS/bin/ folder. If you are not using macOS M1, then you need to download the corresponding Plink 2 and 1.9 executables (minimum versions as above) for your system and rename them as plink2 and plink19 respectfully. In addition, if these are not part of your global path (which is unlikely due to renaming), then add these to the global shell path. Get the absolute path by navigating to the /GWAS/bin folder in a Terminal and run the command: pwd. Use the returned path with the name of executable below.

Identify the type of terminal shell your are using by running this in the command line.

ps -p $$

Then add the path to plink 2 or 1.x that you copied above by adding this to the profile file.

export PATH="<path-to-plink><name of executable>:$PATH"

For example, if zsh then open and add using.

nano ~/.zshrc

If bash, then

nano ~/.bash_profile

or

nano ~/.bashrc

Part 5: Miscellany

curl

Instructions for listing and downloading from FTP site using curl. Ensembl example.

  1. List the files in the directory.
    Use the following command to list the files from the FTP directory:

    curl -l ftp://ftp.ensembl.org/pub/current_gff3/homo_sapiens/

  2. Set a shell variable to one of the file names.
    Once you have the list of files, set a shell variable to the desired file name.
    For example, if the file you want to download is Homo_sapiens.GRCh38.113.chromosome.22.gff3.gz, set a variable like this:

    FILE="Homo_sapiens.GRCh38.113.chromosome.22.gff3.gz"

  3. Specify the target directory:

    TARGET_DIR="./misc/"

  4. Download the file using curl -o and save it in the target directory

    curl -o "$TARGET_DIR/$FILE" ftp://ftp.ensembl.org/pub/current_gff3/homo_sapiens/$FILE

  5. Rules of Thumb >>