geom_point, indicate data points outside plot
1
0
Entering edit mode
6.8 years ago
Mike ▴ 60

On this plot, data points that are outside the limits of the plot are pointed to using triangles:

https://i.imgur.com/ScTCGMw.png from http://www.bioconductor.org/help/workflows/rnaseqGene/#ma-plot

Is it possible to do something similar using ggplot2 (geom_point)?

Thank you.

geom_point • 2.3k views
ADD COMMENT
1
Entering edit mode
6.8 years ago
russhh 5.7k

I'm guessing your example data looks something like:

xs <- data.frame(aveCPM = 1:6, logFC = c(0.5, 10, -0.2, 0.1, -0.4, -2))

Then you can basically do this (you'll presumably want to drop the legend and fix the colours):

library(ggplot2)
library(dplyr)

xs %>%
    dplyr::mutate(
        out_of_bounds = abs(logFC) > 3,
        logFC = ifelse(out_of_bounds, 3 * sign(logFC), logFC)
        ) %>%
    ggplot(aes(x = aveCPM, y = logFC, shape = out_of_bounds)) +
    geom_point() +
    ylim(-3, 3)
ADD COMMENT

Login before adding your answer.

Traffic: 2191 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