Skip to content

Latest commit

 

History

History

docs

<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>depict • depict</title>


<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>

<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous" />

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>

<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>

<!-- pkgdown -->
<link href="pkgdown.css" rel="stylesheet">
<script src="pkgdown.js"></script>




<meta property="og:title" content="depict" />




<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->



  </head>

  <body>
    <div class="container template-title-body">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="index.html">depict</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="index.html">
    <span class="fas fa fas fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="reference/index.html">Reference</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header>

<div class="row">
  <div class="contents col-md-9">
    <div class="page-header">
      <h1>depict</h1>
    </div>


<hr>
<div id="output-github_document" class="section level2">
<h2 class="hasAnchor">
<a href="#output-github_document" class="anchor"></a>output: github_document</h2>
<!-- README.md is generated from README.Rmd. Please edit that file -->
</div>
<div id="depict" class="section level1">

<p>depict is an R wrapper around the wonderful depiction api written by <a href="https://github.com/johnmay">John May</a>. The entire <a href="https://github.com/cdk">CDK</a> team, but especially John, have been steadily improving the visualization features of CDK. The depiction API is succinct and powerful and provides access to a vary large amount of the end-user desired functionality with a small number of composable functions. Because of the design of this API it is now relatively straightforward to design a simple streamlined interface to allow users to quickly and easily generate beautiful graphics.</p>
<div id="installation" class="section level2">
<h2 class="hasAnchor">
<a href="#installation" class="anchor"></a>Installation</h2>
<p>You can install depict from github with:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a><span class="co"># install.packages("devtools")</span></span>
<span id="cb1-2"><a href="#cb1-2"></a>devtools<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/devtools/man/remote-reexports.html">install_github</a></span>(<span class="st">"CDK-R/depict"</span>)</span></code></pre></div>
</div>
<div id="example" class="section level2">
<h2 class="hasAnchor">
<a href="#example" class="anchor"></a>Example</h2>
</div>
<div id="simple-depiciton" class="section level2">
<h2 class="hasAnchor">
<a href="#simple-depiciton" class="anchor"></a>Simple Depiciton</h2>
<p>A simple wrapper around cdk’s excellent depict module.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(depict)</span>
<span id="cb2-2"><a href="#cb2-2"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(magrittr)</span>
<span id="cb2-3"><a href="#cb2-3"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(grid)</span>
<span id="cb2-4"><a href="#cb2-4"></a></span>
<span id="cb2-5"><a href="#cb2-5"></a><span class="co"># you must supply java colors </span></span>
<span id="cb2-6"><a href="#cb2-6"></a>color &lt;-<span class="st"> </span><span class="kw">J</span>(<span class="st">"java.awt.Color"</span>)</span>
<span id="cb2-7"><a href="#cb2-7"></a></span>
<span id="cb2-8"><a href="#cb2-8"></a><span class="co"># load in penicillin</span></span>
<span id="cb2-9"><a href="#cb2-9"></a>pen  &lt;-<span class="st"> </span><span class="kw"><a href="reference/parse_smiles.html">parse_smiles</a></span>(<span class="st">"CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)[O-])C penicillin"</span>)</span>
<span id="cb2-10"><a href="#cb2-10"></a>cav  &lt;-<span class="st"> </span><span class="kw"><a href="reference/parse_smiles.html">parse_smiles</a></span>(<span class="st">"CN1C=NC2=C1C(=O)N(C(=O)N2C)C"</span>)</span>
<span id="cb2-11"><a href="#cb2-11"></a></span>
<span id="cb2-12"><a href="#cb2-12"></a><span class="co"># define the regions to highlight</span></span>
<span id="cb2-13"><a href="#cb2-13"></a><span class="co"># either all atoms/bonds</span></span>
<span id="cb2-14"><a href="#cb2-14"></a><span class="co"># or a SMARTS-defined subregion</span></span>
<span id="cb2-15"><a href="#cb2-15"></a>atms &lt;-<span class="st"> </span>pen<span class="op">$</span><span class="kw">atoms</span>()</span>
<span id="cb2-16"><a href="#cb2-16"></a>bnds &lt;-<span class="st"> </span>pen<span class="op">$</span><span class="kw">bonds</span>()</span>
<span id="cb2-17"><a href="#cb2-17"></a>lactam &lt;-<span class="st"> </span><span class="kw"><a href="reference/match_smarts.html">match_smarts</a></span>(<span class="st">"C1(=O)NCC1"</span>, pen)</span>
<span id="cb2-18"><a href="#cb2-18"></a></span>
<span id="cb2-19"><a href="#cb2-19"></a><span class="co"># use piping to change the behavior as desired</span></span>
<span id="cb2-20"><a href="#cb2-20"></a><span class="kw"><a href="reference/depiction.html">depiction</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb2-21"><a href="#cb2-21"></a><span class="st">  </span><span class="kw"><a href="reference/highlight_atoms.html">highlight_atoms</a></span>(atms, color<span class="op">$</span>LIGHT_GRAY) <span class="op">%&gt;%</span></span>
<span id="cb2-22"><a href="#cb2-22"></a><span class="st">  </span><span class="kw"><a href="reference/highlight_atoms.html">highlight_atoms</a></span>(bnds, color<span class="op">$</span>LIGHT_GRAY) <span class="op">%&gt;%</span></span>
<span id="cb2-23"><a href="#cb2-23"></a><span class="st">  </span><span class="kw"><a href="reference/highlight_atoms.html">highlight_atoms</a></span>(lactam, color<span class="op">$</span>RED) <span class="op">%&gt;%</span></span>
<span id="cb2-24"><a href="#cb2-24"></a><span class="st">  </span><span class="kw"><a href="reference/set_size.html">set_size</a></span>(<span class="dv">400</span>, <span class="dv">400</span>) <span class="op">%&gt;%</span></span>
<span id="cb2-25"><a href="#cb2-25"></a><span class="st">  </span><span class="kw"><a href="reference/set_zoom.html">set_zoom</a></span>(<span class="dv">3</span>) <span class="op">%&gt;%</span></span>
<span id="cb2-26"><a href="#cb2-26"></a><span class="st">  </span><span class="kw"><a href="reference/outerglow.html">outerglow</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb2-27"><a href="#cb2-27"></a><span class="st">  </span><span class="kw"><a href="reference/add_title.html">add_title</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb2-28"><a href="#cb2-28"></a><span class="st">  </span><span class="kw"><a href="reference/depict.html">depict</a></span>(pen) <span class="op">%&gt;%</span></span>
<span id="cb2-29"><a href="#cb2-29"></a><span class="st">  </span><span class="kw"><a href="reference/get_image.html">get_image</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb2-30"><a href="#cb2-30"></a><span class="st">  </span>grid<span class="op">::</span><span class="kw"><a href="https://rdrr.io/r/grid/grid.raster.html">grid.raster</a></span>()</span></code></pre></div>
<p><img src="man/figures/penicillin_highlight.png"></p>
</div>
<div id="a-larger-example" class="section level2">
<h2 class="hasAnchor">
<a href="#a-larger-example" class="anchor"></a>A Larger Example</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a>insulinmol &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span>(<span class="st">"molfiles/ChEBI_5931.mol"</span>, <span class="dt">package=</span><span class="st">"depict"</span>)</span>
<span id="cb3-2"><a href="#cb3-2"></a>insulin    &lt;-<span class="st"> </span><span class="kw"><a href="reference/read_mol.html">read_mol</a></span>(insulinmol)</span>
<span id="cb3-3"><a href="#cb3-3"></a></span>
<span id="cb3-4"><a href="#cb3-4"></a>cysteine &lt;-<span class="st"> </span><span class="kw"><a href="reference/match_smarts.html">match_smarts</a></span>(<span class="st">"C(=O)C(CS)N"</span>, insulin)</span>
<span id="cb3-5"><a href="#cb3-5"></a>xlinks   &lt;-<span class="st"> </span><span class="kw"><a href="reference/match_smarts.html">match_smarts</a></span>(<span class="st">"SS"</span>, insulin)</span>
<span id="cb3-6"><a href="#cb3-6"></a></span>
<span id="cb3-7"><a href="#cb3-7"></a>dp &lt;-<span class="st"> </span><span class="kw"><a href="reference/depiction.html">depiction</a></span>()<span class="op">%&gt;%</span><span class="st"> </span></span>
<span id="cb3-8"><a href="#cb3-8"></a><span class="st">  </span><span class="kw"><a href="reference/set_size.html">set_size</a></span>(<span class="dv">700</span>, <span class="dv">400</span>) <span class="op">%&gt;%</span></span>
<span id="cb3-9"><a href="#cb3-9"></a><span class="st">  </span><span class="kw"><a href="reference/set_zoom.html">set_zoom</a></span>(<span class="dv">10</span>) <span class="op">%&gt;%</span></span>
<span id="cb3-10"><a href="#cb3-10"></a><span class="st">  </span><span class="kw"><a href="reference/outerglow.html">outerglow</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb3-11"><a href="#cb3-11"></a><span class="st">  </span><span class="kw"><a href="reference/highlight_atoms.html">highlight_atoms</a></span>(cysteine, color<span class="op">$</span>YELLOW) <span class="op">%&gt;%</span></span>
<span id="cb3-12"><a href="#cb3-12"></a><span class="st">  </span><span class="kw"><a href="reference/highlight_atoms.html">highlight_atoms</a></span>(xlinks, color<span class="op">$</span>YELLOW) <span class="op">%&gt;%</span></span>
<span id="cb3-13"><a href="#cb3-13"></a><span class="st">  </span><span class="kw"><a href="reference/depict.html">depict</a></span>(insulin) <span class="op">%&gt;%</span></span>
<span id="cb3-14"><a href="#cb3-14"></a><span class="st">  </span><span class="kw"><a href="reference/get_image.html">get_image</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb3-15"><a href="#cb3-15"></a><span class="st">  </span>grid<span class="op">::</span><span class="kw"><a href="https://rdrr.io/r/grid/grid.raster.html">grid.raster</a></span>()</span></code></pre></div>
<p><img src="man/figures/insulin.png"></p>
</div>
<div id="coding-notes" class="section level2">
<h2 class="hasAnchor">
<a href="#coding-notes" class="anchor"></a>Coding notes</h2>
<p>A few notes about setup:</p>
<ol>
<li>Java can be touch on OSX in particular. When in doubt try <code>sudo R CMD javareconf</code> and reinstall rJava from source.</li>
<li>Currently I am using the <code><a href="https://rdrr.io/r/base/Extract.html">$</a></code> operator in just about all of my functions. This makes it about a billion times easier and more succinct to code at the price of performance. If performance becomes an issue we can use low-level calls. If its important to you I’m happy to accept pull requests.</li>
<li>The API is still in flux. I am currently happy with the design but there are a few areas where I’d like to kick the tires a bit more - especially in regards to selection.</li>
<li>java.awt.colors are a bit tough to warp since there are many arities and classes accepted.. I think I will provide a number of colors.</li>
<li>SMARTS selectors. common smarts selections for AminoAcids, Nucleic Acids, Sugars may be worth including as well.</li>
<li>
</ol>
</div>
</div>


  </div>

</div>



      <footer>
      <div class="copyright">
  <p>Developed by Zachary Charlop-Powers.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p>
</div>

      </footer>
   </div>

  


  </body>
</html>