Common Odds Ratio - R Udf
1
0
Entering edit mode
10.8 years ago
zx8754 11k

If you kindly paste SNP1,5220,26,0,810,30,1 as input on this website, it gives out Armitage's trend test common odds ratio of Odds_ratio=8.568. At the bottom of the page they explain what it means as below:

Common odds ratio:    (Case_12*Control_11/N01 + Case_22*Control_12/N12 + 4*(Case_22*Control_11/N02))/
(Case_11*Control_12/N01 + Case_12*Control_22/N12 + 4*(Case_22*Control_11*Case_11*Control_22)**0.5/N02)

Question: I am trying to make an R function, but not sure what N01, N12, N02 mean? Or do you know of an existing R function that would give the same result?

So far, before making it into a function, I am trying to break down the formula so I can get the same result as in the website:

d <- structure(c(5220L, 810L, 26L, 30L, 0L, 1L),
               .Dim = 2:3,
               .Dimnames = structure(
                 list(
                   caco = c("0", "1"), 
                   snp1 = c("CC", "CT", "TT")),
                 .Names = c("caco","snp1")),
               class = "table")
# snp1
# caco   CC   CT   TT
# 0 5220   26    0
# 1  810   30    1

#Assign Variables
Control_11 <- d[1,1]
Control_12 <- d[1,2]
Control_22 <- d[1,3]
Case_11 <- d[2,1]
Case_12 <- d[2,2]
Case_22 <- d[2,3]

#Doesn't work - OR=5986.03
# N01 <- Control_11 + Case_11
# N12 <- Control_12 + Case_12
# N02 <- Control_22 + Case_22

#Doesn't work - OR=214.8141
# N01 <- (Control_11 + Case_11)*2 + Control_12 + Case_12
# N12 <- Control_12 + Case_12
# N02 <- (Control_22 + Case_22)*2 + Control_12 + Case_12

#Return OR - Correct OR should be 8.568
(Case_12*Control_11/N01
 + Case_22*Control_12/N12
 + 4*(Case_22*Control_11/N02))/
  (Case_11*Control_12/N01
   + Case_12*Control_22/N12
   + 4*(Case_22*Control_11*Case_11*Control_22)**0.5/N02)

EDIT: Tried following, close but not the same result:

#Doesn't work - OR=7.59501 - Probably rounding?
N01 <- Case_11 + Case_12 + Case_22 
N02 <- Control_11 + Control_12 + Control_22
N12 <- N01 + N02
r • 3.8k views
ADD COMMENT
0
Entering edit mode

Have you contacted the developers to ask for source or at least a top-level description of their work? If their research is reproducible, they should be able to provide (pseudo) code to show how the analysis works.

ADD REPLY
0
Entering edit mode

Contacted them today to explain what N01, N02, N12 variables mean. If I hear anything I will update this post.

ADD REPLY
1
Entering edit mode
10.8 years ago
zx8754 11k

Found the solution, the formula was adopted from Peter D. Sasieni - "From Genotypes to Genes: Doubling the Sample Size" (Biometrics 1997). There was inconsistency how the variables were named on the paper and on the adopted website.

Here is the working R function:

udf_CommonOddsRatio <- function(d) 
{ 
  # Armitage's trend test - common odds ratio
  # http://ihg.gsf.de/cgi-bin/hw/hwa2.pl
  # 
  # Peter D. Sasieni - "From Genotypes to Genes: Doubling the Sample Size"
  # (Biometrics 1997)
  # 
  # Example data - class=table
  # d <- structure(c(5220L, 810L, 26L, 30L, 0L, 1L),
  #                .Dim = 2:3,
  #                .Dimnames = structure(
  #                  list(
  #                    caco = c("0", "1"), 
  #                    snp1 = c("CC", "CT", "TT")),
  #                  .Names = c("caco","snp1")),
  #                class = "table")
  # snp1
  # caco   CC   CT   TT
  # 0 5220   26    0
  # 1  810   30    1

  #Assign Variables
  Control_11 <- d[1,1]
  Control_12 <- d[1,2]
  Control_22 <- d[1,3]
  Case_11 <- d[2,1]
  Case_12 <- d[2,2]
  Case_22 <- d[2,3]

  N01 <- Case_11 + Control_11 + Case_12 + Control_12
  N02 <- Case_11 + Control_11 + Case_22 + Control_22
  N12 <- Case_12 + Control_12 + Case_22 + Control_22

  #Return OR
  return(
    (Case_12*Control_11/N01
     + Case_22*Control_12/N12
     + 4*(Case_22*Control_11/N02))/
      (Case_11*Control_12/N01
       + Case_12*Control_22/N12
       + 4*(Case_22*Control_11*Case_11*Control_22)**0.5/N02)
  )
}
ADD COMMENT

Login before adding your answer.

Traffic: 2050 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