gravatar for aranyak111

3 hours ago by

I am trying to generate a series of volcano plots of differentially expressed genes. The code snippet I am using is based on 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.



Source link