Skip to content

Commit 9b1a264

Browse files
committed
deploy: d1a0cd8
1 parent 2342085 commit 9b1a264

File tree

8 files changed

+303
-284
lines changed

8 files changed

+303
-284
lines changed

Lesson_1_Basics/Lesson_1_Student_Version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ <h4 class="anchored" data-anchor-id="introduction-to-jupyter-notebooks-and-googl
318318
<p>“The Jupyter Notebook is an incredibly powerful tool for interactively developing and presenting data science projects. A notebook integrates code and its output into a single document that combines visualizations, narrative text, mathematical equations, and other rich media. The intuitive workflow promotes iterative and rapid development, making notebooks an increasingly popular choice at the heart of contemporary data science, analysis, and increasingly science at large.” - <a href="https://www.dataquest.io/blog/jupyter-notebook-tutorial/">dataquest</a></p>
319319
<p>All of our lessons will be presented in Jupyter notebooks due to their interactive nature (.ipynb file extension). They consist of two main attributes, a <code>kernel</code> and <code>cells</code>. * A <code>kernel</code> interprets and executes the code. Here we are using the kernel for python; however, you can specify a kernel for another language like R. * A <code>cell</code> is a container for either text or code to be executed.</p>
320320
<p>To run the python code in a cell, you just hit shift + enter. Try it with the code below.</p>
321-
<div id="cell-8" class="cell" data-quarto="{&quot;engine&quot;:&quot;pyodide&quot;,&quot;autorun&quot;:false,&quot;echo&quot;:true}">
321+
<div id="cell-8" class="cell" data-quarto="{&quot;autorun&quot;:false,&quot;echo&quot;:true,&quot;engine&quot;:&quot;pyodide&quot;}">
322322
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="st">'hello world'</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
323323
</div>
324324
</section>

Lesson_6_NumPy/Lesson_6_NumPy_Student_Version.html

Lines changed: 160 additions & 156 deletions
Large diffs are not rendered by default.

Lesson_8a_Scikit_Learn/scikit_learn_student.html

Lines changed: 92 additions & 82 deletions
Large diffs are not rendered by default.

