code: def draw_quality_plot(db_file, plot_file, position_select, title):
      
      robjects.r.assign('db.file', db_file)
      robjects.r.assign('plot.file', plot_file)
      robjects.r.assign('position.select', position_select)
      robjects.r.assign('title', title)
      robjects.r('''
        library(sqldf)
        library(plyr)
        library(ggplot2)
        sql <- paste("select * from data WHERE position", position.select, sep=" ")
        exp.data <- sqldf(sql, dbname=db.file)
        remap.data <- ddply(exp.data, c("orig", "remap"), transform, count=sum(count))
        p <- ggplot(remap.data, aes(orig, remap)) +
             geom_tile(aes(fill = count)) +
             scale_fill_gradient(low = "white", high = "steelblue", trans="log") +
             opts(panel.background = theme_rect(fill = "white"),
                  title=title) +
             geom_abline(intercept=0, slope=1)
        ggsave(plot.file, p, width=6, height=6)
      ''')
docs: Draw a plot of remapped qualities using ggplot2.
  
      Remapping information is pulled from the sqlite3 database using sqldf
      according to the position select attribute, which is a selection phrase like
      '> 50' or '=28'.
  
      plyr is used to summarize data by the original and remapped score for all
      selected positions.
  
      ggplot2 plots a heatmap of remapped counts at each (original, remap)
      coordinate, with a x=y line added for reference.