This is an example of scatter plot where a simple trend line is added using R package {ggplot2}.
### Not to run ###
library(ggplot2)
# read in data set
d <- readRDS('data/covariates_w_AAA.rds')
# scatter plot of IEAA and EEAA T1 vs T2
d.plot <- data.frame(t1 = c(d$IEAA.t1, d$EEAA.t1),
t2 = c(d$IEAA.t2, d$EEAA.t2),
aa = rep(c('IEAA', 'EEAA'), each = nrow(d)))
p <- ggplot(d.plot, aes(x=t1, y=t2)) +
geom_point() + stat_smooth(method=lm) + facet_wrap(~ aa) +
scale_x_continuous(name='Time point 1') +
scale_y_continuous(name='Time point 2')
jpeg('results/scatterplot_AA_T1vsT2.jpg',
res = 300, height = 1500, width = 3000)
print(p)
dev.off()