### Example: Importing a 23andMe File Source: https://www.cog-genomics.org/plink/1.9/input An example demonstrating the usage of the --23file command with a specific filename and custom IDs. This command initiates the process of loading and converting the 23andMe data. ```bash plink --23file genome.txt Chang Christopher --out plink_genome ``` -------------------------------- ### PLINK 1.9 Basic Frequency Calculation Example Source: https://www.cog-genomics.org/plink/1.9/general_usage This example demonstrates how to perform a basic allele frequency calculation using PLINK 1.9. It takes a 'toy' dataset, calculates frequencies, and outputs the results to 'toy_analysis.frq'. Ensure you have the correct PLINK 1.9 binary for your system. ```bash ./plink --file toy --freq --out toy_analysis ``` -------------------------------- ### Input File and Format Options Source: https://www.cog-genomics.org/plink/1.9/index Options related to input files and their formats. ```APIDOC ## Input File and Format Options ### Description Options related to input files and their formats. ### --mendel-duos #### Description Make --me/--mendel consider samples with only one parent in the dataset. ### --mendel-multigen #### Description Make --me/--mendel consider (great-)grandparents when parental data is missing. ### --mishap-window #### Description Provisionally retired; let us know if you need this. ### --missing-code #### Description Specify missing phenotype values in Oxford-formatted input. ### --missing-genotype #### Description Specify missing genotype code in input. ### --missing-genotype2 #### Description Specify additional missing genotype code in input .bim files. ### --missing-phenotype #### Description Specify missing phenotype code in input. ### --mouse #### Description Specify mouse chromosome set. ### --mpheno #### Description Specify the column number to load in the --pheno file. ### --must-have-sex #### Description Force ambiguous-sex phenotypes to missing in --make-bed/--recode output. ### --mwithin #### Description Specify column to read --within cluster assignments from. ### --native #### Description Allow Intel MKL to use processor-dependent code paths. ### --no-fid #### Description Specify that main input .fam/.ped file does not have a family ID column. ### --no-parents #### Description Specify that main input .fam/.ped file does not have parental ID columns. ### --no-pheno #### Description Specify that main input .fam/.ped file does not have a phenotype column. ### --no-sex #### Description Specify that main input .fam/.ped file does not have a sex column. ### --no-snp #### Description Deprecated. Use e.g. "--linear no-snp". ### --no-x-sex #### Description Deprecated. Use e.g. "--linear no-x-sex". ### --nop #### Description Deprecated. Use "--fast-epistasis nop". ### --not-chr #### Description Exclude all variants on the specified chromosomes. ### --nudge #### Description Deprecated. Use "--genome nudge". ### --oblig-clusters #### Description Deprecated. Use just --oblig-missing. ### --out #### Description Specify filename prefix to use for all output files. ### --output-chr #### Description Specify chromosome coding scheme in output files. ### --output-min-p #### Description Specify minimum p-value to write to reports. ### --output-missing-genotype #### Description Specify missing genotype code to use in files generated by --make-bed/--recode. ### --output-missing-phenotype #### Description Specify missing phenotype code to use in files generated by --make-bed/--recode. ### --oxford-pheno-name #### Description Specify name of phenotype to import from .sample file. ### --oxford-single-chr #### Description Specify single-chromosome .gen file with ignorable first column. ### --p2 #### Description Provisionally retired; let us know if you need this. ### --parallel #### Description Split a computation into many parts and complete one of them. ### --parameters #### Description Exclude covariates/interactions from --linear/--logistic model. ### --parentdt{1,2} #### Description Deprecated. Use e.g. "--tdt exact mperm= parentdt1". ### --ped #### Description Specify full name of input .ped file. ### --perm #### Description Deprecated. Use e.g. "--model perm". ### --perm-batch-size #### Description Set number of permutations per batch for some permutation tests. ### --perm-count #### Description Deprecated. Use e.g. "--model perm-count". ``` -------------------------------- ### Analyzing Distributed Distance Matrix with PLINK Source: https://www.cog-genomics.org/plink/1.9/parallel This snippet shows how to load a pre-computed, distributed distance matrix into PLINK using the --read-dists option and then perform regression analysis with --regress-distance. This is a follow-up step after the distributed calculation of the distance matrix. ```bash plink --bfile test_data --read-dists result.dist.bin --regress-distance ``` -------------------------------- ### Secondary Input: Relationship Matrix Source: https://www.cog-genomics.org/plink/1.9/input2 Commands for loading pre-computed relationship matrices. ```APIDOC ## Secondary input: Relationship matrix ### --grm-gz [prefix] Accepts a prefix (default 'plink') for a .grm.gz + .grm.id fileset. ### --grm-bin [prefix] Loads a .grm.bin + .grm.N.bin + .grm.id fileset. At present, only the --rel-cutoff and --unrelated-heritability flags can act on this input. With --rel-cutoff, only a .grm.id file containing the pruned individual set is generated by default. To also obtain the corresponding relationship matrix, add --make-grm-gz or --make-grm-bin. ``` -------------------------------- ### Setting Output File Prefix in PLINK Source: https://www.cog-genomics.org/plink/1.9/general_usage This command demonstrates how to set a custom prefix for PLINK output files using the --out flag. This is crucial for managing results from multiple runs and avoiding data overwrites. The example shows the correct syntax and the error message generated when the parameter is missing. ```bash # Example of setting a custom output file prefix ./plink --file toy --freq --out toy_analysis # Example of incorrect usage (missing parameter) ./plink --file toy --freq --out ``` -------------------------------- ### Generate Gene Range Lists (awk, cut, grep, nsort, interval_merge) Source: https://www.cog-genomics.org/plink/1.9/resources This snippet demonstrates the pipeline used to generate gene range lists from UCSC Table Browser RefSeq track data. It involves several Unix utilities to process, filter, and format gene information. ```shell tail -n +2 ucscdl-hgxx | awk '{print $3 " " $5 " " $6 " " $13}' | cut -c 4- | grep -E '^.{1,2}\ ' | awk '{print $4 " " $1 " " $2 " " $3}' | nsort | interval_merge > glist-hgxx ``` -------------------------------- ### Generate BIM or FAM Index Files (--make-just-bim, --make-just-fam) Source: https://www.cog-genomics.org/plink/1.9/data These commands are variants of --make-bed used to generate only the .bim or .fam index files, respectively. They do not require a .bed file as primary input, but using them without careful consideration can lead to desynchronization between genotype data and index files. It is generally recommended to use --make-bed unless there is a specific need for these specialized commands. ```bash plink --file input_fileset --make-just-bim --out output_bim ``` ```bash plink --file input_fileset --make-just-fam --out output_fam ``` -------------------------------- ### Format Text Tables with 'prettify' Utility Source: https://www.cog-genomics.org/plink/1.9/other Explains the usage of the 'prettify' utility for formatting tab-and/or-space-delimited text tables into space-delimited, pretty-printed versions. It details various flags for alignment, spacing, and handling of lines and blank entries. ```bash prettify {flag(s)...} [input filename] {output filename} prettify -i -s 4 -r plink.genome.tabs plink.genome2 prettify -ir plink.genome ``` -------------------------------- ### Splitting Variants into Blocks with PLINK Source: https://www.cog-genomics.org/plink/1.9/parallel This snippet illustrates the use of the --write-var-ranges option in PLINK to divide the set of variants into equal-sized blocks. The block boundaries are written to a file named 'plink.var.ranges', which can then be used to distribute simpler jobs by specifying ranges with the --snps option on different machines. ```bash plink --write-var-ranges ``` -------------------------------- ### Other Utility Options Source: https://www.cog-genomics.org/plink/1.9/index Miscellaneous utility options. ```APIDOC ## Other Utility Options ### Description Miscellaneous utility options. ### --min #### Description Specify minimum PI_HAT value for inclusion in --genome report. ### --mfilter #### Description Select covariate to use for --filter. ### --neighbour #### Description Nearest neighbor IBS report. (Useful for outlier detection.) ### --new-id-max-allele-len #### Description Set max # of chars --set-missing-var-ids can use from an allele name. ### --no-const-covar #### Description Exclude constant covariates. ### --nonfounders #### Description Include all samples in MAF/HWE test(s), instead of excluding nonfounders. ### --pca #### Description Extract principal components. ### --pca-cluster-names #### Description Calculate PCs off named clusters, then project remaining samples. ### --pca-clusters #### Description Calculate PCs off clusters named in a file, then project remaining samples. ### --pheno #### Description Load phenotype data from the given file instead of the main input fileset. ``` -------------------------------- ### Distributed Distance Matrix Calculation with PLINK Source: https://www.cog-genomics.org/plink/1.9/parallel This snippet demonstrates how to use the --parallel option in PLINK to compute a distance matrix in a distributed manner. It involves running PLINK twice with different --parallel arguments to generate partial output files, which are then concatenated to form the complete distance matrix file for further analysis. ```bash plink --bfile test_data --distance triangle bin --parallel 1 2 --out result plink --bfile test_data --distance triangle bin --parallel 2 2 --out result cat result.dist.bin.1 result.dist.bin.2 > result.dist.bin ``` -------------------------------- ### Import 23andMe File with PLINK 1.9 Source: https://www.cog-genomics.org/plink/1.9/input This command imports an uncompressed 23andMe-formatted file into PLINK's binary format. Optional parameters include family ID, within-family ID, sex, phenotype, paternal ID, and maternal ID. Default values are used if not specified. Ensure IDs do not contain spaces. ```bash plink --23file [family ID] [within-family ID] [sex] [phenotype] [paternal ID] [maternal ID] --out ``` -------------------------------- ### Generate PLINK Binary Fileset (--make-bed) Source: https://www.cog-genomics.org/plink/1.9/data The --make-bed command creates a new PLINK 1 binary fileset (.bed, .bim, .fam) after applying specified sample and variant filters. It involves temporary file generation, MAF calculation and filtering, and final output creation, ensuring all included data adheres to the specified criteria. Use this command to convert PLINK text filesets or filtered binary filesets into a clean binary format. ```bash plink --file text_fileset --maf 0.05 --make-bed --out binary_fileset ``` -------------------------------- ### Reproducible Monte Carlo Permutation Procedures (PLINK) Source: https://www.cog-genomics.org/plink/1.9/assoc Ensures reproducibility of Monte Carlo permutation procedures by specifying the initial random number seed. Use of --seed is necessary for reproducible runs, and --threads and --perm-batch-size may also be required. ```bash --seed --threads --perm-batch-size ``` -------------------------------- ### Handle Filesets with No Samples or Variants in PLINK Source: https://www.cog-genomics.org/plink/1.9/input PLINK typically generates an error when input filesets lack samples or variants. The '--allow-no-samples' and '--allow-no-vars' flags override this behavior, allowing PLINK to proceed even with empty filesets. While most commands will not produce meaningful output in such cases, these options prevent premature termination. ```bash --allow-no-samples --allow-no-vars ```