Reputation: 351
I am making plot in attach using this:
p = ggplot(y2, aes(logFC, -log10(adj.P.Val))) +
geom_point(aes(col=sig)) +
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
) +
scale_color_manual(values=c("gray", "red")) +
ggtitle("Response to glucose No_DM, No_PDR and PDR") +
xlab("log2FC")
p + geom_text_repel(
data = filter(y2, adj.P.Val<qval.cutoff & abs(logFC) > FC.cutoff),
aes(label = geneSymbol)
) + xlim(-0.3,0.3)
p
The problem is that text labels over red dots are not showing. I should add that using geom_text() gives the same result, not text labels over red dots.
My data looks like this:
head(y2)
ID geneSymbol geneName logFC AveExpr t P.Value adj.P.Val B
1 fSUyR.vR7Xu0iR4nUU TXNIP thioredoxin interacting protein 0.2234088 9.541793 8.415327 3.242297e-12 5.047609e-08 17.238861
2 33obrCQopAnZlAmA1Y HIST1H2AC histone cluster 1 H2A family member c 0.1557544 8.294461 6.818566 2.720443e-09 2.117593e-05 10.960907
3 B.MnES5zlIlJgt51ZU HIST1H2BJ histone cluster 1 H2B family member j 0.1642828 7.674182 6.495074 1.043064e-08 5.412808e-05 9.704442
4 Ebfrl.7uOZfnjp_E7k EGR1 early growth response 1 -0.1641590 9.285850 -6.354245 1.864866e-08 6.262890e-05 9.161173
5 iSYLWdWZUIKnYICW4c HIST1H2BK histone cluster 1 H2B family member k 0.1613979 9.914578 6.278442 2.546608e-08 6.262890e-05 8.869853
6 oB.usjxziFJJd51SUk CCL4L1 C-C motif chemokine ligand 4 like 1 -0.1720790 9.926583 -6.254667 2.807540e-08 6.262890e-05 8.778649
sig
1 pval.cutoff
2 Not Sig
3 Not Sig
4 Not Sig
5 Not Sig
6 pval.cutoff
sapply(y2,class)
ID geneSymbol geneName logFC AveExpr t P.Value adj.P.Val B sig
"character" "character" "character" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "character"
Upvotes: 0
Views: 4448
Reputation: 123783
(: Your last call to p
shows the base plot without the added labels. Try
p <- p + geom_text_repel(
data = filter(y2, adj.P.Val<qval.cutoff & abs(logFC) > FC.cutoff),
aes(label = geneSymbol)
) + xlim(-0.3,0.3)
p
Should show you the plot and worked for me. Code:
df <- tibble(
geneSymbol = c("TXNIP", "HIST1H2AC", "HIST1H2BJ"),
logFC = c(0.2234088, 0.1557544, 0.1642828),
adj.P.Val = c(5.047609e-08, 2.117593e-05, 5.412808e-05),
sig = c("pval.cutoff", "Not Sig", "Not Sig")
)
p <- ggplot(df, aes(logFC, -log10(adj.P.Val))) +
geom_point(aes(col=sig)) +
scale_color_manual(values = c("gray", "red")) +
ggtitle("Response to glucose No_DM, No_PDR and PDR") +
xlab("log2FC")
p <- p + ggrepel::geom_text_repel(
data = filter(df, sig == "pval.cutoff"), aes(label = geneSymbol))
p
Upvotes: 2
Reputation: 123783
Have you checked that the data used in geom_text_repel
, i.e. data = filter(y2, adj.P.Val<qval.cutoff & abs(logFC) > FC.cutoff)
, is a non-empty data.frame?
As sig
is mapped on the color aesthetic, why not simply filter on the value in sig
, i.e. filter(y2, sig == "pval.cutoff")
?
Upvotes: 1