Skip to content

Instantly share code, notes, and snippets.

@nievergeltlab
Created April 8, 2021 21:31
Show Gist options
  • Save nievergeltlab/dbc917664dd2372ef5742eb01d214efc to your computer and use it in GitHub Desktop.
Save nievergeltlab/dbc917664dd2372ef5742eb01d214efc to your computer and use it in GitHub Desktop.
When PLINK does not give you A2 because you forgot to add it, get it from HG annotations ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh37p13/VCF/ (only works if strand matches, need ot add in strand matching code)
zcat /mnt/ukbb/adam/ptsd/ehr_reformat/74_dai2/daner_iPSYCH2015_PTSDbroad_chr1to22_HRC_MAF01.gz | awk '{print $2,$4,$5,$7}' | LC_ALL=C sort -k1b,1 > /mnt/ukbb/adam/ptsd/ehr_reformat/74_dai2/daner_iPSYCH2015_PTSDbroad_chr1to22_HRC_MAF01.afs
LC_ALL=C join -1 1 -2 2 <(cat /mnt/ukbb/adam/ptsd/ehr_reformat/74_dai2/daner_iPSYCH2015_PTSDbroad_chr1to22_HRC_MAF01.afs) <(LC_ALL=C sort -k2b,2 95_biom/PTSD_broad_EA_clean.head.assoc.logistic) > 95_biom/PTSD_broad_EA_clean.head.assoc.logistic.merged
awk '{FRQ=$4; A1=$7; if(A1==$2) { A2=$3} else if(A1 != $2){ A2=$2; FRQ=1-$4}; print $0,A2,FRQ}' 95_biom/PTSD_broad_EA_clean.head.assoc.logistic.merged | grep -v -E "A T$|T A$|C G$|G C$" > 95_biom/PTSD_broad_EA_clean.head.assoc.logistic.merged.gwas1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment