Skip to content

Commit 37a3edb

Browse files
committed
Update Volcano.R
1 parent 0289a49 commit 37a3edb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/Volcano.R

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#' @param color colors used for ggplots.color=c("#FF3300","#FF6600","#FFCC00","#99CC00","#0066CC","#660099")
1616
#' @param fixed_limit whether the limit should be fixed or not T, F
1717
#' @param max_overlap maximum overlap for labels
18+
#' @param FC_range significant fold change range
1819
#'
1920
#' @return Volcano Plot
2021
#' @export
@@ -36,6 +37,7 @@ Volcano<-function(data,
3637
y_limit = c(-2,6),
3738
pval_intercept = 0.05,
3839
max_overlap = 20,
40+
FC_range = c(-1.5,1.5),
3941
sig_label = T,
4042
color = c("blue","black", "red")){
4143
ifelse(!dir.exists(file.path(getwd(), "Volcano")), dir.create(file.path(getwd(), "Volcano")), FALSE)
@@ -120,8 +122,8 @@ Volcano<-function(data,
120122
Volc_Dat<-as.data.frame(Volc_Dat)
121123
colnames(Volc_Dat)<-c("log2FoldChange","pvalue","Direction")
122124
Volc_Dat$Direction <- "Not Significant"
123-
Volc_Dat$Direction[Volc_Dat$log2FoldChange > 0 & Volc_Dat$pvalue < pval_intercept] <- "UP"
124-
Volc_Dat$Direction[Volc_Dat$log2FoldChange < 0 & Volc_Dat$pvalue < pval_intercept] <- "DOWN"
125+
Volc_Dat$Direction[Volc_Dat$log2FoldChange > FC_range[2] & Volc_Dat$pvalue < pval_intercept] <- "UP"
126+
Volc_Dat$Direction[Volc_Dat$log2FoldChange < FC_range[1] & Volc_Dat$pvalue < pval_intercept] <- "DOWN"
125127
KK<-Volc_Dat %>% dplyr::filter(Direction!="Not Significant")
126128
sem_res<-ggplot2::ggplot(data=Volc_Dat, ggplot2::aes(x=log2FoldChange, y=-log(pvalue,base = pval_log), col=Direction)) +
127129
ggplot2::geom_point(size= dotsize) +
@@ -143,6 +145,8 @@ Volcano<-function(data,
143145
axis.text.y=ggplot2::element_text(size=10))+
144146
ggplot2::scale_color_manual(values=color[c("DOWN","Not Significant","UP")%in% unique(Volc_Dat$Direction)]) +
145147
ggplot2::geom_vline(xintercept=c(0), col=c("black")) +
148+
ggplot2::geom_vline(xintercept=FC_range[1],linetype = 'dashed', col=c("grey"))+
149+
ggplot2::geom_vline(xintercept=FC_range[2],linetype = 'dashed', col=c("grey"))+
146150
ggplot2::geom_hline(yintercept=-log(pval_intercept,base = pval_log), col="black")
147151
{if(fixed_limit ==T){
148152
sem_res<-sem_res+ggplot2::xlim(x_limit[1], x_limit[2])+

0 commit comments

Comments
 (0)