using the following R Script i want to generate Volcano plot.but my volcano plot is not correct because their is no connecting point between -logpvalue and log2foldchange value if i run the example as provided on web i get the corrected one its mean the script is correct but something is wrong in my data i try alot but not able to identify the mistake.help me in this regard.
My data:
Gene log2FoldChanges pvalue pvalue
CAR3 -2.024 0.0103 0.0103
SAA2 -2.019 0.0624 0.0624
GADD45A -1.752 0.0015 0.0015
SAA1 -1.599 0.0735 0.0735
NREP -1.265 0.0210 0.021
GM6484 -1.134 0.0034 0.0034
ARRDC3 -1.085 0.0104 0.0104
NRP1 -1.082 0.0108 0.0108
TGM1 -1.072 0.0070 0.007
CYP7A1 -1.068 0.0128 0.0128
RNF186 -1.020 0.0054 0.0054
PIK3CD -1.003 0.0007 0.0007
SOCS3 -0.963 0.0193 0.0193
F3 -0.945 0.0059 0.0059
MID1IP1 -0.942 0.0116 0.0116
SERINC3 -0.941 0.0006 0.0006
GCK -0.933 0.0000 0
Code
res <- read.table("results.txt", header=TRUE)
head(res)
alpha <- 0.05 # Threshold on the adjusted p-value
cols <- densCols(res$log2FoldChange, -log10(res$pvalue))
plot(res$log2FoldChange, -log10(res$pvalue), col=cols, panel.first=grid(),
main="Volcano plot D3 VS D1", xlab="log2(fold-change)", ylab="pvalue",
pch=20, cex=0.6)
abline(v=0)
abline(v=c(-1,1), col="brown")
abline(h=-log10(alpha), col="brown")
with(subset(res, pvalue>alpha | abs(log2FoldChange)<.6), points(log2FoldChange, -log10(pvalue), pch=20, col="blue"))
with(subset(res, pvalue<alpha | abs(log2FoldChange)<.6), points(log2FoldChange, -log10(pvalue), pch=20, col="black"))
with(subset(res, pvalue>alpha | abs(log2FoldChange)>.6), points(log2FoldChange, -log10(pvalue), pch=20, col="black"))
with(subset(res, pvalue<alpha & abs(log2FoldChange)>=.6 & pvalue<.5 & abs(log2FoldChange)<1), points(log2FoldChange, -log10(pvalue), pch=20, col="orange"))
with(subset(res, pvalue<alpha & abs(log2FoldChange)>=1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
Please use the formatting bar (especially the
code
option) to present your post better. You can use backticks for inline code (`text` becomestext
), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.Thanks for your suggestion i will do that.
Could just use this: EnhancedVolcano: Publication-ready volcano plots with enhanced colouring and labeling
I tried but always get this error message
That error is not related to the GitHub repository. It is likely some local issue, i.e., a problem on your side of things. Check that there are no restrictions in place for downloading and installing.
Its not possible to download on my lab PC i will try it on my laptop hopefully it will work thanks for your help stay bless!
For your data, here is the example code and plot:
Thanks how can i add the names of the significant genes in a more good way and avoid the overlapping and also put the connector.
try this:
For partial labeling:
thanks for the code I try it but it always gives this error
geom_text_repel is from the package ggrepel. So,:
Is there any way to put the names of the Genes having high fold change values with connectors.? using Calibrate library.
here is my code
You can easily do that with EnhancedVolcano by setting thresholds for log2FC and / or specifying your genes of interest with
selectLab
. Finally, to draw the connectors, setdrawConnectors = TRUE
. If you want boxes around the labels, setboxedLabels = TRUE
.An example of this, HERE