read in mouse data

Kang <- read.delim("../../mouse_comparison/mouse_WT-LPS_over_WT.txt")
# fdrq 0.05
mouse_limma_FDRq0.05 <-
  read.delim("../../mouse_comparison/results/LPS_WT_gene_DEGs_FDRq0.05.txt")
pig_brain_FDRq0.05 <-
  read.delim("../../results/star/DEGs/LPS_Brain_gene_DEGs_FDRq0.05.txt")
# fdrq 1.0
mouse_limma_FDRq1.00 <-
  read.delim("../../mouse_comparison/results/LPS_WT_gene_DEGs_FDRq1.00.txt")
pig_brain_FDRq1.00 <-
  read.delim("../../results/star/DEGs/LPS_Brain_gene_DEGs_FDRq1.00.txt")

shared and unique between mouse and pig

# rename GeneName to gene_name to merge data sets and find intersections
mouse_and_pg_df <- merge(mouse_limma_FDRq1.00, pig_brain_FDRq1.00, by = "gene_name")

shared_gene_name <- intersect(mouse_limma_FDRq0.05$gene_name, pig_brain_FDRq0.05$gene_name)
uniqueToMouse_gene_name <- setdiff(mouse_limma_FDRq0.05$gene_name, pig_brain_FDRq0.05$gene_name)
uniqueToPig_gene_name <- setdiff(pig_brain_FDRq0.05$gene_name, mouse_limma_FDRq0.05$gene_name)

shared <- mouse_and_pg_df[mouse_and_pg_df$gene_name %in% shared_gene_name, ]
uniqueToMouse <- mouse_and_pg_df[mouse_and_pg_df$gene_name %in% uniqueToMouse_gene_name, ]
uniqueToPig <- mouse_and_pg_df[mouse_and_pg_df$gene_name %in% uniqueToPig_gene_name, ]
# Venn diagram to see what is gained and lost between the reanalysis
x = list(mouse = mouse_limma_FDRq0.05$gene_name, pig = pig_brain_FDRq0.05$gene_name)
ggvenn(
  x,
  fill_color = c("#EFC000FF", "purple"),
  stroke_size = 2,
  set_name_size = 6
)

output tables

#output table 
write.table(
  shared_gene_name,
  "../../mouse_comparison/results/mouse_pig_shared_gene_name.txt",
  quote = F,
  row.names = F
)

write.table(
  uniqueToMouse_gene_name,
  "../../mouse_comparison/results/uniqueToMouse_gene_name.txt",
  quote = F,
  row.names = F
)

write.table(
  uniqueToPig_gene_name,
  "../../mouse_comparison/results/uniqueToPig_gene_name.txt",
  quote = F,
  row.names = F
)

correlation

shared DEGs

# Shared DEGs
shared <- shared[!duplicated(shared[,c("gene_name")]),]

# Shapiro-Wilk normality test 
shapiro.test(shared$logFC.x)
## 
##  Shapiro-Wilk normality test
## 
## data:  shared$logFC.x
## W = 0.89084, p-value = 2.461e-12
shapiro.test(shared$logFC.y)
## 
##  Shapiro-Wilk normality test
## 
## data:  shared$logFC.y
## W = 0.95777, p-value = 1.3e-06
# correlation test 
res <- cor.test(shared$logFC.x, shared$logFC.y, 
                    method = "spearman")
p_value <- round(res$p.value, 3)
rho_value <- round(res$estimate, 3) 

# shared between mouse and pig 
p <- ggplot(data = shared, aes(x = logFC.x, y = logFC.y, text = paste(gene_name))) +
   annotate(
    "rect",
    xmin = 0,
    xmax = max(shared$logFC.x),
    ymin = max(shared$logFC.y),
    ymax = 0,
    fill = "lightpink3",
    alpha = .5
  ) +  annotate(
    "rect",
    xmin = 0,
    xmax = min(shared$logFC.x),
    ymin = 0,
    ymax = min(shared$logFC.y),
    fill = "cadetblue3",
    alpha = .5
  ) +
  geom_abline(color = "gray40") +
  geom_point(size = 2) + 
  theme_bw() +
  theme(plot.title = element_text(size = 10)) +
  theme(legend.position = "none") +
  theme(axis.title.x = element_text(size = 10),
        axis.text.x = element_text(size = 10)) +
  theme(axis.title.y = element_text(size = 10),
        axis.text.y = element_text(size = 10)) +
    annotate(
    "text",
    x = -2,
    y = 5,
    label = paste0("rho = ", rho_value,"\n",
"p = ", p_value),
    parse = TRUE,
    color = "gray29",
    size = 5
  ) + labs(
  title = "Shared DEGs between mouse and pig",
  x = "mouse",
  y = "pig"
)  

