set.seed(12346)
my.df <- data.frame(x = rnorm(50, sd = 4), y = rnorm(50, sd = 4))
# we assume that both x and y values are expressed as log2 fold change
ggplot(my.df, aes(x, y, colour = y)) +
geom_point(shape = "circle", size = 2.5) +
scale_x_logFC() +
scale_y_logFC() +
scale_colour_logFC()
ggplot(my.df, aes(x, y, fill = y)) +
geom_point(shape = "circle filled", colour = "black", size = 2.5) +
scale_x_logFC() +
scale_y_logFC() +
scale_fill_logFC()
my.labels <-
scales::trans_format(function(x) {log10(2^x)}, scales::math_format())
ggplot(my.df, aes(x, y, colour = y)) +
geom_point() +
scale_x_logFC(labels = my.labels) +
scale_y_logFC(labels = my.labels) +
scale_colour_logFC(labels = my.labels)
ggplot(my.df, aes(x, y, colour = y)) +
geom_point() +
scale_x_logFC(log.base.labels = 2) +
scale_y_logFC(log.base.labels = 2) +
scale_colour_logFC(log.base.labels = 2)
ggplot(my.df, aes(x, y, colour = y)) +
geom_point() +
scale_x_logFC(log.base.labels = 10) +
scale_y_logFC(log.base.labels = 10) +
scale_colour_logFC(log.base.labels = 10)
ggplot(my.df, aes(x, y, colour = y)) +
geom_point() +
scale_x_logFC(log.base.labels = 10) +
scale_y_logFC(log.base.labels = 10) +
scale_colour_logFC(log.base.labels = 10,
labels = FC_format(log.base.labels = 10,
log.base.data = 2L,
fmt = "% .*g"))
# override default arguments.
ggplot(my.df, aes(x, y, colour = y)) +
geom_point() +
scale_x_logFC() +
scale_y_logFC() +
scale_colour_logFC(name = "Change",
labels = function(x) {paste(2^x, "fold")})
Run the code above in your browser using DataLab