library(GOplot)
library(data.table)
go_circle <- read.delim("data/GO_MIVSA_Maintenance_vs_Saline_circle.txt", sep = "\t")
go2_circle <- read.delim("data/GO_MIVSA_Abstinence_vs_Saline_circle.txt", sep = "\t")
go3_circle <- read.delim("data/GO_MIVSA_Abstinence_vs_Maintenance_circle.txt", sep = "\t")
processes1 <- data[c(1:7), ]
processes1_final_circle <- processes1$Description
ids_final_circle <- processes1$ID
processes2 <- data[c(8:14), ]
processes2_final_circle <- processes2$Description
ids2_final_circle <- processes2$ID
processes3 <- data[c(15:21), ]
processes3_final_circle <- processes3$Description
ids3_final_circle <- processes3$ID
circletest_genes1 <- data.frame(matrix(ncol = 2, nrow = 432))
colnames(circletest_genes1) <- c("Genes", "L2FC")
circletest_DEGsgenes1 <- as.data.table(results_sig)
circletest_DEGsgenes1$ID <- circletest_DEGsgenes1$symbol
circletest_DEGsgenes1$logFC <- circletest_DEGsgenes1$log2FoldChange
circletest_DEGsgenes1$AveExpr <- circletest_DEGsgenes1$baseMean
circletest_DEGsgenes1$t <- circletest_DEGsgenes1$stat
circletest_DEGsgenes1$P.Value <- circletest_DEGsgenes1$pvalue
circletest_DEGsgenes1$adj.P.Value <- circletest_DEGsgenes1$padj
circletest_DEGsgenes1$B <- circletest_DEGsgenes1$stat
circletest_DEGsgenes1_final <- circletest_DEGsgenes1[, 11:17, with = FALSE]
circletest_genes1$Genes <- names(gene_matrix)
circletest_genes1$ID <- mapIds(
x = org.Mm.eg.db,
keys = circletest_genes1$Genes,
column = "SYMBOL",
keytype = "ENTREZID",
multiVals = "first"
)
circletest_genes1$logFC <- (gene_matrix)
circletest_genes1 <- mutate_all(circletest_genes1, .funs = toupper)
circletest_genes1_final <- circletest_genes1[, 3:4]
circletest_genes1_final$logFC <- as.numeric(circletest_genes1_final$logFC)
circletest_genes2 <- data.frame(matrix(ncol = 2, nrow = 227))
colnames(circletest_genes2) <- c("Genes", "L2FC")
circletest_DEGsgenes2 <- as.data.table(results_sig2)
circletest_DEGsgenes2$ID <- circletest_DEGsgenes2$symbol
circletest_DEGsgenes2$logFC <- circletest_DEGsgenes2$log2FoldChange
circletest_DEGsgenes2$AveExpr <- circletest_DEGsgenes2$baseMean
circletest_DEGsgenes2$t <- circletest_DEGsgenes2$stat
circletest_DEGsgenes2$P.Value <- circletest_DEGsgenes2$pvalue
circletest_DEGsgenes2$adj.P.Value <- circletest_DEGsgenes2$padj
circletest_DEGsgenes2$B <- circletest_DEGsgenes2$stat
circletest_DEGsgenes2_final <- circletest_DEGsgenes2[, 11:17, with = FALSE]
circletest_genes2$Genes <- names(gene_matrix2)
circletest_genes2$ID <- mapIds(
x = org.Mm.eg.db,
keys = circletest_genes2$Genes,
column = "SYMBOL",
keytype = "ENTREZID",
multiVals = "first"
)
circletest_genes2$logFC <- (gene_matrix2)
circletest_genes2 <- mutate_all(circletest_genes2, .funs = toupper)
circletest_genes2_final <- circletest_genes2[, 3:4]
circletest_genes2_final$logFC <- as.numeric(circletest_genes2_final$logFC)
circletest_genes3 <- data.frame(matrix(ncol = 2, nrow = 549))
colnames(circletest_genes3) <- c("Genes", "L2FC")
circletest_DEGsgenes3 <- as.data.table(results_sig3)
circletest_DEGsgenes3$ID <- circletest_DEGsgenes3$symbol
circletest_DEGsgenes3$logFC <- circletest_DEGsgenes3$log2FoldChange
circletest_DEGsgenes3$AveExpr <- circletest_DEGsgenes3$baseMean
circletest_DEGsgenes3$t <- circletest_DEGsgenes3$stat
circletest_DEGsgenes3$P.Value <- circletest_DEGsgenes3$pvalue
circletest_DEGsgenes3$adj.P.Value <- circletest_DEGsgenes3$padj
circletest_DEGsgenes3$B <- circletest_DEGsgenes3$stat
circletest_DEGsgenes3_final <- circletest_DEGsgenes3[, 11:17, with = FALSE]
circletest_genes3$Genes <- names(gene_matrix3)
circletest_genes3$ID <- mapIds(
x = org.Mm.eg.db,
keys = circletest_genes3$Genes,
column = "SYMBOL",
keytype = "ENTREZID",
multiVals = "first"
)
circletest_genes3$logFC <- (gene_matrix3)
circletest_genes3 <- mutate_all(circletest_genes3, .funs = toupper)
circletest_genes3_final <- circletest_genes3[, 3:4]
circletest_genes3_final$logFC <- as.numeric(circletest_genes3_final$logFC)
circ <- circle_dat(go_circle, circletest_DEGsgenes1_final)
circ2 <- circle_dat(go2_circle, circletest_DEGsgenes2_final)
circ3 <- circle_dat(go3_circle, circletest_DEGsgenes3_final)
chord <- chord_dat(circ, circletest_genes1_final, processes1_final_circle)
chord2 <- chord_dat(circ2, circletest_genes2_final, processes2_final_circle)
chord3 <- chord_dat(circ3, circletest_genes3_final, processes3_final_circle)
p5 <- GOChord(chord, space = 0, gene.order = "logFC", gene.space = 0.15, gene.size = 4, nlfc = 1, process.label = 14, limit = c(1, 0), ribbon.col = c("#478FCD", "#FEC111", "#8D268B", "#0FB34C", "#39C0C4", "#F16739", "#607D8B"), border.size = 0, lfc.col = c("#E31A1C", "#33A02C", "#125AD9"), lfc.min = -2, lfc.max = 2)
p6 <- GOChord(chord2, space = 0, gene.order = "logFC", gene.space = 0.15, gene.size = 4, nlfc = 1, process.label = 14, limit = c(1, 0), ribbon.col = c("#478FCD", "#FEC111", "#8D268B", "#0FB34C", "#39C0C4", "#F16739", "#607D8B"), border.size = 0, lfc.col = c("#E31A1C", "#33A02C", "#125AD9"), lfc.min = -2, lfc.max = 2)
p7 <- GOChord(chord3, space = 0, gene.order = "logFC", gene.space = 0.15, gene.size = 4, nlfc = 1, process.label = 14, limit = c(1, 0), ribbon.col = c("#478FCD", "#FEC111", "#8D268B", "#0FB34C", "#39C0C4", "#F16739", "#607D8B"), border.size = 0, lfc.col = c("#E31A1C", "#33A02C", "#125AD9"), lfc.min = -2, lfc.max = 2)
y.axis.text <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 7)
x.axis.text <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 7)
plot.title.text <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 9, hjust = 0.5)
legend.text <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 6)
legend.title.text <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 10)
axis.title <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 6)
text <- element_text(family = "NimbusSanCond", face = "bold", color = "black", size = 6)
p8 <- p5 +
theme(
legend.position = "bottom",
legend.text = legend.text,
legend.title = legend.title.text,
text = text,
legend.key.width = unit(3, "cm")
) # change legend key width
p9 <- p6 +
theme(
legend.position = "bottom",
legend.text = legend.text,
legend.title = legend.title.text,
text = text,
legend.key.width = unit(3, "cm")
) # change legend key width
p10 <- p7 +
theme(
legend.position = "bottom",
legend.text = legend.text,
legend.title = legend.title.text,
text = text,
legend.key.width = unit(3, "cm")
) # change legend key width
cowplot::plot_grid(p8, p9, p10,
ncol = 3, labels = c("A. Maintenance vs Saline", "B. Abstinence vs Saline", "C. Abstinence vs Maintenance"),
label_fontfamily = "arial",
label_fontface = "bold",
label_colour = "black",
label_size = 50
)