<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>ggplot2 | The Evolutionary Biochemist</title>
    <link>https://evolutionaryBiochemist.com/category/ggplot2/</link>
      <atom:link href="https://evolutionaryBiochemist.com/category/ggplot2/index.xml" rel="self" type="application/rss+xml" />
    <description>ggplot2</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Sat, 09 May 2026 00:37:00 +0000</lastBuildDate>
    <image>
      <url>https://evolutionaryBiochemist.com/media/icon_hua2ec155b4296a9c9791d015323e16eb5_11927_512x512_fill_lanczos_center_3.png</url>
      <title>ggplot2</title>
      <link>https://evolutionaryBiochemist.com/category/ggplot2/</link>
    </image>
    
    <item>
      <title>ggchemplot: an R package for publication-quality 2D chemical structures</title>
      <link>https://evolutionaryBiochemist.com/tools/ggchemplot_v_0_2_1/</link>
      <pubDate>Sat, 09 May 2026 00:37:00 +0000</pubDate>
      <guid>https://evolutionaryBiochemist.com/tools/ggchemplot_v_0_2_1/</guid>
      <description>


&lt;p&gt;This week I faced a situation that many biochemists should relate: preparing figures for a paper in which you have to draw chemical structures. The commercial software &lt;a href=&#34;https://revvitysignals.com/products/research/chemdraw&#34;&gt;ChemDraw&lt;/a&gt;, initially developed in 1985 &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-Evans2014&#34;&gt;Evans, 2014&lt;/a&gt;)&lt;/span&gt;, still is the gold standard for drawing publication-quality 2D chemical structures. Because the signature is expensive and the free software available did not met my needs, I started to look for alternatives in R, specially as a &lt;code&gt;ggplot2&lt;/code&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-ggplot2&#34;&gt;Wickham, 2016&lt;/a&gt;)&lt;/span&gt; extension. I reasoned that such a fundamental kind of visualization in (bio)chemical and medical sciences would count with a nice R package. There was none.&lt;/p&gt;
&lt;p&gt;My next move was to load as a &lt;code&gt;dataframe&lt;/code&gt; in R a &lt;a href=&#34;https://de.wikipedia.org/wiki/Structures_Data_File&#34;&gt;Structure Data File&lt;/a&gt; (SDF) of a 2D chemical compound downloaded from &lt;a href=&#34;https://pubchem.ncbi.nlm.nih.gov/&#34;&gt;PubChem&lt;/a&gt;. The file specify atoms and coordinates. That’s all we need for &lt;code&gt;ggplot2&lt;/code&gt;. After the initial plot, I realized that I could make something out of it. After four days writing functions and packaging them, today I used it for creating a figure for my manuscript. Here, I will show how my first &lt;code&gt;ggplot2&lt;/code&gt; extension might help you, R user.&lt;/p&gt;
&lt;div id=&#34;the-ggchemplot-r-package&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;The &lt;code&gt;ggchemplot&lt;/code&gt; R package&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;ggchemplot_logo.png&#34; style=&#34;width:50.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The workflow of &lt;code&gt;ggchemplot&lt;/code&gt; follows three steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Parse a SDF file with &lt;code&gt;ggchemplot1()&lt;/code&gt;.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Visualize the preliminary plot and modify the data with helper functions for polishing.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Plot the final visualization with &lt;code&gt;ggchemplot2()&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;short-tutorial&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Short tutorial&lt;/h1&gt;
&lt;p&gt;Install the package from my &lt;a href=&#34;https://github.com/JPFQueiroz/ggchemplot&#34;&gt;GitHub&lt;/a&gt; repository.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Install the remotes package if not already installed
install.packages(&amp;quot;remotes&amp;quot;)

