Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.
Showing posts with label calculate. Show all posts
Showing posts with label calculate. Show all posts

Tuesday, August 5, 2014

How to Calculate Genomic Inflation Factor and λgc for GWAS

You have conducted your genome-wide association study (GWAS) and have tested each genetic variant for an association with your trait of interest. Now it is time to investigate if there are any systematic biases that may be present in your association results. A common way to do this is to calculate the genomic inflation factor, also known as lambda gc (λgc). By definition, λgc is defined as the median of the resulting chi-squared test statistics divided by the expected median of the chi-squared distribution. The median of a chi-squared distribution with one degree of freedom is 0.4549364. A λgc value can be calculated from z-scores, chi-square statistics, or p-values, depending on the output you have from the association analysis. Follow these simple steps to calculate lambda GC using R programming language.

(1) Convert your output to chi-squared values
(2) Calculate lambda gc (λgc)
If analysis results your data follows the normal chi-squared distribution, the expected λgc value is 1. If the λgc value is greater than 1, then this may be evidence for some systematic bias that needs to be corrected in your analysis.

Wednesday, June 18, 2014

Test for a Difference in Two Odds Ratios

Testing for a statistical difference between two odds ratio estimates can be useful in determining if an association has statistically different effects in different groups or strata of a variable.  For example, maybe an association is stronger for older individuals than younger individuals.  To test for such a difference we need the odds ratio estimate (or more precisely the natural log of the odds ratio estimate, aka the beta estimate from a logistic regression) and the standard error of the log odds ratio.

If you don't have access to the primary data and need to estimate the standard error from a 95% confidence interval (95% CI), see this blog entry.  If you have forgotten how to calculate the standard error of the log odds ratio use this formula:
SE(logOR)=1n1+1n2+1n3+1n4

To test if two odds ratios are significantly different and get a p-value for the difference follow these steps:
(1) Take the absolute value of the difference between the two log odds ratios. We will call this value δ.
(2) Calculate the standard error for δ, SE(δ), using the formula:
SE21+SE22


(3) Calculate the Z score for the test: z=δ/SE(δ)
(4) Calculate the p-value from the z score. The p-value can be easily calculated in R or Microsoft Excel using the below formulas.

R: P-value=2*(1-pnorm(Z))
MS Excel: P-value=2*(1-(NORMDIST(Z,0,1,TRUE)))