Skip to content

Commit

Permalink
re-work pairs a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebaron committed Jun 23, 2022
1 parent cf86e0d commit 8d3321e
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 55 deletions.
25 changes: 13 additions & 12 deletions docs/eta.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ <h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#setup" id="toc-setup" class="nav-link active" data-scroll-target="#setup"> <span class="header-section-number">8.1</span> Setup</a></li>
<li><a href="#data-used-on-this-page" id="toc-data-used-on-this-page" class="nav-link" data-scroll-target="#data-used-on-this-page"> <span class="header-section-number">8.2</span> Data used on this page</a></li>
<li><a href="#eta-versus-continuous-eta_cont" id="toc-eta-versus-continuous-eta_cont" class="nav-link" data-scroll-target="#eta-versus-continuous-eta_cont"> <span class="header-section-number">8.3</span> ETA versus continuous <code>[eta_cont]</code></a></li>
<li><a href="#eta-by-categorical-eta_cat" id="toc-eta-by-categorical-eta_cat" class="nav-link" data-scroll-target="#eta-by-categorical-eta_cat"> <span class="header-section-number">8.4</span> ETA by categorical <code>[eta_cat]</code></a></li>
<li><a href="#eta-histograms-eta_hist" id="toc-eta-histograms-eta_hist" class="nav-link" data-scroll-target="#eta-histograms-eta_hist"> <span class="header-section-number">8.5</span> ETA histograms <code>[eta_hist]</code></a></li>
<li><a href="#eta-pairs-eta_pairs" id="toc-eta-pairs-eta_pairs" class="nav-link" data-scroll-target="#eta-pairs-eta_pairs"> <span class="header-section-number">8.6</span> ETA pairs <code>[eta_pairs]</code></a></li>
<li><a href="#versus-continuous-eta_cont" id="toc-versus-continuous-eta_cont" class="nav-link" data-scroll-target="#versus-continuous-eta_cont"> <span class="header-section-number">8.3</span> Versus continuous <code>[eta_cont]</code></a></li>
<li><a href="#by-categorical-eta_cat" id="toc-by-categorical-eta_cat" class="nav-link" data-scroll-target="#by-categorical-eta_cat"> <span class="header-section-number">8.4</span> By categorical <code>[eta_cat]</code></a></li>
<li><a href="#histograms-eta_hist" id="toc-histograms-eta_hist" class="nav-link" data-scroll-target="#histograms-eta_hist"> <span class="header-section-number">8.5</span> Histograms <code>[eta_hist]</code></a></li>
<li><a href="#pairs-eta_pairs" id="toc-pairs-eta_pairs" class="nav-link" data-scroll-target="#pairs-eta_pairs"> <span class="header-section-number">8.6</span> Pairs <code>[eta_pairs]</code></a></li>
</ul>
<div class="toc-actions"><div><i class="bi bi-github"></i></div><div class="action-links"><p><a href="https://github.com/metrumresearchgroup/pmp-book/blob/main/book/eta.qmd" class="toc-action">View source</a></p><p><a href="https://github.com/metrumresearchgroup/pmp-book/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
</div>
Expand Down Expand Up @@ -367,8 +367,8 @@ <h2 data-number="8.2" class="anchored" data-anchor-id="data-used-on-this-page"><
</div>
</div>
</section>
<section id="eta-versus-continuous-eta_cont" class="level2" data-number="8.3">
<h2 data-number="8.3" class="anchored" data-anchor-id="eta-versus-continuous-eta_cont"><span class="header-section-number">8.3</span> ETA versus continuous <code>[eta_cont]</code></h2>
<section id="versus-continuous-eta_cont" class="level2" data-number="8.3">
<h2 data-number="8.3" class="anchored" data-anchor-id="versus-continuous-eta_cont"><span class="header-section-number">8.3</span> Versus continuous <code>[eta_cont]</code></h2>
<p>Grouped by eta</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">eta_cont</span>(id, <span class="at">x =</span> covs, <span class="at">y =</span> etas[<span class="dv">2</span>]) <span class="sc">%&gt;%</span> </span>
Expand Down Expand Up @@ -396,8 +396,8 @@ <h2 data-number="8.3" class="anchored" data-anchor-id="eta-versus-continuous-eta
</div>
</div>
</section>
<section id="eta-by-categorical-eta_cat" class="level2" data-number="8.4">
<h2 data-number="8.4" class="anchored" data-anchor-id="eta-by-categorical-eta_cat"><span class="header-section-number">8.4</span> ETA by categorical <code>[eta_cat]</code></h2>
<section id="by-categorical-eta_cat" class="level2" data-number="8.4">
<h2 data-number="8.4" class="anchored" data-anchor-id="by-categorical-eta_cat"><span class="header-section-number">8.4</span> By categorical <code>[eta_cat]</code></h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">eta_cat</span>(id, <span class="at">x =</span> <span class="st">"STUDYc//Study type"</span>, <span class="at">y =</span> etas) <span class="sc">%&gt;%</span> </span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">pm_grid</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
Expand All @@ -411,8 +411,8 @@ <h2 data-number="8.4" class="anchored" data-anchor-id="eta-by-categorical-eta_ca
</div>
</div>
</section>
<section id="eta-histograms-eta_hist" class="level2" data-number="8.5">
<h2 data-number="8.5" class="anchored" data-anchor-id="eta-histograms-eta_hist"><span class="header-section-number">8.5</span> ETA histograms <code>[eta_hist]</code></h2>
<section id="histograms-eta_hist" class="level2" data-number="8.5">
<h2 data-number="8.5" class="anchored" data-anchor-id="histograms-eta_hist"><span class="header-section-number">8.5</span> Histograms <code>[eta_hist]</code></h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">eta_hist</span>(id, etas, <span class="at">bins =</span> <span class="dv">10</span>) <span class="sc">%&gt;%</span> </span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">pm_grid</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
Expand All @@ -426,8 +426,9 @@ <h2 data-number="8.5" class="anchored" data-anchor-id="eta-histograms-eta_hist">
</div>
</div>
</section>
<section id="eta-pairs-eta_pairs" class="level2" data-number="8.6">
<h2 data-number="8.6" class="anchored" data-anchor-id="eta-pairs-eta_pairs"><span class="header-section-number">8.6</span> ETA pairs <code>[eta_pairs]</code></h2>
<section id="pairs-eta_pairs" class="level2" data-number="8.6">
<h2 data-number="8.6" class="anchored" data-anchor-id="pairs-eta_pairs"><span class="header-section-number">8.6</span> Pairs <code>[eta_pairs]</code></h2>
<p>See also <a href="pairs.html">Chapter&nbsp;<span>10</span></a> on making pairs plots.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">eta_pairs</span>(id, etas) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ <h1 class="title d-none d-lg-block">The pmplots Gallery</h1>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">Jun 16, 2022</p>
<p class="date">Jun 23, 2022</p>
</div>
</div>

