| Branch | ![]() |
![]() |
|---|---|---|
master |
||
develop |
Work with PLINK and PLINK2 from R.
- Doing the first PLINK example: YouTube download (.ogv)
- Detect an association with one or more quantitative traits: YouTube download (.ogv)
- Detect an association with ideal quantitative traits: YouTube download (.ogv)
- Simulate quantitative traits: YouTube download (.ogv)
- Simulate custom traits: YouTube download (.ogv)
- Detect an association with a binary trait/case-control phenotype: YouTube download (.ogv)
See doc/install.md
plinkr can seamlessly run any PLINK or PLINK2 versions.
Run PLINK:
library(plinkr)
run_plink("--help")To call a specific version of PLINK:
run_plink(c("--help", "--noweb"), create_plink_v1_7_options())
run_plink("--help", create_plink_v1_9_options())
run_plink("--help", create_plink_v2_0_options())Of course, you can also call PLINK to detect genetic associations :-) :
# Use the PLINK v1.9 example files
plink_v1_9 <- create_plink_v1_9_options()
ped_filename <- get_plink_example_filename("toy.ped", plink_v1_9)
map_filename <- get_plink_example_filename("toy.map", plink_v1_9)
# Do a case-control association
plinkr::run_plink(
args = c(
"--ped", ped_filename,
"--map", map_filename
)
)- See the vignette
basic_usagefor basic usage of PLINK, as taken from the PLINK website, which shows a quantitative trait analysis - See the vignette
test_assoc_qtfor the same basic usage of PLINK, using theplinkrinterface - See the vignette
demo_assoc_qtfor doing a quantitative trait analysis using simulated data and theplinkrinterface
assoc_qt_data <- create_assoc_qt_data(
data = create_plink_text_filenames(
map_filename = get_plinkr_filename("demo_assoc_qt.map"),
ped_filename = get_plinkr_filename("demo_assoc_qt.ped")
),
phenotype_data = create_phenotype_data_filename(
phe_filename = get_plinkr_filename("demo_assoc_qt.phe")
)
)
assoc_qt_filenames <- assoc_qt(assoc_qt_data = assoc_qt_data)
read_plink_qassoc_file(assoc_qt_filenames$qassoc_filenames[1])assoc_qt_data <- create_assoc_qt_data(
data = create_plink_bin_filenames(
bed_filename = get_plinkr_filename("demo_assoc_qt.bed"),
bim_filename = get_plinkr_filename("demo_assoc_qt.bim"),
fam_filename = get_plinkr_filename("demo_assoc_qt.fam")
),
phenotype_data = create_phenotype_data_filename(
phe_filename = get_plinkr_filename("demo_assoc_qt.phe")
)
)
assoc_qt_filenames <- assoc_qt(assoc_qt_data = assoc_qt_data)
read_plink_qassoc_file(assoc_qt_filenames$qassoc_filenames[1])plinkr can seamlessly use PLINK/PLINK2 in-memory-data or files.
assoc_qt_data <- create_demo_assoc_qt_data()
# Prove that this is PLINK text data
check_plink_text_data(assoc_qt_data$data)
assoc_qt_params <- create_test_assoc_qt_params()
assoc_qt(
assoc_qt_data = assoc_qt_data,
assoc_qt_params = assoc_qt_params
)To convert the in-memory data to PLINK binary format and do the same quantitative trait analysis:
assoc_qt_data$data <- convert_plink_text_data_to_plink_bin_data(
assoc_qt_data$data
)
# Prove that this is PLINK binary data
check_plink_bin_data(assoc_qt_data$data)
assoc_qt(
assoc_qt_data = assoc_qt_data,
assoc_qt_params = assoc_qt_params
)- See the vignette
demo_assoc_qtfor a walk-through of the data that is simulated by default - See the vignette
create_demo_assoc_qt_paramsfor many examples how data can be simulated
plinkr can read and save many types of PLINK files. Below is an
overview. List from the PLINK file format
reference.
| File extension | plink read function |
|---|---|
.adjusted |
read_plink_adjusted_file |
.allele.no.snp |
π§ |
.assoc |
read_plink_assoc_file |
.assoc.adjusted |
read_plink_assoc_adjusted_file |
.assoc.dosage |
π§ |
.assoc.fisher |
π§ |
.assoc.linear |
π§ |
.assoc.logistic |
π§ |
.auto.R |
π§ |
.bcf |
π§ |
.beagle.dat |
π§ |
.bed |
read_plink_bed_file |
.bim |
read_plink_bin_file |
| PLINK binary data | read_plink_bin_data |
| PLINK2 binary data | read_plink2_bin_data |
.blocks* |
π§ |
.chr-*.dat |
π§ |
.chr-*.map |
π§ |
.clst |
π§ |
.clumped* |
π§ |
.cluster* |
π§ |
.cmh |
π§ |
.cmh2 |
π§ |
.cnv |
π§ |
.cnv.indiv |
π§ |
.cnv.overlap |
π§ |
.cnv.summary |
π§ |
.cov |
read_plink_cov_file |
.dfam |
π§ |
.diff |
π§ |
.dist |
π§ |
.dupvar |
π§ |
.eigenvec* |
π§ |
.epi.* |
π§ |
.fam |
read_plink_fam_file |
.flipscan |
π§ |
.frq |
read_plink_frq_file |
.frq.cc |
π§ |
.frq.count |
π§ |
.frq.strat |
read_plink_frq_strat_file |
.frqx |
π§ |
.fst |
π§ |
.gen |
π§ |
.genome |
π§ |
.grm |
π§ |
.grm.N.bin |
π§ |
.grm.bin |
π§ |
.gvar |
π§ |
.het |
π§ |
.hh |
π§ |
.hom |
π§ |
.hom.indiv |
π§ |
.hom.overlap* |
π§ |
.hom.summary |
π§ |
.homog |
π§ |
.hwe |
π§ |
.ibc |
π§ |
.imiss |
read_plink_imiss_file |
.info |
π§ |
.lasso |
π§ |
.ld |
read_plink_ld_file |
.ldset |
π§ |
.lgen |
π§ |
.list |
π§ |
.lmiss |
read_plink_lmiss_file |
.log |
read_plink_log_file |
.map |
read_plink_map_file |
.mdist |
π§ |
.mdist.missing |
π§ |
.mds |
π§ |
.*mendel |
π§ |
.meta |
π§ |
.mibs |
π§ |
.missing |
π§ |
.missing.hap |
π§ |
.model |
π§ |
.mperm |
π§ |
.nearest |
π§ |
.occur.dosage |
π§ |
.out.dosage |
π§ |
.ped |
read_plink_ped_file |
.perm |
π§ |
.phe |
read_plink_phe_file |
.pphe |
π§ |
.prob |
π§ |
.profile |
π§ |
.qassoc |
read_plink_qassoc_file |
.qassoc.gxe |
π§ |
.qassoc.means |
π§ |
.qfam.* |
π§ |
.range.report |
π§ |
.raw |
π§ |
.recode.*.txt |
π§ |
.recode.phase.inp |
π§ |
.recode.strct_in |
π§ |
.ref |
π§ |
.rel |
π§ |
.rlist |
π§ |
.sample |
π§ |
.set |
π§ |
.set.{perm,mperm} |
π§ |
.set.table |
π§ |
.sexcheck |
π§ |
.simfreq |
read_plink_simfreq_file |
.tags.list |
π§ |
.tdt |
π§ |
.tdt.poo |
π§ |
| PLINK text data | read_plink_text_data |
.tfam |
π§ |
.tped |
π§ |
.traw |
π§ |
.twolocus |
π§ |
.var.ranges |
π§ |
.vcf |
π§ |
| Association type | Data type | General function | Specialized function |
|---|---|---|---|
| Case-control | PLINK1 text data | assoc |
assoc_on_plink_text_data |
| Case-control | PLINK1 bin data | assoc |
assoc_on_plink_bin_data |
| Case-control | PLINK2 bin data | assoc |
assoc_on_plink2_bin_data |
| Case-control | PLINK1 text files | assoc π§ |
assoc_on_plink_text_files π§ |
| Case-control | PLINK1 bin files | assoc π§ |
assoc_on_plink_bin_files π§ |
| Case-control | PLINK2 bin files | assoc π§ |
assoc_on_plink2_bin_files π§ |
| Quantitative | PLINK1 text data | assoc_qt |
assoc_qt_on_plink_text_data |
| Quantitative | PLINK1 bin data | assoc_qt |
assoc_qt_on_plink_bin_data |
| Quantitative | PLINK2 bin data | assoc_qt |
assoc_qt_on_plink2_bin_data |
| Quantitative | PLINK1 text files | assoc_qt π§ |
assoc_qt_on_plink_text_files π§ |
| Quantitative | PLINK1 bin files | assoc_qt π§ |
assoc_qt_on_plink_bin_files π§ |
| Quantitative | PLINK2 bin files | assoc_qt π§ |
assoc_qt_on_plink2_bin_files π§ |
plinkr allows to convert between any PLINK and PLINK2 files.
| From | To | Function name |
|---|---|---|
| PLINK1 text files | PLINK1 binary files | convert_plink_text_files_to_plink_bin_files |
| PLINK1 text files | PLINK2 binary files | convert_plink_text_files_to_plink2_bin_files |
| PLINK1 binary files | PLINK text files | convert_plink_bin_files_to_plink_text_files |
| PLINK1 binary files | PLINK2 binary files | convert_plink_bin_files_to_plink2_bin_files |
| PLINK2 binary files | PLINK text files | convert_plink2_bin_files_to_plink_text_files π§ |
| PLINK2 binary files | PLINK binary files | convert_plink2_bin_files_to_plink_bin_files |
| π§ | π§ | π§ |
| any type of files | PLINK text files | convert_files_to_plink_text_files π§ |
| any type of files | PLINK1 binary files | convert_files_to_plink_bin_files π§ |
| any type of files | PLINK2 binary files | convert_files_to_plink2_bin_files π§ |
| PLINK1 binary files | SAIGE files | create_bgen_files_for_saige π§ |
| PLINK1 binary files | PLINK2 VCF files | convert_plink_bin_files_to_plink_vcf_files π§ |
plinkr allows to convert between any PLINK and PLINK2 data.
| From | To | Function name |
|---|---|---|
| PLINK1 text data | PLINK1 binary data | convert_plink_text_data_to_plink_bin_data |
| PLINK1 text data | PLINK2 binary data | convert_plink_text_data_to_plink2_bin_data |
| PLINK1 binary data | PLINK text data | convert_plink_bin_data_to_plink_text_data π§ |
| PLINK1 binary data | PLINK2 binary data | convert_plink_bin_data_to_plink2_bin_data |
| PLINK2 binary data | PLINK text data | convert_plink2_bin_data_to_plink_text_data π§ |
| PLINK2 binary data | PLINK binary data | convert_plink2_bin_data_to_plink_bin_data |
See doc/faq.md

