Skip to content

Instantly share code, notes, and snippets.

@stephenturner
Last active May 13, 2021 20:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save stephenturner/4a599dbf120f380d38e7 to your computer and use it in GitHub Desktop.
Save stephenturner/4a599dbf120f380d38e7 to your computer and use it in GitHub Desktop.
code from blog post to make a volcano plot
# Download the data from github (click the "raw" button, save as a text file called "results.txt").
# https://gist.github.com/stephenturner/806e31fce55a8b7175af
res <- read.table("results.txt", header=TRUE)
head(res)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-2.5,2)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
with(subset(res, abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, padj<.05 & abs(log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
# Label points with the textxy function from the calibrate plot
library(calibrate)
with(subset(res, padj<.05 & abs(log2FoldChange)>1), textxy(log2FoldChange, -log10(pvalue), labs=Gene, cex=.8))
@Verakhs
Copy link

Verakhs commented Feb 8, 2015

when I install your package and I try to get the exact file, I get the following error
res <- read.gist("806e31fce55a8b7175af", header=TRUE)
Error: could not find function "read.gist"

@Abhijeetbasu
Copy link

go to the git hub using this link https://gist.github.com/stephenturner/806e31fce55a8b7175af
download the Results file, it will be a Text File.
open Excel and then open the results file within excel and save it as .CSV format. its important to know where u have saved the file, which
means u should know the path. for example if you save it in desktop
then use this command
res <- read.csv(File = "C:\Users\name\Desktop\Results.csv", Header = T, Sep",")
head(res)

it should work!

@DimitriosManias
Copy link

Hello! I have a problem in highlighting the significant genes. When I am using your data set, everything goes fine. But when I am trying with my data set I color the whole volcano plot red/orange. I have named everything exactly as here but still doesn't work. I checked my data set and it does contain genes with p.adj.values<.05. Do you have any idea why is this happening?
Btw we have tried with both csv and txt files, with two different computers, two different people but always the same annoying result!

@manajit-das
Copy link

Thanks

@ligrossman
Copy link

When labeling points, is there a way to keep the labels from overlapping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment