Setup

Symlink genotype files into this directory. Set shell variable GENSCOT to the mountpoint of the HPC system holding copies of the data for compute:


ln -s ${GENSCOT}/genetics/genotypes/GS20K_PLINK_files/QCd_data/QCdGS20K.* .
ln -s ${GENSCOT}/genetics/imputed/HRC/updated_bims/GS20K_HRC_0.8_GCTA_*.* .
ln -s ${GENSCOT}/genetics/imputed/HRC/GS20K_HRC.INFO.gz .
 

Covariates

Combine age/sex covariates with MDS components

library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(stringr)

covars <- read_table2('plinkcovar.txt')
## Parsed with column specification:
## cols(
##   famid = col_double(),
##   id = col_double(),
##   age = col_double(),
##   age2 = col_double(),
##   sex = col_double()
## )
pcs <- read_csv('HM3mds2R.mds.csv')
## Parsed with column specification:
## cols(
##   FID = col_double(),
##   IID = col_double(),
##   SOL = col_double(),
##   C1 = col_double(),
##   C2 = col_double(),
##   C3 = col_double(),
##   C4 = col_double()
## )
## Warning: 988 parsing failures.
##   row col expected actual               file
## 19995 FID a double    CEU 'HM3mds2R.mds.csv'
## 19996 FID a double    CEU 'HM3mds2R.mds.csv'
## 19997 FID a double    CEU 'HM3mds2R.mds.csv'
## 19998 FID a double    CEU 'HM3mds2R.mds.csv'
## 19999 FID a double    CEU 'HM3mds2R.mds.csv'
## ..... ... ........ ...... ..................
## See problems(...) for more details.
all_covars <- pcs %>%
inner_join(covars, by=c('FID'='famid', 'IID'='id')) %>%
select(-SOL)

write_delim(all_covars, 'GenScot_AgeSexPCs.cov', delim=' ')

Genotypes

Check sample size with all inclusions and exclusions applied


plink \
  --bfile QCdGS20K \
  --pheno QCdGS20K_Pheno_dep_status_Unaff_b_only0_Aff_b_only1.txt \
  --keep QCdGS20K_unrelated_t0.025.fam \
  --remove GSindividualsOverlappingWithUKB500K.txt \
  --freq case-control \
  --maf 0.01 \
  --out GenScot_MDD_rmUKBB \
  --memory 3000

plink \
  --bfile QCdGS20K \
  --pheno QCdGS20K_Pheno_dep_status_Unaff_b_only0_Aff_b_only1.txt \
  --covar GenScot_AgeSexPCs.cov \
  --keep QCdGS20K_unrelated_t0.025.fam \
  --remove GSindividualsOverlappingWithUKB500K.txt \
  --maf 0.01 \
  --logistic \
  --ci 0.95 \
  --out Genscot_MDD_rmUKBB \
  --memory 3000

Imputed

Case-control allele frequencies

GSrmUKBB.frq.sh:

#$ -N GSrmUKBB.frq
#$ -l h_rt=1:00:00
#$ -l h_vmem=4G
#$ -t 1-22
#$ -cwd
#$ -e logs
#$ -o logs

. /etc/profile.d/modules.sh
module load igmm/apps/plink/1.90b4

CHR=$SGE_TASK_ID

plink \
  --bfile GS20K_HRC_0.8_GCTA_${CHR} \
  --pheno QCdGS20K_Pheno_dep_status_Unaff_b_only0_Aff_b_only1.txt \
  --keep QCdGS20K_unrelated_t0.025.fam \
  --remove GSindividualsOverlappingWithUKB500K.txt \
  --freq case-control \
  --out GenScot_MDD_rmUKBB.HRC.${CHR} \
  --memory 3000

qsub GSrmUKBB.frq.sh

Association analysis

GSrmUKBB.assoc.sh:

#$ -N GSrmUKBB.assoc
#$ -l h_rt=1:00:00
#$ -l h_vmem=4G
#$ -t 1-22
#$ -cwd
#$ -e logs
#$ -o logs

. /etc/profile.d/modules.sh
module load igmm/apps/plink/1.90b4

CHR=$SGE_TASK_ID

plink \
  --bfile GS20K_HRC_0.8_GCTA_${CHR} \
  --pheno QCdGS20K_Pheno_dep_status_Unaff_b_only0_Aff_b_only1.txt \
  --covar GenScot_AgeSexPCs.cov \
  --keep QCdGS20K_unrelated_t0.025.fam \
  --remove GSindividualsOverlappingWithUKB500K.txt \
  --logistic \
  --ci 0.95 \
  --maf 0.01 \
  --out GenScot_MDD_rmUKBB.HRC.${CHR} \
  --memory 3000

qsub GSrmUKBB.assoc.sh

Daner file

Open frequency and association results files. Convert to daner format