ggplotly(p)
## Warning: `gather_()` was deprecated in tidyr 1.2.0.
## Please use `gather()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.

unique to mouse DEGs

# uniqueToMouse DEGs

shapiro.test(uniqueToMouse$logFC.x)
## 
##  Shapiro-Wilk normality test
## 
## data:  uniqueToMouse$logFC.x
## W = 0.84471, p-value < 2.2e-16
shapiro.test(uniqueToMouse$logFC.y)
## 
##  Shapiro-Wilk normality test
## 
## data:  uniqueToMouse$logFC.y
## W = 0.9611, p-value < 2.2e-16
# correlation test 
res <- cor.test(uniqueToMouse$logFC.x, uniqueToMouse$logFC.y, 
                    method = "spearman")
## Warning in cor.test.default(uniqueToMouse$logFC.x, uniqueToMouse$logFC.y, :
## Cannot compute exact p-value with ties
p_value <- round(res$p.value, 3)
rho_value <- round(res$estimate, 3) 

# uniqueToMouse between mouse and pig 
p <- ggplot(data = uniqueToMouse, aes(x = logFC.x, y = logFC.y, text = paste(gene_name))) +
     annotate(
    "rect",
    xmin = 0,
    xmax = max(uniqueToMouse$logFC.x),
    ymin = max(uniqueToMouse$logFC.y),
    ymax = 0,
    fill = "lightpink3",
    alpha = .5
  ) +  annotate(
    "rect",
    xmin = 0,
    xmax = min(uniqueToMouse$logFC.x),
    ymin = 0,
    ymax = min(uniqueToMouse$logFC.y),
    fill = "cadetblue3",
    alpha = .5
  ) +
  geom_abline(color = "gray40") +
  geom_point(size = 2) + 
  theme_bw() +
  theme(plot.title = element_text(size = 10)) +
  theme(legend.position = "none") +
  theme(axis.title.x = element_text(size = 10),
        axis.text.x = element_text(size = 10)) +
  theme(axis.title.y = element_text(size = 10),
        axis.text.y = element_text(size = 10)) +
    annotate(
    "text",
    x = -2,
    y = 1.25,
    label = paste0("rho = ", rho_value,"\n",
"p = ", p_value),
    parse = TRUE,
    color = "gray29",
    size = 5
  ) + labs(
  title = "DEGs unique to mouse",
  x = "mouse",
  y = "pig"
) 
  
ggplotly(p)

unique to pig DEGs

# uniqueToPig DEGs
shapiro.test(uniqueToPig$logFC.x)
## 
##  Shapiro-Wilk normality test
## 
## data:  uniqueToPig$logFC.x
## W = 0.98562, p-value = 0.2758
shapiro.test(uniqueToPig$logFC.y)
## 
##  Shapiro-Wilk normality test
## 
## data:  uniqueToPig$logFC.y
## W = 0.90463, p-value = 7.243e-07
# correlation test 
res <- cor.test(uniqueToPig$logFC.x, uniqueToPig$logFC.y, 
                    method = "spearman")
p_value <- round(res$p.value, 3)
rho_value <- round(res$estimate, 3) 

# uniqueToPig between mouse and pig 
p <- ggplot(data = uniqueToPig, aes(x = logFC.x, y = logFC.y, text = paste(gene_name))) +
    annotate(
    "rect",
    xmin = 0,
    xmax = max(uniqueToPig$logFC.x),
    ymin = max(uniqueToPig$logFC.y),
    ymax = 0,
    fill = "lightpink3",
    alpha = .5
  ) +  annotate(
    "rect",
    xmin = 0,
    xmax = min(uniqueToPig$logFC.x),
    ymin = 0,
    ymax = min(uniqueToPig$logFC.y),
    fill = "cadetblue3",
    alpha = .5
  ) +
  geom_abline(color = "gray40") +
  geom_point(size = 2) + 
  theme_bw() +
  theme(plot.title = element_text(size = 10)) +
  theme(legend.position = "none") +
  theme(axis.title.x = element_text(size = 10),
        axis.text.x = element_text(size = 10)) +
  theme(axis.title.y = element_text(size = 10),
        axis.text.y = element_text(size = 10)) +
    annotate(
    "text",
    x = -.17,
    y = 1.5,
    label = paste0("rho = ", rho_value,"\n",
"p = ", p_value),
    parse = TRUE,
    color = "gray29",
    size = 5
  ) + labs(
  title = "DEGs unique to pig",
  x = "mouse",
  y = "pig"
) 
ggplotly(p)