Introduction

RNA_seq_tissue_specific_overlap <- read.csv("../data/RNA_seq_tissue_specific_overlap.csv")

RNA_seq_tissue_specific_overlap[,11] <- RNA_seq_tissue_specific_overlap[,3]+RNA_seq_tissue_specific_overlap[,5]
## Warning in Ops.factor(RNA_seq_tissue_specific_overlap[, 3],
## RNA_seq_tissue_specific_overlap[, : '+' not meaningful for factors
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.4.4

Function for the human-chimpanzee tissue specific overlap

Heart- human and chimp (conservative)

RNA_seq_tissue_specific_overlap <- c(NA, NA, 96,332, 117,425,134,551,72)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 39
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 1.724958e-107

liver- human and chimp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 102,429, 199,495,153,479,77)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 62
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 1.251186e-139

lung- human and chimp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 65,225, 90,380,144,557,39)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 23
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 1.139362e-90

kidney- human and chimp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 33,224, 50,150,34,166,19)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 7
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 1.821355e-68

Human-chimpanzee-rhesus macaque tissue specific overlap

Heart- 3 species (conservative)

RNA_seq_tissue_specific_overlap <- c(NA, NA, 96,332, 117,425,134,551,72)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 14
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 8.658219e-56

Liver- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 102,429, 199,495,153,479,77)


  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 20
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 3.395985e-47

lung- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 65,225, 90,380,144,557,39)


  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 10
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 2.147224e-37

kidney- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 33,224, 50,150,34,166,19)


  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 5.070802e-36

Heart- 3 species (lenient)

RNA_seq_tissue_specific_overlap <- c(NA, NA, 482,   219,    182,    514,    446,    514,    93)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 83
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 4.238179e-308

Liver- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 734,   234,    301,    565,    381,    644,    95)


  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 157
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

lung- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 408,   126,    125,    419,    419,    888,    63)


  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 77
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 3.125462e-244

kidney- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 172,   137,    86, 170,    170,    245,    31)


  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 12184 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 13
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 1.939328e-167
library(VennDiagram)
## Warning: package 'VennDiagram' was built under R version 3.4.4
## Loading required package: grid
## Loading required package: futile.logger
library(RColorBrewer)
library(cowplot)
## Warning: package 'cowplot' was built under R version 3.4.4
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggplot2':
## 
##     ggsave
# Load colors 

colors <- colorRampPalette(c(brewer.pal(9, "Blues")[1],brewer.pal(9, "Blues")[9]))(100)
pal <- c(brewer.pal(9, "Set1"), brewer.pal(8, "Set2"), brewer.pal(12, "Set3"))


draw_venn_methylation <- function(hcr, hs, hc, cs, cr, rs, hr){
draw.triple.venn(hs+hc+hr+hcr, cs+hc+cr+hcr, rs+hr+cr+hcr, hc+hcr, cr+hcr, hr+hcr, hcr, filename = NULL, category = c("Hu", "Ch", "Rh"), fill = pal[1:3], main.cex = 3, cat.cex = 3, cex=3.5, lty=1, height=2000, width=2000, fontfamily = "sans", cat.fontfamily = "sans", main.fontfamily = "sans", cat.fontface = "bold", main.fontface = "bold", cat.dist = 0.05)
}

# Heart specific
svg("../data/Lenient_heart_specific.svg", width = 7.2, height = 7.2)
draw_venn_methylation(482,  219,    182,    514,    446,    514,    93)
## (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], polygon[GRID.polygon.5], polygon[GRID.polygon.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9], text[GRID.text.10], text[GRID.text.11], text[GRID.text.12], text[GRID.text.13], text[GRID.text.14], text[GRID.text.15], text[GRID.text.16])
dev.off()
## quartz_off_screen 
##                 2
svg("../data/Lenient_kidney_specific.svg", width = 7.2, height = 7.2)
draw_venn_methylation(172,  137,    86, 170,    92, 245,    31)
## (polygon[GRID.polygon.17], polygon[GRID.polygon.18], polygon[GRID.polygon.19], polygon[GRID.polygon.20], polygon[GRID.polygon.21], polygon[GRID.polygon.22], text[GRID.text.23], text[GRID.text.24], text[GRID.text.25], text[GRID.text.26], text[GRID.text.27], text[GRID.text.28], text[GRID.text.29], text[GRID.text.30], text[GRID.text.31], text[GRID.text.32])
dev.off()
## quartz_off_screen 
##                 2
svg("../data/Lenient_liver_specific.svg", width = 7.2, height = 7.2)
draw_venn_methylation(734,  234,    301,    565,    381,    644,    95)
## (polygon[GRID.polygon.33], polygon[GRID.polygon.34], polygon[GRID.polygon.35], polygon[GRID.polygon.36], polygon[GRID.polygon.37], polygon[GRID.polygon.38], text[GRID.text.39], text[GRID.text.40], text[GRID.text.41], text[GRID.text.42], text[GRID.text.43], text[GRID.text.44], text[GRID.text.45], text[GRID.text.46], text[GRID.text.47], text[GRID.text.48])
dev.off()
## quartz_off_screen 
##                 2
svg("../data/Lenient_lung_specific.svg", width = 7.2, height = 7.2)
draw_venn_methylation(408,  126,    125,    419,    412,    888, 63)
## (polygon[GRID.polygon.49], polygon[GRID.polygon.50], polygon[GRID.polygon.51], polygon[GRID.polygon.52], polygon[GRID.polygon.53], polygon[GRID.polygon.54], text[GRID.text.55], text[GRID.text.56], text[GRID.text.57], text[GRID.text.58], text[GRID.text.59], text[GRID.text.60], text[GRID.text.61], text[GRID.text.62], text[GRID.text.63], text[GRID.text.64])
dev.off()
## quartz_off_screen 
##                 2
p1 <- ggdraw()+draw_image("../data/Lenient_heart_specific.svg") 
p2 <- ggdraw()+draw_image("../data/Lenient_kidney_specific.svg") 
p3 <- ggdraw()+draw_image("../data/Lenient_liver_specific.svg")  
p4 <- ggdraw()+draw_image("../data/Lenient_lung_specific.svg") 


