Friday, December 25, 2015

Exporting high resolution TIFF chromatograms from Agilent 1100/1200 HPLC ChemStation



Few years ago I have faced a problem of exporting HPLC chromatograms from Agilent ChemStation software into image file with resolution which was mostly required by scientific journals (300 dpi). One of the options is to use ‘Graphics/Copy to Clipboard’ and then to paste it to PhotoShop new file, but even if you try to trick the system with pasting it to 300 dpi new file, it is still rasterized 72 dpi image (Figure 1). Other option is to use some of image printing devices like PostScript, MS Office Image (or XPS Document) Writer and PDF Writers. None of these options have completely solved my problem, although I had some success, but with lots of PhotoShop struggling. I have tried to search for some simple exporting protocol on the internet, but I couldn’t find any.
Figure 1. Image exported in old fashion way (72 dpi imported in 300 dpi)


Hereby, I would like to share some adjustable R code which could be the answer I was looking for. First you will have to do is to export chromatogram in two column data frame. You have to be careful when you loading the signal at the very start of this protocol. It is crucial to load only one signal. Than you have to export it by 'File/Export File/CSV File...' than choose ‘Signal’ option and check box ‘Write to Clipboard’ at the bottom of the dialog. Click OK, then again OK. Then open Notepad and paste it there. This step is important because original values are followed by some NULL characters, which are swiped away in Notepad. Than copy and paste this values into Excel document and save this document as 'name.csv' (in our example 'helichrysum.csv'). That would be all preparation that you need. Now run the code.


 library(ggplot2)
 library(Hmisc)  
 df <- read.csv("./data/helichrysum.csv", header = FALSE)  
 names(df) <- c("time", "signal")  
 tiff(filename = "./data/helichrysum.tiff",  
     width = 3000, height = 1300,  
     units = "px", pointsize = 12,  
     compression = c("lzw"),  
     bg = "white", res = 300,  
     type = c("cairo"))  
 par(mfrow=c(1,1), mar=c(2, 3, 1, 1), las=1)  
     plot(df$time, df$signal, type = "l",  
        xlab = "", ylab = "", xaxs="i",yaxs="i",  
        ylim = c(-40, 760), xlim = c(0, 40),  
        bty="n", xaxt="n", yaxt = "n")  
     axis(1, at = seq(0, 40, 5),  
        labels = c("", "5", "10", "15", "20", "25", "30", "35", "min"),  
        cex.axis = 0.8, cex.lab = 0.8, tck = -0.01,  
        mgp = c(3, 0.1, 0))  
     axis(2, at = c(-40, 0, 100, 200, 300, 400, 500, 600, 700, 760),  
        labels = c("", "0", "100", "200", "300", "400", "500", "600","700", "mAU"),  
        cex.axis = 0.8, cex.lab = 0.8, tck = -0.01,  
        mgp = c(3, 0.4, 0))  
     minor.tick(nx=10, ny=10, tick.ratio=0.2)  
 dev.off()  


The TIFF printing result (helichrysum.tiff) is presented in Figure 2.


Figure 2. HPLC chromatogram processed with R code (300 dpi)

Of course, you can adjust axes depending on your peak abundance and analysis run time.
Have a nice publishing!

Example data: https://github.com/Shansh/chromatography/blob/master/helichrysum.csv