Calculate z-scores from GWAS summary stats
2
5
Entering edit mode
9.0 years ago
NB ▴ 960

Hello,

I need to calculate the z-scores from meta-GWAS summary stats. The association file has the following header

rs_id   Allele1 Allele2 Freq1   Effect  StdErr  P.value

The 'effect' is the Beta coefficent. My understanding is

z-score=Effect/StdErr

Is that correct? Also, are there any R packages that can do this?

Many thanks

summary-stats GWAS z-scores • 20k views
ADD COMMENT
7
Entering edit mode
9.0 years ago

You are correct. This can be very easily done with basic AWK or R:

AWK:

awk '{if(NR == 1) print \$1; else if(NR > 1) print $0, \$5/\$6}' infile > outfile

R:

Infile<-read.table("infile.txt", head=T)
infile$z-score<-infile$Effect/infile$StdErr
head(Infile, 1)
rs_id   Allele1 Allele2 Freq1   Effect  StdErr  P.value z-score
ADD COMMENT
0
Entering edit mode

thank you, very much! I actually tried awk before but end up with an error

awk: (FILENAME=summary_stats.txt FNR=1) fatal: division by zero attempted

ADD REPLY
0
Entering edit mode

Hi,

Please check following code to fix the issue. Actually, the issue backs to division by zero and also considering heading as string.

awk -v OFS='\t' 'NR==1 {$8="zscore"} NR>1 {$8 = ($6!=0) ? sprintf("%.3f", $5 / $6): "UND"} 1' input file > output file

ADD REPLY

Login before adding your answer.

Traffic: 2601 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6