Showing posts with label photography. Show all posts
Showing posts with label photography. Show all posts

Wednesday, 5 February 2014

Making figures for scientific papers

The next few blog posts (when I get round to doing them) are going to be a series of tutorials into common but neglected aspects of the academic process, such as how to make figures (this post), and how to submit/prepare data for GenBank (coming later). Very few students get taught how to do these things, so we just muddle our way through and learn along the way. Considering that these kind of activities are a central part of our research time, however, a little advice at the early stages can save a lot of effort.

What I won't be covering today though, is how to design good figures in the first place. There's enough information on that out there already. See, for example, the paper "A brief guide to designing effective figures for the scientific paper"; this article runs through dos and don'ts of making a figure to express your results clearly and effectively. What I will talk about, however, is how you actually put your figures together—what tools/processes are used, and how to be organised.

The basics

The really basic stuff is probably worth repeating. There are essentially two types of digital graphics: "raster" graphics (also known as "bitmap") and "vector" graphics. Raster graphics are comprised of entirely of coloured/shaded pixels, and as a result lose quality when you zoom in. Vector graphics (e.g. SVG, PDF, EPS) are comprised of instructions to draw objects, and so are scalable and therefore do not lose quality when zoomed in. Raster graphic formats (e.g. JPG, PNG, TIF) are for photographic images, and vector formats are for graphs, plots, diagrams, and cartoons. Raster images can be inserted into vector files (where they remain as raster), but not vice versa. Importantly in vector plots, the text remains as text. It amazes me how many rasterised phylogenetic trees I still see in journal articles. It might seems a trivial detail, but when you rasterise a tree, the names of the taxa in those trees become invisible to searching both within the PDF article, or by Web search engines.

Fig 1. Difference between raster and vector graphics

Software

So, what programs do we use to create/edit our figures? Well first of all, I will not be recommending any proprietary software. The reasons are threefold: (a) a lot of students work on their own personal machines, so it's unfair to make them spend their limited money on these expensive software packages; (b) with open-source software you can often use the same program on any operating system (Mac, Windows, Linux); and (c) there's no need, as the free tools are good enough. So, for generating the data plots I use the R statistical package with ggplot2 (the sort of equivalent of Microsoft Excel), for editing raster images I use Gimp (the equivalent of Adobe Photoshop), for maps I use QGIS (the equivalent of ArcGIS), and for putting it all together and making adjustments to vector figures I use Inkscape (the equivalent of Adobe Illustrator). Now I'm not pretending that Gimp, QGIS, and Inkscape are better than their paid-for equivalents, but they are free, and for academic use I think they do pretty much all that is needed.

Before we get started, though, here's one useful piece of advice: go to the Web site of the journal that you're intending to submit your manuscript to, and read the instructions for authors. Each journal has slightly different requirements, and knowing the specifics at the beginning makes things a lot easier. They will tell you the dimensions of the figures, the label formats, the fonts to use, etc. If you don't know where you will submit the article, just do something generic, but importantly, make it easy for yourself to change it as a later date; you will have to. The usual format journals want for vector graphics is EPS (sometimes PDF), while for pure raster graphics, it is usually TIFs at > 300 pixels per inch (ppi, but often also called dpi).

For plots/graphs

