---
title: "Using the exact functional test"
author: "Hua Zhong and Joe Song"
date: "Updated October 24, 2018; September 1, 2016; Created April 30, 2016"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using the exact functional test}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

We illustrate the exact functional test with an example. An epigenetic indicator called CpG island methylator phenotype (CIMP) is strongly associated with liver cancers. Specimens [@shen2002dna] to study CIMP were collected and divided into three groups with different CIMP status: negative (no methylated genes), intermediate (1~2 methylated genes) and positive (>2 methylated genes). 

The following table gives the frequencies of observed tumor protein p53 mutations and CIMP status:

Table: **CpG Island Methylator Phenotype (CIMP) and p53 mutation.**

--------------------------------------------------------
                     CIMP         CIMP           CIMP
 p53 mutation      Negative    Intermediate	   Positive
--------------    ----------  --------------  ----------
    No	              12	        26	           18
    
	  Yes	           	  0	           8		         12
-------------------------------------------------------

```{r}
require(FunChisq)
# x is a contingency table with row variable for p53 mutation and
#   column variable for CIMP
x <- matrix(c(12,26,18,0,8,12), nrow=2, ncol=3, byrow=TRUE)
x
# Test the functional dependency: p53 mutation -> CIMP
res <- fun.chisq.test(x, method="exact")
print(res)
pval.text <- format.pval(res$p.value, digits=2)
xif.text <- format.pval(res$estimate, digits=2)
plot_table(
  x, xlab="CIMP", ylab="p53 mutation", col="seagreen3",
  main=bquote(italic(P)~'='~.(pval.text)*','~~italic(xi[f])~'='~.(xif.text)))
```

## References

---
references:
- id: shen2002dna
  title: DNA methylation and environmental exposures in human hepatocellular carcinoma
  author:
  - family: Shen
    given: L.
  - family: Ahuja
    given: N.
  - family: Shen
    given: Y.
  - family: Habib
    given: N. A.
  - family: Toyota
    given: M.
  - family: Rashid
    given: A.
  - family: Issa
    given: J.-P. J.
  container-title: Journal of the National Cancer Institute
  volume: 94
  issue: 10
  page: 755-761
  type: article-journal
  issued:
    year: 2002
...