Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorials infrastructure: switch to text-based notebook workflow #59

Closed
wants to merge 38 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7ee54d5
Adding jupytext options to Makefile
Jun 23, 2021
0803983
Migrating from the "old" format: toc is not a mapping
Jun 23, 2021
55ff765
Moving builds to their folder
Jun 23, 2021
f3bf746
Building site instead of book
Jun 23, 2021
de2d146
Adding Makefile on website
Jun 23, 2021
e345a61
Removing website Makefile refs
Jun 23, 2021
1d4e64c
Adding website/conf.py
Jun 23, 2021
37c53d5
Starting index.md
Jun 23, 2021
3086296
Adding Indices and tables to index.md
Jun 23, 2021
0c22b39
Ignoring website local builds
Jun 23, 2021
568fe59
An example — testing jupytext conversion
Jun 23, 2021
2437a6a
Adding example to toctree on index.md
Jun 23, 2021
831741f
Creating a link from website/images to ../images
Jun 23, 2021
e818bc4
Testing toc structure
Jun 23, 2021
747d842
Organizing folders
Jun 23, 2021
f217e16
Changing intro.md
Jun 24, 2021
9244886
Testing python instead of ipython3 on {code-cell}s
Sep 13, 2021
872d226
jb-article -> jb-book
Sep 14, 2021
9803c81
Adding more converted notebooks
Sep 14, 2021
7af90a1
Changing - to _ on adv3 filename
Sep 15, 2021
fa7fed3
Adding some of the newly converted notebooks to the toc
Sep 15, 2021
71f8a0b
Fix tabs in Makefile
stefanv Dec 2, 2021
ae4c3fe
Require book directory for building html
stefanv Dec 2, 2021
caea7c1
Fix incorrect build path
stefanv Dec 2, 2021
f18a5cd
website -> site
Dec 2, 2021
78a689b
website -> site
Dec 2, 2021
83728db
website -> site
Dec 2, 2021
d4325e7
Refactor the build system
stefanv Dec 3, 2021
9edcefd
Fix skdemo
stefanv Dec 3, 2021
ef683cc
Fix up color_and_exposure module
stefanv Dec 3, 2021
f95be21
Fix image links
stefanv Dec 3, 2021
28d0e4c
Fix notebooks; fix skdemo; fix notebook build path
stefanv Dec 3, 2021
4103ab0
Require imagecodecs for reading tiffs
stefanv Dec 3, 2021
db180a5
Fix filters imports
stefanv Dec 3, 2021
64cea04
threshold_adaptive is not threshold_local
stefanv Dec 3, 2021
bfcc8c5
Final fixes to adv0_chromosomes
stefanv Dec 3, 2021
ad248c4
Fix adv1_lesion_quantification
stefanv Dec 3, 2021
6edeb56
Fix adv2_microarray
stefanv Dec 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix adv2_microarray
stefanv committed Dec 10, 2021
commit 6edeb5648c5a12b8c8cc097fddb31533a5b9f129
56 changes: 24 additions & 32 deletions modules/adv2_microarray.md
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.10.3
jupytext_version: 1.11.2
kernelspec:
display_name: Python 3
language: python
name: python3
---

```{code-cell} python
```{code-cell} ipython3
from __future__ import division, print_function
%matplotlib inline
```
@@ -46,17 +46,15 @@ More example data:

- [MicroArray Genome Imaging & Clustering Tool](http://www.bio.davidson.edu/projects/MAGIC/MAGIC.html) by Laurie Heyer & team, Davidson College



```{code-cell} python
```{code-cell} ipython3
import matplotlib.pyplot as plt

import numpy as np

from skimage import io, img_as_float
```

```{code-cell} python
```{code-cell} ipython3
microarray = io.imread('../images/microarray.jpg')