Lesson_8c_scanpy/Lesson_8c_scanpy.html

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,16 +1180,20 @@ <h2 class="anchored" data-anchor-id="scanpy---explore-and-filter-data">scanpy -
11801180
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a>adata <span class="op">=</span> adata[:, adata.var.highly_variable]</span>
11811181
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true" tabindex="-1"></a>sc.pp.regress_out(adata, [<span class="st">'total_counts'</span>, <span class="st">'pct_counts_mt'</span>])</span>
11821182
<span id="cb15-17"><a href="#cb15-17" aria-hidden="true" tabindex="-1"></a>sc.pp.scale(adata, max_value<span class="op">=</span><span class="dv">10</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1183+
<div class="cell-output cell-output-stderr">
1184+
<pre><code>/usr/local/lib/python3.10/dist-packages/scanpy/preprocessing/_normalization.py:170: UserWarning: Received a view of an AnnData. Making a copy.
1185+
view_to_actual(adata)</code></pre>
1186+
</div>
11831187
</div>
11841188
</section>
11851189
<section id="scanpy---pca-and-umap-clustering" class="level2">
11861190
<h2 class="anchored" data-anchor-id="scanpy---pca-and-umap-clustering">scanpy - PCA and UMAP clustering</h2>
11871191
<p>PCA stands for principal component analysis. principal components (PCs) are axes capturing variation in your data. They are often used to reduce the dimensionality of your dataset and can be used in machine learning/regression models. See <a href="https://towardsdatascience.com/a-step-by-step-introduction-to-pca-c0d78e26a0dd">A Step-By-Step Introduction to PCA</a> for a more detailed overview. Let’s calculate the PCs and visualize the first two PCs highlighting CST3 expression.</p>
11881192
<div id="cell-23" class="cell" data-outputid="90762dcd-620a-4f28-8397-ee7a1eaa7795">
1189-
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co"># look at pcs to see how many pcs to use in neighborhood graph construction</span></span>
1190-
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a>sc.tl.pca(adata, svd_solver<span class="op">=</span><span class="st">'arpack'</span>)</span>
1191-
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="co"># pl ie plot just the first two principal components</span></span>
1192-
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a>sc.pl.pca(adata, color<span class="op">=</span><span class="st">'CST3'</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1193+
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="co"># look at pcs to see how many pcs to use in neighborhood graph construction</span></span>
1194+
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>sc.tl.pca(adata, svd_solver<span class="op">=</span><span class="st">'arpack'</span>)</span>
1195+
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a><span class="co"># pl ie plot just the first two principal components</span></span>
1196+
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a>sc.pl.pca(adata, color<span class="op">=</span><span class="st">'CST3'</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
11931197
<div class="cell-output cell-output-display">
11941198
<div>
11951199
<figure class="figure">
@@ -1201,8 +1205,8 @@ <h2 class="anchored" data-anchor-id="scanpy---pca-and-umap-clustering">scanpy -
12011205
<p>In the figure above, each dot is a cell plotted against the first two PCs. The color of the dot is correlated with CST3 expression. It looks like there are three or four different clusters just based on these PCs and CST3 expression level.</p>
12021206
<p>Now, let’s create an elbow plot which will plot variance captured vs each PC. This gives us an idea of which PCs to use in clustering (those that capture the most variance).</p>
12031207
<div id="cell-25" class="cell" data-outputid="46daf2c5-e969-45b6-bbc8-20d7e540fae0">
1204-
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="co"># note that this is a logarithmic scale of variance ratio</span></span>
1205-
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>sc.pl.pca_variance_ratio(adata, log<span class="op">=</span><span class="va">True</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1208+
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="co"># note that this is a logarithmic scale of variance ratio</span></span>
1209+
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>sc.pl.pca_variance_ratio(adata, log<span class="op">=</span><span class="va">True</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
12061210
<div class="cell-output cell-output-display">
12071211
<div>
12081212
<figure class="figure">
@@ -1225,19 +1229,19 @@ <h2 class="anchored" data-anchor-id="scanpy---pca-and-umap-clustering">scanpy -
12251229
<li><a href="https://joss.theoj.org/papers/10.21105/joss.00861">McInnes et al.&nbsp;(2018)</a></li>
12261230
</ul>
12271231
<div id="cell-27" class="cell" data-outputid="498efcf0-08a6-4a94-c0df-0d69f6ab7ea3">
1228-
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="co"># calculate neighborhood graph pp = preprocessing using the first 40 PCs</span></span>
1229-
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>sc.pp.neighbors(adata, n_neighbors<span class="op">=</span><span class="dv">10</span>, n_pcs<span class="op">=</span><span class="dv">40</span>)</span>
1230-
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a></span>
1231-
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a><span class="co"># initial clustering...this part isn't in the official demo but I think they forgot this part</span></span>
1232-
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a>sc.tl.leiden(adata)</span>
1233-
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a><span class="co"># remedy disconnected clusters...</span></span>
1234-
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a>sc.tl.paga(adata) <span class="co"># maps "coarse-grained connectivity structures of complex manifolds", tl = toolkit, paga = partition-based graph abstraction</span></span>
1235-
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a>sc.pl.paga(adata, plot<span class="op">=</span><span class="va">False</span>) <span class="co"># compute the course grained layout, pl = plot</span></span>
1236-
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a>sc.tl.umap(adata, init_pos<span class="op">=</span><span class="st">'paga'</span>) <span class="co"># embed in umap</span></span>
1237-
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a></span>
1238-
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a><span class="co"># embedding of neighborhood graph using UMAP</span></span>
1239-
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a>sc.tl.umap(adata)</span>
1240-
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a>sc.pl.umap(adata, color<span class="op">=</span>[<span class="st">'CST3'</span>, <span class="st">'NKG7'</span>, <span class="st">'PPBP'</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1232+
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="co"># calculate neighborhood graph pp = preprocessing using the first 40 PCs</span></span>
1233+
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>sc.pp.neighbors(adata, n_neighbors<span class="op">=</span><span class="dv">10</span>, n_pcs<span class="op">=</span><span class="dv">40</span>)</span>
1234+
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a></span>
1235+
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="co"># initial clustering...this part isn't in the official demo but I think they forgot this part</span></span>
1236+
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a>sc.tl.leiden(adata)</span>
1237+
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a><span class="co"># remedy disconnected clusters...</span></span>
1238+
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a>sc.tl.paga(adata) <span class="co"># maps "coarse-grained connectivity structures of complex manifolds", tl = toolkit, paga = partition-based graph abstraction</span></span>
1239+
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a>sc.pl.paga(adata, plot<span class="op">=</span><span class="va">False</span>) <span class="co"># compute the course grained layout, pl = plot</span></span>
1240+
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a>sc.tl.umap(adata, init_pos<span class="op">=</span><span class="st">'paga'</span>) <span class="co"># embed in umap</span></span>
1241+
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a></span>
1242+
<span id="cb19-11"><a href="#cb19-11" aria-hidden="true" tabindex="-1"></a><span class="co"># embedding of neighborhood graph using UMAP</span></span>
1243+
<span id="cb19-12"><a href="#cb19-12" aria-hidden="true" tabindex="-1"></a>sc.tl.umap(adata)</span>
1244+
<span id="cb19-13"><a href="#cb19-13" aria-hidden="true" tabindex="-1"></a>sc.pl.umap(adata, color<span class="op">=</span>[<span class="st">'CST3'</span>, <span class="st">'NKG7'</span>, <span class="st">'PPBP'</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
12411245
<div class="cell-output cell-output-display">
12421246
<div>
12431247
<figure class="figure">
@@ -1253,12 +1257,16 @@ <h2 class="anchored" data-anchor-id="scanpy---pca-and-umap-clustering">scanpy -
12531257
<li><a href="https://www.nature.com/articles/s41598-019-41695-z">Traag et al.&nbsp;(2018)</a></li>
12541258
</ul>
12551259
<div id="cell-29" class="cell" data-outputid="d1f5df8d-ea1c-4e60-a22f-0718fdfe3b36">
1256-
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a>sc.tl.leiden(adata)</span>
1257-
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>sc.pl.umap(adata, color<span class="op">=</span>[<span class="st">'leiden'</span>, <span class="st">'CST3'</span>, <span class="st">'NKG7'</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1260+
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>sc.tl.leiden(adata)</span>
1261+
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>sc.pl.umap(adata, color<span class="op">=</span>[<span class="st">'leiden'</span>, <span class="st">'CST3'</span>, <span class="st">'NKG7'</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1262+
<div class="cell-output cell-output-stderr">
1263+
<pre><code>/usr/local/lib/python3.10/dist-packages/scanpy/plotting/_tools/scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
1264+
cax = scatter(</code></pre>
1265+
</div>
12581266
<div class="cell-output cell-output-display">
12591267
<div>
12601268
<figure class="figure">
1261-
<p><img src="Lesson_8c_scanpy_files/figure-html/cell-15-output-1.png" class="img-fluid figure-img"></p>
1269+
<p><img src="Lesson_8c_scanpy_files/figure-html/cell-15-output-2.png" class="img-fluid figure-img"></p>
12621270
</figure>
12631271
</div>
12641272
</div>
@@ -1269,12 +1277,12 @@ <h2 class="anchored" data-anchor-id="in-class-exercises">In-class exercises</h2>
12691277
<p>In-class exercise 1: From the <a href="#anndata">AnnData</a> section…instead of creating a <code>csr_matrix</code> can we create a pandas dataframe instead to look at the data more easily?</p>
12701278
<p>Answer:</p>
12711279
<div id="cell-31" class="cell">
1272-
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>pd.DataFrame(np.random.poisson(<span class="dv">1</span>, size<span class="op">=</span>(<span class="dv">100</span>, <span class="dv">2000</span>)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1280+
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>pd.DataFrame(np.random.poisson(<span class="dv">1</span>, size<span class="op">=</span>(<span class="dv">100</span>, <span class="dv">2000</span>)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
12731281
</div>
12741282
<p>In-class exercise 2: Find the UMAP mappings for cell 5 in the <code>adata</code> object.</p>
12751283
<p>Answer:</p>
12761284
<div id="cell-33" class="cell">
1277-
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>adata.obsm[<span class="st">"X_umap"</span>][<span class="dv">4</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1285+
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>adata.obsm[<span class="st">"X_umap"</span>][<span class="dv">4</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
12781286
</div>
12791287

12801288

Lesson_8c_scanpy/Lesson_8c_scanpy_files/figure-html/cell-15-output-1.png renamed to Lesson_8c_scanpy/Lesson_8c_scanpy_files/figure-html/cell-15-output-2.png

File renamed without changes.

index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,8 @@ <h2 class="anchored" data-anchor-id="lessons">Lessons</h2>
347347
<section id="try-an-interactive-pyodide-cell" class="level2">
348348
<h2 class="anchored" data-anchor-id="try-an-interactive-pyodide-cell">Try an interactive Pyodide cell</h2>
349349
<p>Below is a small Python snippet running <strong>in your browser</strong> via Pyodide. Click <strong>Run Code</strong> to execute it:</p>
350-
<div id="688bb064" class="cell" data-autorun="false" data-engine="pyodide" data-execution_count="1">
350+
<div id="b478b132" class="cell" data-engine="pyodide" data-autorun="false">
351351
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="bu">sum</span>([<span class="dv">10</span>, <span class="dv">20</span>, <span class="dv">30</span>, <span class="dv">40</span>, <span class="dv">50</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
352-
<div class="cell-output cell-output-display" data-execution_count="1">
353-
<pre><code>150</code></pre>
354-
</div>
355352
</div>
356353

357354

0 commit comments

Comments
 (0)