By default, the
gglogo package uses polygons created from a Helvetica font to use for creating logo plots. These polygons are stored in the object
alphabet.rda, and use the name of the letter or digits they describe as their group identifier:
## x y order group pathGroup ## 1 0.1208333 0.004854369 1 A A.1 ## 2 0.1229167 0.007281553 2 A A.1 ## 3 0.4437500 1.000000000 3 A A.1 ## 4 0.5729167 1.000000000 4 A A.1 ## 5 0.8833333 0.000000000 5 A A.1 ## 6 0.7604167 0.000000000 6 A A.1
Each letter and digit is scaled to an area between 0 and 1 in y direction (which makes the lower case letter ‘c’ as tall as its upper case counterpart). In x direction the letter scaled proportionally to its extent in y direction.
In order to change the alphabet used, an alphabet object has to be created, and the link to the object has to be changed so that the logo plots use the correct alphabet in the rendering process.
createPolygons have parameters to choose the font family and the set of letters for which polygons are supposed to be created. The parameters
fontsize are only needed, if some letters appear to be chopped off. In that case, the dimension of the image should be increased and/or fontsize should be decreased.
alphas <- c(LETTERS, letters, 0:9) alphabet_garamond <- createPolygons(alphas, font="Garamond") alphabet_garamond$group <- factor(alphabet_garamond$group, levels=alphas) ggplot(alphabet_garamond, aes(x = x, y = y, group = group)) + geom_polygon(aes(subgroup=pathGroup)) + facet_wrap(~group, ncol = 13)
For use as alphabet in the logo geom, letters have to be scaled to fill the full extent in y-direction so as to fill the surrounding rectangles. Setting the parameter
scale to TRUE regulates this.
Logo plot of peptide sequences, first with the unscaled Helvetica alphabet:
## Warning: `cols` is now required. ## Please use `cols = c(position, element)`