eight_plots <- plot_grid(p1, p2, p3, p4, labels = c("2A. Heart", "2B. Kidney", "2C. Liver", "2D. Lung"), ncol = 2)
plot_fig2 <- plot_grid(eight_plots, ncol = 2, rel_heights=c(1, 1))

save_plot("../data/fig_2_lenient_ts.png", plot_fig2,
           ncol = 2, # we're saving a grid plot of 2 columns
           nrow = 2, # and 2 rows
           # each individual subplot should have an aspect ratio of 1.3
           base_aspect_ratio = 1
           )

Methylation- humans and chimps

Heart - 50% bp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 36,    1816,   223,    915,    43, 1011,   58)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Liver

RNA_seq_tissue_specific_overlap <- c(NA, NA, 197,   1474,   575,    3708,   479,    8622,   251)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 7
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Lung

RNA_seq_tissue_specific_overlap <- c(NA, NA, 2, 240,    21, 263,    8,  311,    3)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 2.368124e-57

Kidney

RNA_seq_tissue_specific_overlap <- c(NA, NA, 125,   2263,   420,    1089,   95, 2244,   209)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 3
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Heart - 25% bp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 66,    2413,   389,    1212,   76, 1354,   101)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 3
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Liver

RNA_seq_tissue_specific_overlap <- c(NA, NA, 478,   1556,   849,    4191,   843,    9717,   395)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 12
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Lung

RNA_seq_tissue_specific_overlap <- c(NA, NA, 5, 415,    46, 382,    20, 488,    13)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 2.178134e-117

Kidney

RNA_seq_tissue_specific_overlap <- c(NA, NA, 287,   2763,   607,    1258,   148,    2812,   300)

 m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]+RNA_seq_tissue_specific_overlap[6]+RNA_seq_tissue_specific_overlap[7]
  n <- 1674083 - m
  x <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[4] + RNA_seq_tissue_specific_overlap[5] + RNA_seq_tissue_specific_overlap[9]

# Expected

 which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 5
# P value of observed
 phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Heart- 3 species, 50% bp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 36,    1816,   223,    915,    43, 1011,   58)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 2.690084e-71

Liver- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 197,   1474,   575,    3708,   479,    8622,   251)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 4
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 3.19614e-248

Lung- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 2, 240,    21, 263,    8,  311,    3)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 1.786278e-08

Kidney- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 125,   2263,   420,    1089,   95, 2244,   209)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 6.93864e-222

Heart- 3 species, 25% bp

RNA_seq_tissue_specific_overlap <- c(NA, NA, 66,    2413,   389,    1212,   76, 1354,   101,    455)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 2.99824e-119

Liver- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 478,   1556,   849,    4191,   843,    9717,   395,    1327)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 10
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0

Lung- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 5, 415,    46, 382,    20, 488,    13, 51)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 1
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 3.2977e-14

Kidney- 3 species

RNA_seq_tissue_specific_overlap <- c(NA, NA, 287,   2763,   607,    1258,   148,    2812,   300,    894)

  m <- RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[5]
  n <- 1493337 - m
  x <- RNA_seq_tissue_specific_overlap[3] 
  q = x
  k = RNA_seq_tissue_specific_overlap[3] + RNA_seq_tissue_specific_overlap[7]+RNA_seq_tissue_specific_overlap[8]+RNA_seq_tissue_specific_overlap[9]

# Expected

which(grepl(max(dhyper(1:x, m, n, k)), dhyper(1:x, m, n, k)))
## [1] 2
# P value of observed
phyper(q, m, n, k, lower.tail = FALSE)
## [1] 0