7 Supplementary Figure 01

This is the accessory documentation of Supplementary Figure 01. It explains the steps of script 2.2.0.1.maf2circos.sh and documents progression from the whole genome alignment of the de novo Hypoplectrus puella genome assembly with the Gasterosteus aculeatus reference genome.

7.1 Preparation

First we switch to the directory containing the full genome alignment (synteny.maf) which was created by script 1.2.8.Hp2Ga.sh.

cd $WORK/1-output/08_Synteny

From the alignment we create circos compatible links which will be place in the circos-base/data folder. The transformation includes:

  • reformatting
  • the renaming of the stickleback Linkage groups (from Roman to Arabic)
  • dropping alignments on unanchored Scaffolds
  • filtering for alignments larger than 5kb
awk 'NF{NF-=1};1' synteny.maf | \
    grep -v "^#" | grep '^s'|  \
    awk '{print $2,"\t",$3,"\t",$3+$4 }' | \
    paste - -  | \
    sed 's/chrI /ga01 /g; s/chrII /ga02 /g; s/chrIII /ga03 /g; s/chrIV /ga04 /g; s/chrV /ga05 /g'| \
    sed 's/chrVI /ga06 /g; s/chrVII /ga07 /g; s/chrVIII /ga08 /g; s/chrIX /ga09 /g; s/chrX /ga10 /g'| \
    sed 's/chrXI /ga11 /g; s/chrXII /ga12 /g; s/chrXIII /ga13 /g; s/chrXIV /ga14 /g; s/chrXV /ga15 /g'| \
    sed 's/chrXVI /ga16 /g; s/chrXVII /ga17 /g; s/chrXVIII /ga18 /g; s/chrXIX /ga19 /g; s/chrXX /ga20 /g'| \
    sed 's/chrXXI /ga21 /g; s/chrM /gaM /g' | \
    sed '/^Contig/d' | \
    sed 's/LG/hp/g' | awk -v sz=5000 '$3-$2>sz || $2-$3>sz{print}' > $WORK/3_figures/S01/data/links.txt

We then switch to the circos base folder and run circos to plot the alignments.

cd $WORK/3_figures/S01

# basic plot with circos
circos -conf confs/circos.conf

Afterwards we use the S01.R script to annotate the alignment plot.

# annotation with R
cd $WORK/3_figures/F_scripts

Rscript --vanilla S01.R
rm Rplots.pdf

7.2 Content of circos_figure.R

The circos_figure.R is an executable R script that depends on a variety of image manipulation packages:

library(grid)
library(gridSVG)
library(grImport2)
library(grConvert)
library(tidyverse)
library(cowplot)

The first step is to convert the original circos plot to a cairo svg for further handling.

convertPicture("circos.svg",'circos-cairo.svg')

Then we load the converted image, as well as the annotation elements and store them as Grid Objects.

cir <- gTree(children=gList(pictureGrob(readPicture("circos-cairo.svg"))))
GA <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/GA-cairo.svg"))))
HP <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/puella-cairo.svg"))))

Finally, we put together the original plot and the annotation elements using the ggdraw() from the cowplot package.

S01 <- ggdraw()+
  draw_grob(cir, -.05,-.05,1.1,1.1)+
  draw_grob(GA, 0, .84, .25, .2)+
  draw_grob(HP, 0.75,.83,.25,.2)

The resulting plot is than exported to be figure S01.pdf.

ggsave(plot = S01,filename = 'S01.pdf',width = 183,height = 183,units = 'mm',device = cairo_pdf)