Skip to content

Incorrect handling of odds ratio confidence interval when flipping alleles during harmonization #209

@trafalmadorian97

Description

@trafalmadorian97

Example:

Image

Notice that how before GWASLAB harmonization, OR_95U is not equal to OR_95L, whereas after harmonization, both values are equal to one.

I believe the problem is here:

if has_or_95l:
log.write(" -Flipping column: OR_95U = 1 / OR_95L...", verbose=verbose)
sumstats.loc[matched_index, "OR_95U"] = factor / sumstats.loc[matched_index, "OR_95L"].values
if has_or_95u:
log.write(" -Flipping column: OR_95L = 1 / OR_95U...", verbose=verbose)
sumstats.loc[matched_index, "OR_95L"] = factor / sumstats.loc[matched_index, "OR_95U"].values
.

If both has_or_95l and has_or_95u are true, then OR_95U is updated using OR_95L, and then the new value of OR_95U is used to update OR_95L. Consequently, the old value of OR_95U is never used.

A solution would be to use a swap idiom:

    if has_or_95l:
        log.write(" -Flipping column: OR_95U = 1 / OR_95L...", verbose=verbose) 
        new_or95u=  factor / sumstats.loc[matched_index, "OR_95L"].values.copy()
    if has_or_95u:
        log.write(" -Flipping column: OR_95L = 1 / OR_95U...", verbose=verbose) 
        sumstats.loc[matched_index, "OR_95L"] = factor / sumstats.loc[matched_index, "OR_95U"].values
    if has_or_95l:
        sumstats.loc[matched_index, "OR_95U"] = new_or95u
         

I encountered this problem in gwaslab version 3.6.8, but I believe it still exists in the current version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions