#setwd("C:\\work\\script_test\\R\\diff_valcano") #Args <- commandArgs() path = "P30_vs_MV4_11.genes.DEA.xls" title = "Difference expression genes of P30_vs_MV4_11" savefile = "P30_vs_MV4_11.Dynamic_volcano_plot.html" library(ggplot2) library(plotly) options(stringsAsFactors=FALSE) data <- read.csv(path, header=TRUE, sep = "\t", quote = "") #data <- read.csv(Args[1], header=TRUE, sep = "\t") data_plot = data[!is.na(data[,4]),c(8, 4, 6)] data_plot$change <- as.factor(ifelse(data_plot$padjust < 0.005 & abs(data_plot$log2foldchange) > 1,ifelse(data_plot$log2foldchange > 1,'UP','DOWN'),'NOT')) data_plot$sign <- ifelse(data_plot$padjust < 0.005 & abs(data_plot$log2foldchange) > 1,data_plot$gene_name,NA) p <- ggplot(data = data_plot, aes(x = log2foldchange, y = -log10(padjust), color = change)) + geom_point(aes(text = sign), alpha=0.8, size = 0.8) + theme_bw(base_size = 15) + #labs(title = paste0("Difference expression of ", Args[2])) + labs(title = title) + theme( panel.grid.minor = element_blank(), panel.grid.major = element_blank(), plot.title = element_text(hjust = 0.5)) + scale_color_manual(name = "", values = c("red", "green", "black"), limits = c("UP", "DOWN", "NOT")) p <- ggplotly(p) #htmlwidgets::saveWidget(as_widget(p), paste0(Args[2], ".Dynamic_volcano_plot.html")) htmlwidgets::saveWidget(as_widget(p), savefile)