Volcano plot of Deseq2 data
1
0
Entering edit mode
3.2 years ago
aranyak111 • 0

I am trying to generate a series of volcano plots of differentially expressed genes. The code snippet I am using is based on https://biocorecrg.github.io/CRG_RIntroduction/volcano-plots.html.

The exact code I am using is 
data <- read.delim("E:/KDR-mir150 12.02.2021/KDR150diff.txt")
    >   View(data)
    > p <- ggplot(data=data, aes(x=log2FoldChange, y=-log10(padj))) + geom_point() + theme_minimal()
    Error in ggplot(data = data, aes(x = log2FoldChange, y = -log10(padj))) : 
      could not find function "ggplot"
    > 
    > library(ggplot2)
    > p <- ggplot(data=data, aes(x=log2FoldChange, y=-log10(padj))) + geom_point() + theme_minimal()
    > p2 <- p + geom_vline(xintercept=c(-0.6, 0.6), col="red") +
    +     geom_hline(yintercept=-log10(0.05), col="red")
    > data$diffexpressed[data$log2FoldChange >  >= 1 & data$pvalue < 0.05] <- "UP"
    Error: unexpected '>=' in "data$diffexpressed[data$log2FoldChange >  >="
    > data$diffexpressed[data$log2FoldChange >= 1 & data$pvalue < 0.05] <- "UP"
    > data$diffexpressed[de$log2FoldChange <= -1 & data$pvalue < 0.05] <- "DOWN"
    Error in de$log2FoldChange : object of type 'closure' is not subsettable
    > data$diffexpressed[data$log2FoldChange <= -1 & data$pvalue < 0.05] <- "DOWN"
    > p <- ggplot(data=data, aes(x=log2FoldChange, y=-log10(padj), col=diffexpressed)) + geom_point() + theme_minimal()
    > p2 <- p + geom_vline(xintercept=c(-0.6, 0.6), col="red") +
    +     geom_hline(yintercept=-log10(0.05), col="red")
    > p3 <- p2 + scale_color_manual(values=c("blue", "black", "red"))
    > 
    > mycolors <- c("blue", "red" )
    > names(mycolors) <- c("DOWN", "UP")
    > p3 <- p2 + scale_colour_manual(values = mycolors)
    > data$delabel <- NA
    > data$delabel[data$diffexpressed != "NO"] <- data$genename[data$diffexpressed != "NO"]
    > ggplot(data=data, aes(x=log2FoldChange, y=-log10(padj), col=diffexpressed, label=delabel)) + 
    +     geom_point() + 
    +     theme_minimal() +
    +     geom_text()
    > library(ggrepel)
    > ggplot(data=data, aes(x=log2FoldChange, y=-log10(padj), col=diffexpressed, label=delabel)) +
    +     geom_point() + 
    +     theme_minimal() +
    +     geom_text_repel() +
    +     scale_color_manual(values=c("blue",  "red")) +
    +     geom_vline(xintercept=c(-0.6, 0.6), col="red") +
    +     geom_hline(yintercept=-log10(0.05), col="red")

I want to have all the plots scaled by the same value on the y-axis to make proper comparisons. Where in the code I need to introduce the change to make the y-axis values uniform.

rna-seq • 2.2k views
ADD COMMENT
2
Entering edit mode
3.2 years ago

You can add + ylim(min_value, max_value) to your ggplot object.

For future reference you should remove any extraneous code when posting, to make it easier for people to view.

ADD COMMENT

Login before adding your answer.

Traffic: 2310 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6