Expand Down
32 changes: 21 additions & 11 deletions docs/pairs.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ <h1 class="quarto-secondary-nav-title"><span class="chapter-number">10</span>&nb
<header id="title-block-header" class="quarto-title-block default page-columns page-full">
<div class="quarto-title-banner page-columns page-full">
<div class="quarto-title column-body">
<h1 class="title d-none d-lg-block"><span class="chapter-number">10</span>&nbsp; <span class="chapter-title">Pairs plots</span></h1>
<h1 class="title"><span id="sec-pairs" class="quarto-section-identifier d-none d-lg-block"><span class="chapter-number">10</span>&nbsp; <span class="chapter-title">Pairs plots</span></span></h1>
</div>
</div>

Expand Down Expand Up @@ -294,7 +294,8 @@ <h2 id="toc-title">Table of contents</h2>

<ul>
<li><a href="#general-pairs-plot" id="toc-general-pairs-plot" class="nav-link active" data-scroll-target="#general-pairs-plot"> <span class="header-section-number">10.1</span> General pairs plot</a></li>
<li><a href="#customized-lower-triangle" id="toc-customized-lower-triangle" class="nav-link" data-scroll-target="#customized-lower-triangle"> <span class="header-section-number">10.2</span> Customized lower triangle</a></li>
<li><a href="#eta-pairs-plots" id="toc-eta-pairs-plots" class="nav-link" data-scroll-target="#eta-pairs-plots"> <span class="header-section-number">10.2</span> ETA pairs plots</a></li>
<li><a href="#customized-lower-triangle" id="toc-customized-lower-triangle" class="nav-link" data-scroll-target="#customized-lower-triangle"> <span class="header-section-number">10.3</span> Customized lower triangle</a></li>
</ul>
<div class="toc-actions"><div><i class="bi bi-github"></i></div><div class="action-links"><p><a href="https://github.com/metrumresearchgroup/pmp-book/blob/main/book/pairs.qmd" class="toc-action">View source</a></p><p><a href="https://github.com/metrumresearchgroup/pmp-book/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
</div>
Expand All @@ -306,22 +307,29 @@ <h2 id="toc-title">Table of contents</h2>

