This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Scatter plot when there is a standard error for both axes

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

You forgot to ask a question.

1 answer

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

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?

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?

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

Log in to answer this question.