improve polls and update for Nov 2024

This commit is contained in:
Natalie Elphick 2024-11-08 15:30:41 -08:00
parent f6305c4141
commit 73777222a9
5 changed files with 171 additions and 187 deletions

View file

@ -2572,7 +2572,7 @@ class CountdownTimer {
<h1 class="title">Introduction to R Data Analysis</h1> <h1 class="title">Introduction to R Data Analysis</h1>
<h1 class="subtitle">Part 1</h1> <h1 class="subtitle">Part 1</h1>
<h2 class="author">Natalie Elphick</h2> <h2 class="author">Natalie Elphick</h2>
<h3 class="date">August 26th, 2024</h3> <h3 class="date">November 11th, 2024</h3>
</section> </section>
<section id="section" class="slide level2"> <section id="section" class="slide level2">
@ -2585,8 +2585,6 @@ class CountdownTimer {
<h2>Introductions</h2> <h2>Introductions</h2>
<p><strong>Natalie Elphick</strong><br /> <p><strong>Natalie Elphick</strong><br />
Bioinformatician I</p> Bioinformatician I</p>
<p><strong>Min-Gyoung Shin</strong><br />
Bioinformatician III</p>
</section> </section>
<section id="poll-1" class="slide level2"> <section id="poll-1" class="slide level2">
<h2>Poll 1</h2> <h2>Poll 1</h2>
@ -2858,7 +2856,6 @@ one style of names</li>
<li>Logical <li>Logical
<ul> <ul>
<li>Boolean (TRUE, FALSE)</li> <li>Boolean (TRUE, FALSE)</li>
<li>NA (missing data)</li>
</ul></li> </ul></li>
<li>Character <li>Character
<ul> <ul>
@ -2867,15 +2864,24 @@ one style of names</li>
</ul></li> </ul></li>
</ul> </ul>
</section> </section>
<section id="missing-values" class="slide level2">
<h2>Missing Values</h2>
<ul>
<li>R has a special data type - NA which represents missing data</li>
<li>NAs can take the place of any type but by default are logical</li>
</ul>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="cn">NA</span> <span class="sc">+</span> <span class="dv">1</span></span></code></pre></div>
<pre><code>[1] NA</code></pre>
</section>
<section id="poll-3" class="slide level2"> <section id="poll-3" class="slide level2">
<h2>Poll 3</h2> <h2>Poll 3</h2>
<p><strong>Which of these is not the correct data type for the <p><strong>Which of these is not the correct data type for the
value?</strong></p> value?</strong></p>
<ol type="1"> <ol type="1">
<li>1.5 - Numeric</li> <li>1.5 - Numeric</li>
<li>“1” - Character</li> <li>A” - Character</li>
<li>NA - Logical</li> <li>1L - Integer</li>
<li>1 - Integer</li> <li>TRUE - Boolean</li>
</ol> </ol>
</section> </section>
<section id="data-structures" class="slide level2"> <section id="data-structures" class="slide level2">
@ -2915,7 +2921,7 @@ types/structures</strong> (ex. nested lists)</li>
<section id="min-break" class="title-slide slide level1"> <section id="min-break" class="title-slide slide level1">
<h1>10 min break</h1> <h1>10 min break</h1>
<center> <center>
<div class="countdown" id="timer_1497287f" data-update-every="1" tabindex="0" style="right:0;bottom:0;margin:5%;padding:50px;font-size:5em;position: relative; width: min-content;"> <div class="countdown" id="timer_1fd2ccf2" data-update-every="1" tabindex="0" style="right:0;bottom:0;margin:5%;padding:50px;font-size:5em;position: relative; width: min-content;">
<div class="countdown-controls"><button class="countdown-bump-down"></button><button class="countdown-bump-up">+</button></div> <div class="countdown-controls"><button class="countdown-bump-down"></button><button class="countdown-bump-up">+</button></div>
<code class="countdown-time"><span class="countdown-digits minutes">10</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code> <code class="countdown-time"><span class="countdown-digits minutes">10</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div> </div>
@ -2934,44 +2940,44 @@ types/structures</strong> (ex. nested lists)</li>
mean( ), median( ), mode( ) )</li> mean( ), median( ), mode( ) )</li>
<li>Relational comparison operators to compare values</li> <li>Relational comparison operators to compare values</li>
</ul> </ul>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>x <span class="sc">==</span> y <span class="co"># Equal to</span></span> <div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>x <span class="sc">==</span> y <span class="co"># Equal to</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>x <span class="sc">!=</span> y <span class="co"># Not equal to</span></span> <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>x <span class="sc">!=</span> y <span class="co"># Not equal to</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&lt;</span> y <span class="co"># Less than</span></span> <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&lt;</span> y <span class="co"># Less than</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&gt;</span> y <span class="co"># Greater than</span></span> <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&gt;</span> y <span class="co"># Greater than</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&lt;=</span> y <span class="co"># Less than or equal to</span></span> <span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&lt;=</span> y <span class="co"># Less than or equal to</span></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&gt;=</span> y <span class="co"># Greater than or equal to</span></span> <span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&gt;=</span> y <span class="co"># Greater than or equal to</span></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a></span> <span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a>x <span class="sc">%in%</span> y <span class="co"># Is x in this vector y?</span></span></code></pre></div> <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a>x <span class="sc">%in%</span> y <span class="co"># Is x in this vector y?</span></span></code></pre></div>
</section>
<section id="poll-4" class="slide level2">
<h2>Poll 4</h2>
<p><strong>What is the output of the following code?</strong></p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="dv">4</span> <span class="sc">%in%</span> <span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>)</span></code></pre></div>
<ol type="1">
<li>TRUE</li>
<li>FALSE</li>
<li>NA</li>
</ol>
</section> </section>
<section id="logical-operators" class="slide level2"> <section id="logical-operators" class="slide level2">
<h2>Logical Operators</h2> <h2>Logical Operators</h2>
<ul> <ul>
<li>Logical operators can compare TRUE or FALSE values</li> <li>Logical operators can compare TRUE or FALSE values</li>
</ul> </ul>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>x <span class="ot">&lt;-</span> <span class="cn">TRUE</span></span> <div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>x <span class="ot">&lt;-</span> <span class="cn">TRUE</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>y <span class="ot">&lt;-</span> <span class="cn">FALSE</span></span> <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a>y <span class="ot">&lt;-</span> <span class="cn">FALSE</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a></span> <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="sc">!</span>x <span class="co"># Not x</span></span> <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="sc">!</span>x <span class="co"># Not x</span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>x <span class="sc">|</span> y <span class="co"># x or y</span></span> <span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a>x <span class="sc">|</span> y <span class="co"># x or y</span></span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&amp;</span> y <span class="co"># x and y</span></span></code></pre></div> <span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&amp;</span> y <span class="co"># x and y</span></span></code></pre></div>
</section>
<section id="poll-4" class="slide level2">
<h2>Poll 4</h2>
<p><strong>What is the output of the following code?</strong></p>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="dv">2</span> <span class="sc">+</span> <span class="dv">2</span> <span class="sc">==</span> <span class="dv">4</span> <span class="sc">&amp;</span> <span class="dv">8</span> <span class="sc">+</span> <span class="dv">10</span> <span class="sc">&lt;</span> <span class="dv">20</span></span></code></pre></div>
<ol type="1">
<li>TRUE</li>
<li>FALSE</li>
<li>NA</li>
</ol>
</section> </section>
<section id="poll-5" class="slide level2"> <section id="poll-5" class="slide level2">
<h2>Poll 5</h2> <h2>Poll 5</h2>
<p><strong>What is the output of the following code?</strong></p> <p><strong>What is the output of the following code?</strong></p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>x <span class="ot">&lt;-</span> <span class="cn">TRUE</span></span> <div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>x <span class="ot">&lt;-</span> <span class="cn">TRUE</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a>y <span class="ot">&lt;-</span> <span class="cn">FALSE</span></span> <span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>y <span class="ot">&lt;-</span> <span class="cn">FALSE</span></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a></span> <span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a>x <span class="sc">&amp;</span> <span class="sc">!</span>y</span></code></pre></div> <span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a>y <span class="sc">|</span> (y <span class="sc">|</span> x)</span></code></pre></div>
<ol type="1"> <ol type="1">
<li>TRUE</li> <li>TRUE</li>
<li>FALSE</li> <li>FALSE</li>
@ -2984,17 +2990,17 @@ mean( ), median( ), mode( ) )</li>
<li>Relational and logical operations allow for conditional execution of <li>Relational and logical operations allow for conditional execution of
code</li> code</li>
</ul> </ul>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>dog_breeds <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&quot;Labrador Retriever&quot;</span>, <span class="st">&quot;Akita&quot;</span>, <span class="st">&quot;Bulldog&quot;</span>)</span> <div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>dog_breeds <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&quot;Labrador Retriever&quot;</span>, <span class="st">&quot;Akita&quot;</span>, <span class="st">&quot;Bulldog&quot;</span>)</span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> (<span class="st">&quot;Akita&quot;</span> <span class="sc">%in%</span> dog_breeds) {</span> <span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> (<span class="st">&quot;Akita&quot;</span> <span class="sc">%in%</span> dog_breeds) {</span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(<span class="st">&quot;dog_breeds already contains Akita&quot;</span>)</span> <span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(<span class="st">&quot;dog_breeds already contains Akita&quot;</span>)</span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a>} <span class="cf">else</span> {</span> <span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a>} <span class="cf">else</span> {</span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a> dog_breeds <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&quot;Akita&quot;</span>, dog_breeds)</span> <span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a> dog_breeds <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">&quot;Akita&quot;</span>, dog_breeds)</span>
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div> <span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<pre><code>[1] &quot;dog_breeds already contains Akita&quot;</code></pre> <pre><code>[1] &quot;dog_breeds already contains Akita&quot;</code></pre>
</section></section> </section></section>
<section> <section>
@ -3019,39 +3025,39 @@ R</strong> functions</li>
<li>To define a function we use the function keyword, the output is <li>To define a function we use the function keyword, the output is
specified with the <strong>return</strong> function:</li> specified with the <strong>return</strong> function:</li>
</ul> </ul>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>add_dog <span class="ot">&lt;-</span> <span class="cf">function</span>(dog_to_add, input_vector) {</span> <div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>add_dog <span class="ot">&lt;-</span> <span class="cf">function</span>(dog_to_add, input_vector) {</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (dog_to_add <span class="sc">%in%</span> input_vector) {</span> <span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (dog_to_add <span class="sc">%in%</span> input_vector) {</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(<span class="st">&quot;Already contains this dog&quot;</span>)</span> <span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(<span class="st">&quot;Already contains this dog&quot;</span>)</span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span> {</span> <span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span> {</span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a> output <span class="ot">&lt;-</span> <span class="fu">c</span>(dog_to_add, input_vector)</span> <span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a> output <span class="ot">&lt;-</span> <span class="fu">c</span>(dog_to_add, input_vector)</span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(output)</span> <span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(output)</span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> </span> <span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a> }</span> <span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a> }</span>
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div> <span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
</section> </section>
<section id="example-1" class="slide level2"> <section id="example-1" class="slide level2">
<h2>Example</h2> <h2>Example</h2>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">add_dog</span>(<span class="at">dog_to_add =</span> <span class="st">&quot;Akita&quot;</span>,</span> <div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">add_dog</span>(<span class="at">dog_to_add =</span> <span class="st">&quot;Akita&quot;</span>,</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="at">input_vector =</span> dog_breeds)</span></code></pre></div>
<pre><code>[1] &quot;Already contains this dog&quot;</code></pre>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">add_dog</span>(<span class="at">dog_to_add =</span> <span class="st">&quot;German Shepard&quot;</span>,</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="at">input_vector =</span> dog_breeds)</span></code></pre></div> <span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="at">input_vector =</span> dog_breeds)</span></code></pre></div>
<pre><code>[1] &quot;Already contains this dog&quot;</code></pre>
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="fu">add_dog</span>(<span class="at">dog_to_add =</span> <span class="st">&quot;German Shepard&quot;</span>,</span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a> <span class="at">input_vector =</span> dog_breeds)</span></code></pre></div>
<pre><code>[1] &quot;German Shepard&quot; &quot;Labrador Retriever&quot; &quot;Akita&quot; <pre><code>[1] &quot;German Shepard&quot; &quot;Labrador Retriever&quot; &quot;Akita&quot;
[4] &quot;Bulldog&quot; </code></pre> [4] &quot;Bulldog&quot; </code></pre>
</section> </section>
<section id="poll-6" class="slide level2"> <section id="poll-6" class="slide level2">
<h2>Poll 6</h2> <h2>Poll 6</h2>
<p><strong>What does this function do?</strong></p> <p><strong>What does this function do?</strong></p>
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>mystery_function <span class="ot">&lt;-</span> <span class="cf">function</span>(x) {</span> <div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>mystery_function <span class="ot">&lt;-</span> <span class="cf">function</span>(x) {</span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (x <span class="sc">&gt;</span> <span class="dv">0</span>) {</span> <span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (x <span class="sc">&gt;</span> <span class="dv">0</span>) {</span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(x)</span> <span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(x)</span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span> {</span> <span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span> {</span>
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(<span class="sc">-</span>x)</span> <span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(<span class="sc">-</span>x)</span>
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a> }</span> <span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a> }</span>
<span id="cb23-7"><a href="#cb23-7" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div> <span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<ol type="1"> <ol type="1">
<li>Returns the absolute value of x</li> <li>Returns the absolute value of x</li>
<li>Returns x</li> <li>Returns x</li>
@ -3070,7 +3076,7 @@ specified with the <strong>return</strong> function:</li>
<li>Packages are collections of functions that are specialized to a <li>Packages are collections of functions that are specialized to a
specific task (plotting, data manipulation etc.)</li> specific task (plotting, data manipulation etc.)</li>
</ul> </ul>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2) <span class="co"># Makes all of the ggplot2 functions available</span></span></code></pre></div> <div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2) <span class="co"># Makes all of the ggplot2 functions available</span></span></code></pre></div>
<ul> <ul>
<li>The tidyverse is a collection of commonly used data analysis <li>The tidyverse is a collection of commonly used data analysis
packages packages
@ -3110,15 +3116,15 @@ can continue to improve these workshops</li>
</section> </section>
<section id="upcoming-workshops" class="slide level2"> <section id="upcoming-workshops" class="slide level2">
<h2>Upcoming Workshops</h2> <h2>Upcoming Workshops</h2>
<p><a href="https://gladstone.org/events/intermediate-rna-seq-analysis-using-r-5">Intermediate <p><a href="https://gladstone.org/events/introduction-scatac-seq-data-analysis">Introduction
RNA-Seq Analysis Using R</a><br /> to scATAC-seq Data Analysis</a><br />
September 10, 2024 9am-12pm PDT</p> November 14 - November 15, 2024 1:00-4:00pm PST</p>
<p><a href="https://gladstone.org/events/introduction-statistics-experimental-design-and-hypothesis-testing-1">Introduction <p><a href="https://gladstone.org/events/introduction-linear-mixed-effects-models-0">Introduction
to Statistics, Experimental Design, and Hypothesis Testing</a><br /> to Linear Mixed Effects Models</a><br />
September 10 - September 12, 2024 1-3pm PDT</p> November 18-November 19, 2024 1:00-3:00pm PST</p>
<p><a href="https://gladstone.org/events/single-cell-rna-seq-data-analysis-0">Single <p><a href="https://gladstone.org/events/scatac-seq-and-scrna-seq-data-integration">scATAC-seq
Cell RNA-Seq Data Analysis</a><br /> and scRNA-seq Data Integration</a><br />
September 16-September 17, 2024 9am-4pm PDT</p> November 22, 2024 1:00-4:00pm PST</p>
<ul> <ul>
<li>Check <a href="https://gladstone.org/events?series=data-science-training-program">this <li>Check <a href="https://gladstone.org/events?series=data-science-training-program">this
link</a> at for the full schedule</li> link</a> at for the full schedule</li>

View file

@ -2809,10 +2809,8 @@ border: 0;
<h1>Introductions</h1> <h1>Introductions</h1>
<p><strong>Natalie Elphick</strong><br /> <p><strong>Natalie Elphick</strong><br />
Bioinformatician I</p> Bioinformatician I</p>
<p><strong>Michela Traglia</strong><br /> <p><strong>Reuben Thomas</strong><br />
Senior Statistician</p> Associate Core Director</p>
<p><strong>Ayushi Agrawal</strong><br />
Bioinformatician III</p>
</section> </section>
<section id="schedule" class="title-slide slide level1"> <section id="schedule" class="title-slide slide level1">
@ -3048,7 +3046,7 @@ modified by adding layers</li>
<section id="min-break" class="title-slide slide level1"> <section id="min-break" class="title-slide slide level1">
<h1>10 min break</h1> <h1>10 min break</h1>
<center> <center>
<div class="countdown" id="timer_dfe5910e" data-update-every="1" tabindex="0" style="right:0;bottom:0;margin:5%;padding:50px;font-size:5em;position: relative; width: min-content;"> <div class="countdown" id="timer_786cfcf4" data-update-every="1" tabindex="0" style="right:0;bottom:0;margin:5%;padding:50px;font-size:5em;position: relative; width: min-content;">
<div class="countdown-controls"><button class="countdown-bump-down"></button><button class="countdown-bump-up">+</button></div> <div class="countdown-controls"><button class="countdown-bump-down"></button><button class="countdown-bump-up">+</button></div>
<code class="countdown-time"><span class="countdown-digits minutes">10</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code> <code class="countdown-time"><span class="countdown-digits minutes">10</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div> </div>
@ -4624,8 +4622,23 @@ reach out to the authors using their preferred method</li>
<h1>Additional Resources</h1> <h1>Additional Resources</h1>
</section> </section>
<section id="r" class="slide level2"> <section id="coding-templates" class="slide level2">
<h2>R</h2> <h2>Coding Templates</h2>
<p>Code templates can be used to avoid typing the same code over and
over again.</p>
<ul>
<li>These are templates that we are using to automate things like plot
appearance and documentation:
<ul>
<li><a href="https://www.dropbox.com/scl/fi/a9cnyqdajgabbfcxbmm6y/RMD_template.Rmd?rlkey=yntfpo6aptw9b4pgjyzpe5ubi&amp;dl=1">.Rmd
Template</a></li>
<li><a href="https://www.dropbox.com/scl/fi/cy43b8b1x3nzn17esnmmt/Rscript_template.R?rlkey=zn7b0g8nn0s9213blh70fjjsx&amp;dl=1">.R
Script Template</a></li>
</ul></li>
</ul>
</section>
<section id="r-resources" class="slide level2">
<h2>R Resources</h2>
<ul> <ul>
<li><a href="https://r4ds.hadley.nz/">R for Data Science</a></li> <li><a href="https://r4ds.hadley.nz/">R for Data Science</a></li>
<li><a href="https://statsandr.com/blog/top-10-errors-in-r/">Top 10 R <li><a href="https://statsandr.com/blog/top-10-errors-in-r/">Top 10 R
@ -4636,41 +4649,6 @@ Markdown: The Definitive Guide</a></li>
data analysis</a></li> data analysis</a></li>
<li><a href="https://adv-r.hadley.nz/">Advanced R</a></li> <li><a href="https://adv-r.hadley.nz/">Advanced R</a></li>
</ul> </ul>
</section>
<section id="statistics" class="slide level2">
<h2>Statistics</h2>
<ul>
<li><a href="https://bookdown.org/steve_midway/DAR">Data Analysis in
R</a> : This book has more statistics details than <em>R for Data
Science</em></li>
<li><a href="https://bookdown.org/steve_midway/DAR/glms-generalized-linear-models.html">Generalized
Linear Models</a><br />
</li>
<li><a href="https://bookdown.org/steve_midway/DAR/random-effects.html">Random
Effects</a></li>
</ul>
</section>
<section id="rna-seq-analysis" class="slide level2">
<h2>RNA-seq Analysis</h2>
<ul>
<li><a href="https://rnaseq.uoregon.edu/">RNA-seqlopedia</a> :
Everything you need to know about RNA-seq experiments</li>
<li><a href="https://luisvalesilva.com/datasimple/rna-seq_units.html">RNA-seq
Expression Units</a> : Blog post on understanding common units</li>
<li><a href="https://bioconductor.org/books/3.17/OSCA.intro/index.html">Introduction
to Single-Cell Analysis with Bioconductor</a> : Covers the basics of
scRNA-seq analysis in R</li>
</ul>
</section>
<section id="dimensional-reduction" class="slide level2">
<h2>Dimensional Reduction</h2>
<ul>
<li><a href="https://uw.pressbooks.pub/appliedmultivariatestatistics/chapter/pca/">Tutorial
on PCA</a> : PCA explained with R code examples</li>
<li><a href="https://pair-code.github.io/understanding-umap/">Understanding
UMAP</a> : Short explanation with great visualizations, mainly useful
for scRNA-seq analysis</li>
</ul>
</section></section> </section></section>
<section> <section>
<section id="end-of-part-2" class="title-slide slide level1"> <section id="end-of-part-2" class="title-slide slide level1">
@ -4686,15 +4664,15 @@ can continue to improve these workshops</li>
</section> </section>
<section id="upcoming-workshops" class="slide level2"> <section id="upcoming-workshops" class="slide level2">
<h2>Upcoming Workshops</h2> <h2>Upcoming Workshops</h2>
<p><a href="https://gladstone.org/events/intermediate-rna-seq-analysis-using-r-5">Intermediate <p><a href="https://gladstone.org/events/introduction-scatac-seq-data-analysis">Introduction
RNA-Seq Analysis Using R</a><br /> to scATAC-seq Data Analysis</a><br />
September 10, 2024 9am-12pm PDT</p> November 14 - November 15, 2024 1:00-4:00pm PST</p>
<p><a href="https://gladstone.org/events/introduction-statistics-experimental-design-and-hypothesis-testing-1">Introduction <p><a href="https://gladstone.org/events/introduction-linear-mixed-effects-models-0">Introduction
to Statistics, Experimental Design, and Hypothesis Testing</a><br /> to Linear Mixed Effects Models</a><br />
September 10 - September 12, 2024 1-3pm PDT</p> November 18-November 19, 2024 1:00-3:00pm PST</p>
<p><a href="https://gladstone.org/events/single-cell-rna-seq-data-analysis-0">Single <p><a href="https://gladstone.org/events/scatac-seq-and-scrna-seq-data-integration">scATAC-seq
Cell RNA-Seq Data Analysis</a><br /> and scRNA-seq Data Integration</a><br />
September 16-September 17, 2024 9am-4pm PDT</p> November 22, 2024 1:00-4:00pm PST</p>
<ul> <ul>
<li>Check <a href="https://gladstone.org/events?series=data-science-training-program">this <li>Check <a href="https://gladstone.org/events?series=data-science-training-program">this
link</a> at for the full schedule</li> link</a> at for the full schedule</li>

View file

@ -2,7 +2,7 @@
title: "Introduction to R Data Analysis" title: "Introduction to R Data Analysis"
subtitle: "Part 1" subtitle: "Part 1"
author: "Natalie Elphick" author: "Natalie Elphick"
date: "August 26th, 2024" date: "November 11th, 2024"
knit: (function(input, ...) { knit: (function(input, ...) {
rmarkdown::render( rmarkdown::render(
input, input,
@ -29,8 +29,7 @@ knitr::opts_chunk$set(comment = "")
**Natalie Elphick** **Natalie Elphick**
Bioinformatician I Bioinformatician I
**Min-Gyoung Shin**
Bioinformatician III
## Poll 1 ## Poll 1
@ -246,19 +245,27 @@ DogBreeds <- c("Labrador Retriever", "Akita", "Bulldog")
- Decimal numbers - Decimal numbers
- Logical - Logical
- Boolean (TRUE, FALSE) - Boolean (TRUE, FALSE)
- NA (missing data)
- Character - Character
- Letters and strings of letters - Letters and strings of letters
- "A", "Labrador Retriever" - "A", "Labrador Retriever"
## Missing Values
- R has a special data type - NA which represents missing data
- NAs can take the place of any type but by default are logical
```{r}
NA + 1
```
## Poll 3 ## Poll 3
**Which of these is not the correct data type for the value?** **Which of these is not the correct data type for the value?**
1. 1.5 - Numeric 1. "1.5" - Numeric
2. "1" - Character 2. "A" - Character
3. NA - Logical 3. 1L - Integer
4. 1 - Integer 4. TRUE - Boolean
## Data Structures ## Data Structures
@ -320,17 +327,7 @@ x >= y # Greater than or equal to
x %in% y # Is x in this vector y? x %in% y # Is x in this vector y?
``` ```
## Poll 4
**What is the output of the following code?**
```{r, eval = FALSE}
4 %in% c(1, 2, 3, 4)
```
1. TRUE
2. FALSE
3. NA
## Logical Operators ## Logical Operators
@ -344,6 +341,18 @@ x | y # x or y
x & y # x and y x & y # x and y
``` ```
## Poll 4
**What is the output of the following code?**
```{r, eval = FALSE}
2 + 2 == 4 & 8 + 10 < 20
```
1. TRUE
2. FALSE
3. NA
## Poll 5 ## Poll 5
**What is the output of the following code?** **What is the output of the following code?**
@ -351,7 +360,7 @@ x & y # x and y
x <- TRUE x <- TRUE
y <- FALSE y <- FALSE
x & !y y | (y | x)
``` ```
1. TRUE 1. TRUE
@ -470,16 +479,17 @@ packages
## Upcoming Workshops ## Upcoming Workshops
[Intermediate RNA-Seq Analysis Using R](https://gladstone.org/events/intermediate-rna-seq-analysis-using-r-5) [Introduction to scATAC-seq Data Analysis](https://gladstone.org/events/introduction-scatac-seq-data-analysis)
September 10, 2024 9am-12pm PDT November 14 - November 15, 2024 1:00-4:00pm PST
[Introduction to Statistics, Experimental Design, and Hypothesis Testing](https://gladstone.org/events/introduction-statistics-experimental-design-and-hypothesis-testing-1) [Introduction to Linear Mixed Effects Models](https://gladstone.org/events/introduction-linear-mixed-effects-models-0)
September 10 - September 12, 2024 1-3pm PDT November 18-November 19, 2024 1:00-3:00pm PST
[Single Cell RNA-Seq Data Analysis](https://gladstone.org/events/single-cell-rna-seq-data-analysis-0) [scATAC-seq and scRNA-seq Data Integration](https://gladstone.org/events/scatac-seq-and-scrna-seq-data-integration)
September 16-September 17, 2024 9am-4pm PDT November 22, 2024 1:00-4:00pm PST
- Check [this link](https://gladstone.org/events?series=data-science-training-program) at for the full schedule - Check [this link](https://gladstone.org/events?series=data-science-training-program) at for the full schedule

View file

@ -31,11 +31,8 @@ knitr::opts_chunk$set(comment = "")
**Natalie Elphick** **Natalie Elphick**
Bioinformatician I Bioinformatician I
**Michela Traglia** **Reuben Thomas**
Senior Statistician Associate Core Director
**Ayushi Agrawal**
Bioinformatician III
# Schedule # Schedule
@ -281,30 +278,23 @@ For any bioinformatics specific questions feel free to reach out to the Gladston
# Additional Resources # Additional Resources
## Coding Templates
## R Code templates can be used to avoid typing the same code over and over again.
- These are templates that we are using to automate things like plot appearance and documentation:
- [.Rmd Template](https://www.dropbox.com/scl/fi/a9cnyqdajgabbfcxbmm6y/RMD_template.Rmd?rlkey=yntfpo6aptw9b4pgjyzpe5ubi&dl=1)
- [.R Script Template](https://www.dropbox.com/scl/fi/cy43b8b1x3nzn17esnmmt/Rscript_template.R?rlkey=zn7b0g8nn0s9213blh70fjjsx&dl=1)
## R Resources
- [R for Data Science](https://r4ds.hadley.nz/) - [R for Data Science](https://r4ds.hadley.nz/)
- [Top 10 R Errors and How to Fix them](https://statsandr.com/blog/top-10-errors-in-r/) - [Top 10 R Errors and How to Fix them](https://statsandr.com/blog/top-10-errors-in-r/)
- [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/how-to-read-this-book.html) - [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/how-to-read-this-book.html)
- [ggplot2: elegant graphics for data analysis](https://ggplot2-book.org/) - [ggplot2: elegant graphics for data analysis](https://ggplot2-book.org/)
- [Advanced R](https://adv-r.hadley.nz/) - [Advanced R](https://adv-r.hadley.nz/)
## Statistics
- [Data Analysis in R](https://bookdown.org/steve_midway/DAR) : This book has more statistics details than *R for Data Science*
- [Generalized Linear Models](https://bookdown.org/steve_midway/DAR/glms-generalized-linear-models.html)\
- [Random Effects](https://bookdown.org/steve_midway/DAR/random-effects.html)
## RNA-seq Analysis
- [RNA-seqlopedia](https://rnaseq.uoregon.edu/) : Everything you need to know about RNA-seq experiments
- [RNA-seq Expression Units](https://luisvalesilva.com/datasimple/rna-seq_units.html) : Blog post on understanding common units
- [Introduction to Single-Cell Analysis with Bioconductor](https://bioconductor.org/books/3.17/OSCA.intro/index.html) : Covers the basics of scRNA-seq analysis in R
## Dimensional Reduction
- [Tutorial on PCA](https://uw.pressbooks.pub/appliedmultivariatestatistics/chapter/pca/) : PCA explained with R code examples
- [Understanding UMAP](https://pair-code.github.io/understanding-umap/) : Short explanation with great visualizations, mainly useful for scRNA-seq analysis
@ -315,14 +305,14 @@ For any bioinformatics specific questions feel free to reach out to the Gladston
## Upcoming Workshops ## Upcoming Workshops
[Intermediate RNA-Seq Analysis Using R](https://gladstone.org/events/intermediate-rna-seq-analysis-using-r-5) [Introduction to scATAC-seq Data Analysis](https://gladstone.org/events/introduction-scatac-seq-data-analysis)
September 10, 2024 9am-12pm PDT November 14 - November 15, 2024 1:00-4:00pm PST
[Introduction to Statistics, Experimental Design, and Hypothesis Testing](https://gladstone.org/events/introduction-statistics-experimental-design-and-hypothesis-testing-1) [Introduction to Linear Mixed Effects Models](https://gladstone.org/events/introduction-linear-mixed-effects-models-0)
September 10 - September 12, 2024 1-3pm PDT November 18-November 19, 2024 1:00-3:00pm PST
[Single Cell RNA-Seq Data Analysis](https://gladstone.org/events/single-cell-rna-seq-data-analysis-0) [scATAC-seq and scRNA-seq Data Integration](https://gladstone.org/events/scatac-seq-and-scrna-seq-data-integration)
September 16-September 17, 2024 9am-4pm PDT November 22, 2024 1:00-4:00pm PST
- Check [this link](https://gladstone.org/events?series=data-science-training-program) at for the full schedule - Check [this link](https://gladstone.org/events?series=data-science-training-program) at for the full schedule

View file

@ -23,7 +23,7 @@ learnr::tutorial_options(exercise.timelimit = 10)
This guide will help you get set up for <ins>Intro to R Data Analysis</ins>. There are just a few steps to make sure you'll have the necessary software installed and ready to go on day 1. **Please ensure that you've completed each step by running the validation test prior to the start of the workshop**. This guide will help you get set up for <ins>Intro to R Data Analysis</ins>. There are just a few steps to make sure you'll have the necessary software installed and ready to go on day 1. **Please ensure that you've completed each step by running the validation test prior to the start of the workshop**.
This guide will walk you through how to install R, RStudio, and some additional tools that well be using in the course. By rough analogy to a car, R is like the cars engine and RStudio is like the dashboard. More precisely, R is a programming language and Rstudio is an integrated development environment (IDE), which is basically a nice software interface for interacting with R. For our purposes, you will only ever interact directly with RStudio, but it needs to have R installed to work (like a car needing its engine). This guide will help you set up R, RStudio, and a few extra tools we'll use in this course. You can think of R as the engine that powers everything, while RStudio is like the dashboard that makes it easy to control. R is a programming language, and RStudio is a tool that helps you work with it. Even though you'll mainly use RStudio, it needs R to be installed to work, just like a car needs an engine to run.
Please complete the following steps (must be done in this order). If you already have R and Rstudio installed you can skip ahead. Make sure you complete step 5 though! Please complete the following steps (must be done in this order). If you already have R and Rstudio installed you can skip ahead. Make sure you complete step 5 though!
@ -83,4 +83,4 @@ You should see a plot that looks like this appear:
</center> </center>
If you see an error that says “R version is too old” that means you need to update your R version. The update process is the same as the installation process. It will update your R installation. If you see an error that says “There is no package called ggplot2” that means you need to install the tidyverse package (see above). If you see an error that says “R version is too old” that means you need to update your R version. The update process is the same as the installation process. It will update your R installation. If you see an error that says “There is no package called ggplot2” that means you need to install the tidyverse package (see the *Install Required Packages* section).