<section id="general-pairs-plot" class="level2" data-number="10.1">
<h2 data-number="10.1" class="anchored" data-anchor-id="general-pairs-plot"><span class="header-section-number">10.1</span> General pairs plot</h2>
<p>This is a simple wrapper around <code>GGally::ggpairs</code> with some customizations that have been developed internally at Metrum over the years.</p>
<p>This is a simple wrapper around <code>GGally::ggpairs</code> with some customizations that have been developed internally at MetrumRG over the years.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>cols <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">"WT//Weight"</span>, <span class="st">"ALB//Albumin"</span>, <span class="st">"SCR//Serum creat"</span>)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pairs_plot</span>(id, cols)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<div id="fig-pairs" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="pairs_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="576"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption"></figcaption><p></p>
<figure class="figure">
<img src="pairs_files/figure-html/fig-pairs-1.png" class="img-fluid figure-img" width="480">
</figure>
<p></p><figcaption aria-hidden="true" class="figure-caption">Figure 10.1: General pairs plot.</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>One customization we’ve added is the annotation on the upper triangle, which is the <code>complete.obs</code> correlation between <code>x</code> and <code>y</code> along with the number of observations.</p>
</section>
<section id="eta-pairs-plots" class="level2" data-number="10.2">
<h2 data-number="10.2" class="anchored" data-anchor-id="eta-pairs-plots"><span class="header-section-number">10.2</span> ETA pairs plots</h2>
<p>There is also a function called <code>eta_pairs()</code> that is identical to the <code>pairs_plot()</code> function. This might be helpful to remember the function name but there is no difference in functionality between <code>eta_pairs()</code> and <code>pairs_plot()</code>.</p>
</section>
<section id="customized-lower-triangle" class="level2" data-number="10.2">
<h2 data-number="10.2" class="anchored" data-anchor-id="customized-lower-triangle"><span class="header-section-number">10.2</span> Customized lower triangle</h2>
<section id="customized-lower-triangle" class="level2" data-number="10.3">
<h2 data-number="10.3" class="anchored" data-anchor-id="customized-lower-triangle"><span class="header-section-number">10.3</span> Customized lower triangle</h2>
<p>Pass a function that customizes the scatter plots on the lower triangle. This function should accept a gg object and add a geom to it</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>my_lower <span class="ot">&lt;-</span> <span class="cf">function</span>(p) {</span>
Expand All @@ -332,10 +340,12 @@ <h2 data-number="10.2" class="anchored" data-anchor-id="customized-lower-triangl
<div class="cell">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pairs_plot</span>(id, <span class="fu">c</span>(<span class="st">"WT"</span>, <span class="st">"ALB"</span>), <span class="at">lower_plot =</span> my_lower)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<div id="fig-pairs-custom-lower" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="pairs_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid figure-img" width="576"></p>
<p></p><figcaption aria-hidden="true" class="figure-caption"></figcaption><p></p>
<figure class="figure">
<img src="pairs_files/figure-html/fig-pairs-custom-lower-1.png" class="img-fluid figure-img" width="480">
</figure>
<p></p><figcaption aria-hidden="true" class="figure-caption">Figure 10.2: Pairs plot with customized lower triangle.</figcaption><p></p>
</figure>
</div>
</div>
Expand Down
Binary file added docs/pairs_files/figure-html/fig-pairs-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 26 additions & 19 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,32 +175,32 @@
"text": "8.2 Data used on this page\nWe are exclusively using a data set that is one row per individual\n\n\n\n\n\n\nPreview the data used on this page\n\n\n\n\n\n\nhead(as.data.frame(id), n=3)\n\n C NUM ID SUBJ TIME SEQ CMT EVID AMT DV AGE WT CRCL ALB BMI AAG\n1 NA 1 1 1 0 0 1 1 5 0 28.03 55.16 114.45 4.40 21.67 106.36\n2 NA 17 2 2 0 0 1 1 5 0 34.67 51.74 100.54 3.88 23.85 61.79\n3 NA 33 3 3 0 0 1 1 5 0 26.24 54.84 99.05 3.84 19.43 50.10\n SCR AST ALT HT CP TAFD TAD LDOS MDV BLQ PHASE STUDY RF 102 IPRED\n1 1.14 11.88 12.66 159.55 0 0 0 5 1 0 1 1 norm 1 0\n2 0.98 15.09 27.44 147.27 0 0 0 5 1 0 1 1 norm 1 0\n3 1.05 35.85 31.26 168.02 0 0 0 5 1 0 1 1 norm 1 0\n CWRESI NPDE PRED RES WRES CL V2 KA ETA1 ETA2 ETA3\n1 0 0 0 0 0 2.5927 40.287 1.4520 -0.075300 -0.184030 -0.095308\n2 0 0 0 0 0 1.9339 32.925 1.6044 0.024467 -0.321810 -0.340470\n3 0 0 0 0 0 3.2407 50.967 1.4195 -0.097942 0.056922 0.132150\n DOSE STUDYc CPc\n1 5 SAD normal\n2 5 SAD normal\n3 5 SAD normal"
},
{
"objectID": "eta.html#eta-versus-continuous-eta_cont",
"href": "eta.html#eta-versus-continuous-eta_cont",
"objectID": "eta.html#versus-continuous-eta_cont",
"href": "eta.html#versus-continuous-eta_cont",
"title": "8  ETA plots",
"section": "8.3 ETA versus continuous [eta_cont]",
"text": "8.3 ETA versus continuous [eta_cont]\nGrouped by eta\n\neta_cont(id, x = covs, y = etas[2]) %>% \n pm_grid()\n\n\n\n\n\n\n\n\n\nGrouped by covariate\n\neta_cont(id, x = covs[1], y = etas) %>% \n pm_grid(ncol = 2)"
"section": "8.3 Versus continuous [eta_cont]",
"text": "8.3 Versus continuous [eta_cont]\nGrouped by eta\n\neta_cont(id, x = covs, y = etas[2]) %>% \n pm_grid()\n\n\n\n\n\n\n\n\n\nGrouped by covariate\n\neta_cont(id, x = covs[1], y = etas) %>% \n pm_grid(ncol = 2)"
},
{
"objectID": "eta.html#eta-by-categorical-eta_cat",
"href": "eta.html#eta-by-categorical-eta_cat",
"objectID": "eta.html#by-categorical-eta_cat",
"href": "eta.html#by-categorical-eta_cat",
"title": "8  ETA plots",
"section": "8.4 ETA by categorical [eta_cat]",
"text": "8.4 ETA by categorical [eta_cat]\n\neta_cat(id, x = \"STUDYc//Study type\", y = etas) %>% \n pm_grid()"
"section": "8.4 By categorical [eta_cat]",
"text": "8.4 By categorical [eta_cat]\n\neta_cat(id, x = \"STUDYc//Study type\", y = etas) %>% \n pm_grid()"
},
{
"objectID": "eta.html#eta-histograms-eta_hist",
"href": "eta.html#eta-histograms-eta_hist",
"objectID": "eta.html#histograms-eta_hist",
"href": "eta.html#histograms-eta_hist",
"title": "8  ETA plots",
"section": "8.5 ETA histograms [eta_hist]",
"text": "8.5 ETA histograms [eta_hist]\n\neta_hist(id, etas, bins = 10) %>% \n pm_grid()"
"section": "8.5 Histograms [eta_hist]",
"text": "8.5 Histograms [eta_hist]\n\neta_hist(id, etas, bins = 10) %>% \n pm_grid()"
},
{
"objectID": "eta.html#eta-pairs-eta_pairs",
"href": "eta.html#eta-pairs-eta_pairs",
"objectID": "eta.html#pairs-eta_pairs",
"href": "eta.html#pairs-eta_pairs",
"title": "8  ETA plots",
"section": "8.6 ETA pairs [eta_pairs]",
"text": "8.6 ETA pairs [eta_pairs]\n\neta_pairs(id, etas)"
"section": "8.6 Pairs [eta_pairs]",
"text": "8.6 Pairs [eta_pairs]\nSee also Chapter 10 on making pairs plots.\n\neta_pairs(id, etas)"
},
{
"objectID": "wrap.html",
Expand Down Expand Up @@ -263,14 +263,21 @@
"href": "pairs.html",
"title": "10  Pairs plots",
"section": "",
"text": "This is a simple wrapper around GGally::ggpairs with some customizations that have been developed internally at Metrum over the years.\n\ncols <- c(\"WT//Weight\", \"ALB//Albumin\", \"SCR//Serum creat\")\npairs_plot(id, cols)"
"text": "This is a simple wrapper around GGally::ggpairs with some customizations that have been developed internally at MetrumRG over the years.\n\ncols <- c(\"WT//Weight\", \"ALB//Albumin\", \"SCR//Serum creat\")\npairs_plot(id, cols)\n\n\n\n\n\n\nFigure 10.1: General pairs plot.\n\n\n\n\nOne customization we’ve added is the annotation on the upper triangle, which is the complete.obs correlation between x and y along with the number of observations."
},
{
"objectID": "pairs.html#eta-pairs-plots",
"href": "pairs.html#eta-pairs-plots",
"title": "10  Pairs plots",
"section": "10.2 ETA pairs plots",
"text": "10.2 ETA pairs plots\nThere is also a function called eta_pairs() that is identical to the pairs_plot() function. This might be helpful to remember the function name but there is no difference in functionality between eta_pairs() and pairs_plot()."
},
{
"objectID": "pairs.html#customized-lower-triangle",
"href": "pairs.html#customized-lower-triangle",
"title": "10  Pairs plots",
"section": "10.2 Customized lower triangle",
"text": "10.2 Customized lower triangle\nPass a function that customizes the scatter plots on the lower triangle. This function should accept a gg object and add a geom to it\n\nmy_lower <- function(p) {\n p + geom_point(aes(color = STUDYc)) + \n geom_smooth(se = FALSE, color = \"black\")\n}\n\n\npairs_plot(id, c(\"WT\", \"ALB\"), lower_plot = my_lower)"
"section": "10.3 Customized lower triangle",
"text": "10.3 Customized lower triangle\nPass a function that customizes the scatter plots on the lower triangle. This function should accept a gg object and add a geom to it\n\nmy_lower <- function(p) {\n p + geom_point(aes(color = STUDYc)) + \n geom_smooth(se = FALSE, color = \"black\")\n}\n\n\npairs_plot(id, c(\"WT\", \"ALB\"), lower_plot = my_lower)\n\n\n\n\n\n\nFigure 10.2: Pairs plot with customized lower triangle."
},
{
"objectID": "vectorized.html",
Expand Down
Loading

0 comments on commit 8d3321e

Please sign in to comment.