This is a test version of Biostars. For the public version, visit https://www.biostars.org.
can not transpose ggplot2 smooth line

Hi,

I was trying to draw scatter plots with smooth lines using ggplot2. When I transpose X/Y axis (data), the smooth line didn't.

I thought smooth lines were to show the trend of data. Am I misunderstanding?

When I changed below

p <- qplot(
  log2(countsNormalized[,1]+1),
  log2(countsNormalized[,4]+1),
  xlab="A",
  ylab="B",
  alpha=0.9)
p + 
  geom_smooth(method="lm",se=F) +
  geom_abline(intercept = 0,linetype="dotted") +
  geom_point(size=3) +
  stat_smooth_func(geom="text",method="lm",hjust=0,parse=TRUE)

to next

p <- qplot(
  log2(countsNormalized[,4]+1),
  log2(countsNormalized[,1]+1),
  xlab="A",
  ylab="B",
  alpha=0.9)
p +
  geom_smooth(method="lm",se=F) +
  geom_abline(intercept = 0,linetype="dotted") +
  geom_point(size=3) +
  stat_smooth_func(geom="text",method="lm",hjust=0,parse=TRUE)

the smooth line stayed the same.

Any ideas would be helpful. Thanks.

ggplot2 rna-seq r

By the way, how can I put picture here?

1 answer

Instead of swapping the axes around in the columns, you can just use + coord_flip().

Check out: http://docs.ggplot2.org/0.9.3.1/coord_flip.html for implementations.

Log in to answer this question.