I'm trying to convert plink output to the .sumstats format for use with LD score regression and I don't understand how plink is coding alleles. The .sumstats files look like
SNP A1 A2 Z N
rs3131969 A G 0.003 17115.000
We are running GWAS for quantitative traits using plink1.9:
./plink --bfile ../cal/chrom$i --covar sexAgeCovar10.pcs --covar-name age sex C1 C2 C3 C4 --linear standard-beta
How can I convert the A1 column from the .assoc output files to A1 and A2 columns like above?
We are using plink2 for case/control GWAS:
./plink2f --bfile ../cal/chrom$i --covar keep.10pcs --covar-name C1 C2 C3 C4 --glm firth-fallback
Similarly, how can I convert the REF and ALT1 columns from the .hybrid output file to A1 and A2 columns like above?
1 answer
With plink 1.9, assuming that the A2 alleles in chrom##.bim are always major (you can double-check by running "./plink --bfile ../cal/chrom## --make-bed" and verifying that the new .bim file is identical to the old one, since plink 1.x automatically flips minor A2 alleles), you can
- Create an allele_cols.txt file with just the A1 A2 header line: "echo A1 A2 > allele_cols.txt"
- Manually extract the alleles from the .bim file, and append them to allele_cols.txt: "cat chrom##.bim | cut -f 5-6 | tr '\t' ' ' >> allele_cols.txt"
- Extract the SNP, NMISS, and STAT columns from the .assoc file, one at a time. (STAT -> Z, NMISS -> N.) "cat plink.assoc.linear | awk '{print $2}' > snp_col.txt", similarly for columns 6 and 8.
- Paste the columns together: "paste snp_col.txt allele_cols.txt zcol.txt ncol.txt > my.sumstats"
- Change the STAT and NMISS headers, if you didn't do so in step 3.
plink 2.0 is a bit simpler since everything's in one file; you can treat REF as A2 and ALT1 as A1.
Log in to answer this question.