So, for a simple plot, my workflow is straightforward. In basic R graphics I just run the code (see below) which saves my plot as a PDF (I'd prefer to save directly as SVG, but R Cairo does not currently support editable text objects in SVG). You may have to make minor changes to the plot—such as trimming up margins, moving the axis labels or changing fonts etc—before it's good enough for publication. Here, we have two choices: (a) do all the plot polishing in R, and export as a final version EPS (to save as EPS, just change "pdf" to "postscript" in the code below); or (b) save as PDF, import into Inkscape, and make minor adjustments there. Generally I find that it's easier to do this kind of thing in Inkscape, rather than messing around with details too much in R. However, there is a law of diminishing returns here, which means that only very minor changes are worth doing by hand instead of taking the time to perfect the code in R. There's a good chance you will certainly have to make the plot several times in the end—co-author doesn't like it, reviewers don't like it, need to submit to different journal, etc—so think about this in advance and do the bulk of the work in R. If working on a plot in Inkscape, it is best to save it as a master copy in SVG (the native format of Inkscape), or if it's a big file, as a compressed SVG (SVGZ). You can export to EPS, PDF and a variety of other vector formats in Inkscape via the "File > Save a Copy" menu.

data(mtcars)#load up the car data that comes with R
pdf("carplot.pdf", useDingbats=FALSE)#open PDF file
plot(mtcars$mpg~mtcars$wt)#create plot
abline(lm(mtcars$mpg~mtcars$wt), col="red")#fit linear model
dev.off()#close PDF file

Fig 2. A basic, no frills R plot showing car MPG (efficiency) as function of car weight.
Fig 3. After editing the plot in Inkscape to reduce the margins and change the axis font
(please never use comic sans, it's just for illustrative purposes).

In a ggplot2 session, I do this (ggplot2 plots are pretty, so usually good-to-go with no editing at all):

library(ggplot2)#load ggplot2 library
data(mtcars)#load up the car data that comes with R
c <- ggplot(mtcars, aes(mpg, wt))#create plot
c + stat_smooth(method="lm", se=TRUE) + geom_point()#layers
ggsave("carplotgg.pdf")#save as PDF

Fig 4. A ggplot2 plot.

For mixed figure types such as multi-panel figures

Sometimes you'll need to combine several photographic images onto one figure. Again, I use Inkscape for this, but if I need to make any alterations such as contrast, brightness, or resolution, I do this first in Gimp (Inkscape cannot edit the image in this way). What I don't do is crop the photo in Gimp first. This can be done in Inkscape, and importantly, if you need to change the proportions of the figure, it can be reversed or re-edited at any later date from within the same file. A useful thing worth mentioning at this point, is the value of keeping a backed-up history of each version of the figure. This can be really handy, not only for getting out of trouble if you make mistakes, but also to keep your working folders free of dozens of copies of the same file. I recommend looking as git for this purpose.

Now, to import the raster images into Inkscape, go to "File > Import", choose the file and select the "embed" box. Align the imported objects using "View > Grid". You can also resize them by selecting them, and going to the "Object > Transform > Scale" menu, remembering to "scale proportionally" to keep the width/height ratio. Add any arrows or text boxes that are required. The format/colour of these can be changed by selecting the object and going to "Object > Fill and Stroke". A useful thing to know when making arrows in Inkscape, is that you need to go to "Extensions > Modify Path > Colour Markers to Match Stroke" in order to make the arrow head match the arrow shaft.

Journals generally want minimal margins on plots. In Inkscape I use "File > Document Properties > Resize page to drawing or selection" to trim the plot to just a few pixels round each of the edges. Experiment to see what looks best. Here's one I made earlier.

Fig 5. Two pygmy seahorse images edited onto a single figure with arrows and labels.

Again, I save this as a master copy SVG and work in that format. The figure can be exported as an EPS or PDF for the final version, but pay attention to the "resolution for rasterisation" option of the internal raster elements when you save (journals usually require 300 ppi or more, even if embedded in a vector file). Sometimes the file sizes can end up being quite big here, so what I often do when emailing figures to co-authors, or even when submitting a manuscript at the peer review stage, is to generate a low-resolution raster image for this purpose (high quality images are submitted later on in the review process). You can do this by going to "File > Export Bitmap" and select the page as the export area, and change the dpi to, say, 90. This will export a PNG file. Repeat at lower resolution if file size is still too big. Follow this process if the journal, for some strange reason, require the figure to be a raster image; if they do not accept PNG, you will need to open Gimp and export the PNG as a TIF.

In conclusion, I hope this provides some useful advice to get people started on making figures for their publications. Please don't hesitate to add any of your own nuggets of advice in the comments.

Tuesday, 21 December 2010

A method of photographing and preserving fishes for molecular studies

Voucher specimens are important in molecular studies, almost maybe as important as for morphological studies. A good voucher will be useful to both molecular and morphological research for many years to come; a good voucher will allow any misidentified specimens to be easily corrected, and will permit any interesting molecular results to be effectively corroborated with morphology.

But generating good vouchers in molecular studies is hard. Formalin, the fixative chemical of choice for ichthyologists, degrades DNA and makes extraction/PCR difficult (but see Zhang, 2010). Instead, ethanol can be used as a fixative, but ethanol fixed specimens are often brittle, faded, and of poorer long-term quality.

It's often best to take a tissue sample from your specimen, store this in ethanol, and formalin fix the rest of the fish as a voucher. This is fine, but you'll want to know which tissue sample comes from which specimen, and for small fishes it's not possible to permanently attach the label to the specimen without causing damage. Of course, you could put them all in individual jars, but you could soon run out of jars or space. Transporting them is a big problem too, and this is where you really need to save space.

So, after trying out some quite unsatisfactory methods, and ruining many good specimens, I have developed a nice method of generating quality molecular vouchers:

Step 1. Fill vials for tissue samples with high-grade 100% ethanol. Label the tubes internally with pencil on archive quality "goatskin" paper, and externally with marker pen. The vouchers can be kept separate using small polythene zip-seal bags. They need to be perforated first, however, with a paper hole punch (do several at a time). They should also have their bottom corners cut off to allow the bags to drain. Place another label in the bag.


Step 2. Get everything ready in advance. Here I have:

  • Latex gloves
  • 10% formalin (clearly labelled)
  • MS-222 (fish anaesthetic)
  • Spirit burner to decontaminate tools
  • Variety of forceps and scalpel
  • Pencil
  • Squares of cardboard to use as a clean surface for tissue preparation. 
  • Vials for tissue samples
  • Bags for voucher


Step 3. Assemble your light source and photo rig. Here I use an adjustable microscopy light (halogen desk lamps can be substituted) and a shallow white tray. I used a piece of folded graph paper as a scale for these photos. Now, mix up your MS-222 (overdosed) and water into a shallow clear tray (the lid of a tube rack), and the fish can now be added (wait for 10 mins to ensure death). Make sure the fish is only just covered.


Step 4. Adjust the light angle and photograph the left-hand side of the fish, always adding the label. Remember to set your camera's white balance correctly (usually using the custom mode). The picture can then be cropped and the file name changed.



Step 5. Take the fish out of the solution and place on the card sheet. Use the scalpel to carefully excise a tissue sample from the right-hand side of the fish. Pectoral fin clips can also be taken to cause less damage, but on small fishes this won't yield much tissue, and using mitochondrion rich muscle may reduce the likelihood of numts (Song et al., 2008).

Note: don't cut from the caudal peduncle area if characters such as caudal peduncle scale counts may be important for identifying your fish.


Step 6. Next, place the fish into the plastic bag with the forceps, and place into the formalin. The position of the fish and fins can be manipulated through the holes in the bag with the forceps. This ensures the fish is not bent and the fins are not folded down.



Step 7. Throw away the card sheet and replace with new. Clean the implements with a wet tissue and then sterilise with the spirit burner. Repeat process for rest of specimens.

Step 8. Leave vouchers in formalin for approximately three days (longer for larger fishes). After three days, remove from formalin and wash thoroughly with water. Leave in water for 24 hours to dilute remaining formalin. Place into weak 35% alcohol (ethanol or clear methylated spirit) solution for three days before final storage in 70% alcohol. The voucher will have lost a lot of its colour by now, but can be photographed again to document the preserved colour pattern.


Of course, these bags have not been tested for long-term (i.e. indefinite) storage, and are only recommended as a temporary (<5yr) storage or transport solution.

In addition, although I haven't yet tested it, this method could hopefully be adapted for use in the field.