Scatter plot when there is a standard error for both axes
1
1
Entering edit mode
8.2 years ago
devenvyas ▴ 740

I have f3 statistics in the form f3(Outgroup:POI_1, Comparative) and f3(Outgroup:POI_2, Comparative) and so on.

For a handful of pairs of POIs (populations of interest) and over a hundred comparative populations

For each pair of POIs, I want to make a scatter plot, where one f3 value is on the X axis and the others is on the Y axis, but I want both sets of standard errors graphed.

Basically, I want some conceptually similar to this plot from Allentoft et al. 2015 (http://www.nature.com/nature/journal/v522/n7555/fig_tab/nature14507_SF2.html).

R • 3.5k views
ADD COMMENT
0
Entering edit mode

You forgot to ask a question.

ADD REPLY
4
Entering edit mode
8.2 years ago

This is really an R "question", but here you go.

ADD COMMENT
0
Entering edit mode

Thanks! This seems to be working. By any chance do you happen to know how to get rid of the perpendicular bars on the end of each error bar or how to get it to read in what color each point should be?

ADD REPLY
0
Entering edit mode

You can use aesthetics, like for anything else in ggplot2 (http://docs.ggplot2.org/0.9.3.1/geom_errorbarh.html ).

ADD REPLY
0
Entering edit mode

I fixed the perpendicular bars, but I having some difficulty getting it to read colors from a column in my data table (titled color). Neither of these really work.

ggplot(data = tbl,aes(x = x,y = y),colour=color) +
  geom_point() +  
  geom_errorbar(aes(ymin = y-SEy,ymax = y+SEy,height=.00)) +
  geom_errorbarh(aes(xmin = x-SEx,xmax = x+SEx,height=.00)) +
  scale_color_identity() + geom_abline(intercept = 0, slope = 1)

ggplot(data = tbl,aes(x = x,y = y),colour=color) +
  geom_point() +  
  geom_errorbar(aes(ymin = y-SEy,ymax = y+SEy,height=.00)) +
  geom_errorbarh(aes(xmin = x-SEx,xmax = x+SEx,height=.00)) +
  scale_color_manual(values = as.character(tbl$color)) + geom_abline(intercept = 0, slope = 1)

Any clue what is going on?

ADD REPLY
0
Entering edit mode

Nope, that should work. Since this is no longer a bioinformatics question, you might ask this on an R forum.

ADD REPLY

Login before adding your answer.

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