# Scale between zero and one
@@ -66,7 +64,7 @@ plt.figure(figsize=(10, 5))
plt.imshow(microarray[:500, :1000], cmap='gray', interpolation='nearest');
```

```{code-cell} python
```{code-cell} ipython3
from skimage import color
f, (ax0, ax1) = plt.subplots(1, 2, figsize=(15, 10))

@@ -84,14 +82,14 @@ ax1.imshow(red_rgb, interpolation='nearest')
plt.suptitle('\n\nPseudocolor plots of red and green channels', fontsize=16);
```

```{code-cell} python
from skimage import filter as filters
```{code-cell} ipython3
from skimage import filters

mask = (green > 0.1)
plt.imshow(mask[:1000, :1000], cmap='gray');
```

```{code-cell} python
```{code-cell} ipython3
z = red.copy()
z /= green
z[~mask] = 0
@@ -103,26 +101,26 @@ plt.imshow(z[:500, :500], cmap=plt.cm.gray, vmin=0, vmax=2);

### Locating the grid

```{code-cell} python
```{code-cell} ipython3
both = (green + red)

plt.imshow(both, cmap='gray');
```

```{code-cell} python
```{code-cell} ipython3
from skimage import feature

sum_down_columns = both.sum(axis=0)
sum_across_rows = both.sum(axis=1)

dips_columns = feature.peak_local_max(sum_down_columns.max() - sum_down_columns)
dips_columns = dips_columns.ravel()
dips_columns = feature.peak_local_max(sum_down_columns.max() - sum_down_columns, min_distance=5)
dips_columns = np.sort(dips_columns.ravel())

M = len(dips_columns)
column_distance = np.mean(np.diff(dips_columns))

dips_rows = feature.peak_local_max(sum_across_rows.max() - sum_across_rows)
dips_rows = dips_rows.ravel()
dips_rows = feature.peak_local_max(sum_across_rows.max() - sum_across_rows, min_distance=5)
dips_rows = np.sort(dips_rows.ravel())

N = len(dips_rows)
row_distance = np.mean(np.diff(dips_rows))
@@ -143,7 +141,7 @@ ax1.set_xlim(0, 200)
ax0.set_title('Row gaps');
```

```{code-cell} python
```{code-cell} ipython3
P, Q = 500, 500

plt.figure(figsize=(15, 10))
@@ -158,17 +156,18 @@ for j in dips_columns[dips_columns < Q]:
plt.axis('image');
```

```{code-cell} python
```{code-cell} ipython3
out = np.zeros(microarray.shape[:2])
M, N = len(dips_rows), len(dips_columns)

for i in range(M - 1):
for j in range(N - 1):
row0, row1 = dips_rows[i], dips_rows[i + 1]
col0, col1 = dips_columns[j], dips_columns[j + 1]

r = microarray[row0:row1, col0:col1, 0]
g = microarray[row0:row1, col0:col1, 1]

ratio = r / g
mask = ~np.isinf(ratio)

@@ -179,7 +178,7 @@ for i in range(M - 1):
out[row0:row1, col0:col1] = mean_ratio
```

```{code-cell} python
```{code-cell} ipython3
f, (ax0, ax1) = plt.subplots(1, 2, figsize=(15, 10))

ax0.imshow(microarray)
@@ -191,21 +190,14 @@ ax1.grid(color='magenta', linewidth=1)

### Transform the intensity to spot outliers

```{code-cell} python
```{code-cell} ipython3
from skimage import exposure

f, (ax0, ax1) = plt.subplots(1, 2, figsize=(15, 10))

ax0.imshow(microarray)
ax0.grid(color='magenta', linewidth=1)

ax1.imshow(np.log(0.5 + out), cmap='gray', interpolation='nearest', vmin=0, vmax=3);
ax1.imshow(exposure.adjust_log(out, gain=0.4), cmap='gray', interpolation='nearest', vmin=0, vmax=3);
ax1.grid(color='magenta', linewidth=1)
```

---

<div style="height: 400px;"></div>

```{code-cell} python
%reload_ext load_style
%load_style ../themes/tutorial.css
```