# Install ggchemplot from GitHub
remotes::install_github(&amp;quot;JPFQueiroz/ggchemplot&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The input file in this example (&lt;code&gt;P1_pyridone.sdf&lt;/code&gt;) was prepared through the drawing tool of &lt;a href=&#34;https://pubchem.ncbi.nlm.nih.gov/&#34;&gt;PubChem&lt;/a&gt;. Other R users might also prepare the input structure directly from R with &lt;code&gt;rcdk&lt;/code&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-Guha2007&#34;&gt;Guha, 2007&lt;/a&gt;)&lt;/span&gt;. Use &lt;code&gt;ggchemplot1&lt;/code&gt; to parse the file and generate the initial data object.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;
# Load ggchemplot
library(ggchemplot)

# Parse the data and generate initial plot
p1 &amp;lt;- ggchemplot1(sdf_file = &amp;quot;P1_pyridone.sdf&amp;quot;)

# Check the initial plot
p1$plot
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;example1.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Quickly visualize the atom and bond ids in &lt;code&gt;p1$atoms&lt;/code&gt; on the plot with the argument &lt;code&gt;show_ids = TRUE&lt;/code&gt; in &lt;code&gt;ggchemplot2()&lt;/code&gt;. The ids visualization can guide through the polishing step, where many functions use as argument ids of atoms or bonds.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;
# Load dplyr to use the pipe operator %&amp;gt;% 
library(dplyr)

p1 %&amp;gt;% 
  ggchemplot2(show_ids = TRUE)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;example2.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Polish the visualization using the arguments available in &lt;code&gt;ggchemplot1()&lt;/code&gt;, modifying the underlying data with helper functions or through manual wrangling of the &lt;code&gt;dataframe&lt;/code&gt; objects, and finally to &lt;code&gt;ggchemplot2()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;
# Publication-quality plot
p1 &amp;lt;- ggchemplot1(
  sdf_file = &amp;quot;P1_pyridone.sdf&amp;quot;,
  title = NULL,
  collapse_hydrogens = TRUE,
  rotation = 90,
  label_padding = 1,
  show_atom_circles = TRUE,
  hide_carbon_circles = TRUE,
  circle_stroke = 0,
  show_atom_labels = TRUE,
  hide_carbon_labels = TRUE,
  bond_width = 2,
  atom_size = 18,
  label_size = 12,
  double_bond_offset = 0.3,
  custom_atom_colors = NULL,
  paint_it_black = TRUE,
  H_offset = c(0.50, 1)) %&amp;gt;% 
  change_label(atom_id = 7, new_label = &amp;quot;Fe&amp;quot;) %&amp;gt;% 
  add_hashed_bond(from_id = 7, to_id = 11, 
                  wedge_thickness = 0.3,n_hashes = 6,
                  shorten = c(0.3, 0)) %&amp;gt;% 
  ggchemplot2()

# Plot
p1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;example3.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The basic tutorial ends here. You can cite &lt;code&gt;ggchemplot&lt;/code&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-ggchemplot&#34;&gt;Fernandes-Queiroz, 2026&lt;/a&gt;)&lt;/span&gt; in your publications using the BibTex citation below. Your feedback is welcome.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@software{ggchemplot,
  author       = {João Pedro Fernandes Queiroz},
  title        = {JPFQueiroz/ggchemplot: ggchemplot: an R package for visualization of chemical structures},
  month        = may,
  year         = 2026,
  publisher    = {Zenodo},
  version      = {v0.2-beta.1},
  doi          = {10.5281/zenodo.20088880},
  url          = {https://doi.org/10.5281/zenodo.20088880},
}&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2 unnumbered&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34; entry-spacing=&#34;0&#34; line-spacing=&#34;2&#34;&gt;
&lt;div id=&#34;ref-Evans2014&#34; class=&#34;csl-entry&#34;&gt;
Evans, D. A. (2014). History of the harvard ChemDraw project. &lt;em&gt;Angewandte Chemie International Edition&lt;/em&gt;, &lt;em&gt;53&lt;/em&gt;(42), 11140–11145.
&lt;/div&gt;
&lt;div id=&#34;ref-ggchemplot&#34; class=&#34;csl-entry&#34;&gt;
Fernandes-Queiroz, J. P. (2026). &lt;em&gt;JPFQueiroz/ggchemplot: Ggchemplot: An r package for visualization of chemical structures&lt;/em&gt; (Version v0.2-beta.1) [Computer software]. Zenodo. &lt;a href=&#34;https://doi.org/10.5281/zenodo.20088880&#34;&gt;https://doi.org/10.5281/zenodo.20088880&lt;/a&gt;
&lt;/div&gt;
&lt;div id=&#34;ref-Guha2007&#34; class=&#34;csl-entry&#34;&gt;
Guha, R. (2007). Chemical informatics functionality in r. &lt;em&gt;Journal of Statistical Software&lt;/em&gt;, &lt;em&gt;18&lt;/em&gt;(6).
&lt;/div&gt;
&lt;div id=&#34;ref-ggplot2&#34; class=&#34;csl-entry&#34;&gt;
Wickham, H. (2016). &lt;em&gt;ggplot2: Elegant graphics for data analysis&lt;/em&gt;. Springer-Verlag New York. &lt;a href=&#34;https://ggplot2.tidyverse.org&#34;&gt;https://ggplot2.tidyverse.org&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>