freq <- bind_rows(plyr::llply(1:22, function(chr) read_table2(paste0('GenScot_MDD_rmUKBB.HRC.', chr, '.frq.cc'))))
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   A1 = col_character(),
##   A2 = col_character(),
##   MAF_A = col_double(),
##   MAF_U = col_double(),
##   NCHROBS_A = col_double(),
##   NCHROBS_U = col_double()
## )
assoc <- bind_rows(plyr::llply(1:22, function(chr) read_table2(paste0('GenScot_MDD_rmUKBB.HRC.', chr, '.assoc.logistic'))))
## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 4539520 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.1.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.1.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.1.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.1.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.1.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 4990368 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.2.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.2.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.2.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.2.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.2.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 4250464 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.3.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.3.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.3.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.3.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.3.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 4311264 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.4.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.4.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.4.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.4.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.4.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 3873288 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.5.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.5.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.5.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.5.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.5.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 3966368 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.6.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.6.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.6.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.6.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.6.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 3481168 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.7.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.7.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.7.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.7.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.7.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 3327224 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.8.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.8.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.8.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.8.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.8.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 2551352 parsing failures.
## row col   expected     actual                                      file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.9.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.9.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.9.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.9.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.9.assoc.logistic'
## ... ... .......... .......... .........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 3041280 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.10.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.10.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.10.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.10.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.10.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 2977224 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.11.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.11.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.11.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.11.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.11.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 2864504 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.12.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.12.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.12.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.12.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.12.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 2225272 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.13.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.13.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.13.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.13.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.13.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1939184 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.14.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.14.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.14.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.14.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.14.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1673680 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.15.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.15.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.15.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.15.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.15.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1805392 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.16.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.16.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.16.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.16.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.16.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1521432 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.17.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.17.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.17.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.17.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.17.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1704280 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.18.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.18.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.18.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.18.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.18.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1273352 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.19.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.19.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.19.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.19.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.19.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 1328880 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.20.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.20.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.20.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.20.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.20.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 812352 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.21.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.21.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.21.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.21.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.21.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.

## Warning: Missing column names filled in: 'X13' [13]
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   BP = col_double(),
##   A1 = col_character(),
##   TEST = col_character(),
##   NMISS = col_double(),
##   OR = col_double(),
##   SE = col_double(),
##   L95 = col_double(),
##   U95 = col_double(),
##   STAT = col_double(),
##   P = col_double(),
##   X13 = col_character()
## )
## Warning: 772776 parsing failures.
## row col   expected     actual                                       file
##   1  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.22.assoc.logistic'
##   2  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.22.assoc.logistic'
##   3  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.22.assoc.logistic'
##   4  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.22.assoc.logistic'
##   5  -- 13 columns 12 columns 'GenScot_MDD_rmUKBB.HRC.22.assoc.logistic'
## ... ... .......... .......... ..........................................
## See problems(...) for more details.
gs_bim <- read_table2('QCdGS20K.bim', col_names=c('CHR', 'SNP', 'CM', 'BP', 'A1', 'A2'))
## Parsed with column specification:
## cols(
##   CHR = col_double(),
##   SNP = col_character(),
##   CM = col_double(),
##   BP = col_double(),
##   A1 = col_character(),
##   A2 = col_character()
## )
hrc_info <- read_table2('GS20K_HRC.INFO.gz')
## Parsed with column specification:
## cols(
##   CHROM = col_double(),
##   POS = col_double(),
##   REF = col_character(),
##   ALT = col_character(),
##   INFO = col_double()
## )
## Warning: 63 parsing failures.
##     row   col               expected actual                file
##  725028 CHROM a double                CHROM 'GS20K_HRC.INFO.gz'
##  725028 POS   a double                POS   'GS20K_HRC.INFO.gz'
##  725028 INFO  no trailing characters  O     'GS20K_HRC.INFO.gz'
## 1426808 CHROM a double                CHROM 'GS20K_HRC.INFO.gz'
## 1426808 POS   a double                POS   'GS20K_HRC.INFO.gz'
## ....... ..... ...................... ...... ...................
## See problems(...) for more details.
# SNPs that are directly genotyped
genotyped <- gs_bim %>%
transmute(CHR, SNP, ngt=1)

sumstats <- 
assoc %>%
filter(TEST == 'ADD') %>%
filter(str_detect(SNP, 'rs')) %>%
left_join(freq, by=c('CHR', 'SNP', 'A1')) %>%
left_join(genotyped, by=c('CHR', 'SNP')) %>%
left_join(hrc_info, by=c('CHR'='CHROM', 'BP'='POS')) %>%
mutate(ngt=if_else(ngt %in% 1, true=1, false=0)) %>%
select(CHR, SNP, BP, A1, A2, FRQ_A_951=MAF_A, FRQ_U_6114=MAF_U,
       INFO, OR, SE, P, ngt) %>%
filter(!is.na(INFO) & FRQ_U_6114 >= 0.01 & FRQ_A_951 > 0.01)

write_tsv(sumstats, 'daner_mdd_genscot_2019-11a_rmUKBB.gz')