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

GHA: Automated live (rendered) versions of the notebooks #821

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions RNA-seq/02-gastric_cancer_tximeta.nb.html
Original file line number Diff line number Diff line change
Expand Up @@ -3264,8 +3264,8 @@ <h2>Summarize to gene</h2>
<pre class="r"><code># Summarize to the gene level
gene_summarized &lt;- summarizeToGene(txi_data)</code></pre>
<!-- rnb-source-end -->
<!-- rnb-message-begin eyJkYXRhIjoibG9hZGluZyBleGlzdGluZyBFbnNEYiBjcmVhdGVkOiAyMDI0LTA4LTA4IDE2OjEwOjI3XG4ifQ== -->
<pre><code>loading existing EnsDb created: 2024-08-08 16:10:27</code></pre>
<!-- rnb-message-begin eyJkYXRhIjoibG9hZGluZyBleGlzdGluZyBFbnNEYiBjcmVhdGVkOiAyMDI0LTEyLTA0IDIwOjM1OjI1XG4ifQ== -->
<pre><code>loading existing EnsDb created: 2024-12-04 20:35:25</code></pre>
<!-- rnb-message-end -->
<!-- rnb-message-begin eyJkYXRhIjoib2J0YWluaW5nIHRyYW5zY3JpcHQtdG8tZ2VuZSBtYXBwaW5nIGZyb20gZGF0YWJhc2VcbiJ9 -->
<pre><code>obtaining transcript-to-gene mapping from database</code></pre>
Expand Down
6 changes: 3 additions & 3 deletions scRNA-seq-advanced/01-read_filter_normalize_scRNA-live.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ Finally, we will set up the our output directory, creating it if it does not yet
normalized_dir <- file.path(data_dir, "normalized")

# create the directory if it does not exist
if (!dir.exists(normalized_dir)) {
dir.create(normalized_dir, recursive = TRUE)
}
fs::dir_create(normalized_dir)

# output RDS file for normalized data
output_sce_file <- file.path(normalized_dir,
Expand All @@ -113,6 +111,8 @@ Some of these functions for other common data formats are discussed in [Chapter
```{r read SCE, live=TRUE}
# read SCE from matrix directory

# ensure barcodes are set as column names in the SCE object

Comment on lines +114 to +115
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jashapiro would you prefer this comment not be there (and I move it to the end of the line so it goes away) for when you teach this? I'm going to fix those spots I introduced in the integration notebook; let me know if you want me to fix this one too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, probably better to have it at the end of the line

```

Let's look at the contents of the object after reading it in:
Expand Down
172 changes: 94 additions & 78 deletions scRNA-seq-advanced/01-read_filter_normalize_scRNA.nb.html

Large diffs are not rendered by default.

46 changes: 26 additions & 20 deletions scRNA-seq-advanced/02-dataset_integration-live.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ To see how this looks, let's look at the UMAP when calculated from individual sa
```{r plot individual UMAPs, live = TRUE}
# Plot UMAP calculated from individual samples with separate scaling

# Use a CVD-friendly color scheme and specify legend name

# Modify the legend key so its points are larger and easier to see

```


Expand Down Expand Up @@ -525,13 +529,12 @@ Now, let's see how this new `merged_UMAP` looks compared to the `UMAP` calculate
# UMAPs scaled together when calculated from the merged SCE
scater::plotReducedDim(merged_sce,
dimred = "merged_UMAP",
colour_by = "sample",
color_by = "sample",
# Some styling to help us see the points:
point_size = 0.5,
point_alpha = 0.2) +
# Modify the legend key so its points are larger and easier to see
guides(colour = guide_legend(override.aes = list(size = 3, alpha = 1))) +
# Add a plot title
scale_color_brewer(palette = "Dark2", name = "sample") +
guides(color = guide_legend(override.aes = list(size = 3, alpha = 1))) +
ggtitle("UMAP calculated on merged_sce")
```

Expand Down Expand Up @@ -596,13 +599,12 @@ scater::plotReducedDim(merged_sce,
# plot the fastMNN coordinates
dimred = "fastmnn_UMAP",
# color by sample
colour_by = "sample",
color_by = "sample",
# Some styling to help us see the points:
point_size = 0.5,
point_alpha = 0.2) +
# Modify legend so they key is larger and easier to see
guides(colour = guide_legend(override.aes = list(size = 3, alpha = 1))) +
# add plot title
scale_color_brewer(palette = "Dark2", name = "sample") +
guides(color = guide_legend(override.aes = list(size = 3, alpha = 1))) +
ggtitle("UMAP after integration with fastMNN")
```

Expand Down Expand Up @@ -642,10 +644,12 @@ Let's re-plot this UMAP to highlight cell types:
scater::plotReducedDim(merged_sce,
dimred = "fastmnn_UMAP",
# color by broad celltypes
colour_by = "celltype_broad",
color_by = "celltype_broad",
point_size = 0.5,
point_alpha = 0.2) +
guides(colour = guide_legend(override.aes = list(size = 3, alpha = 1))) +
# include argument to specify color of NA values
scale_color_brewer(palette = "Dark2", name = "Broad celltype", na.value = "grey80") +
guides(color = guide_legend(override.aes = list(size = 3, alpha = 1))) +
ggtitle("UMAP after integration with fastMNN")
```

Expand All @@ -658,12 +662,13 @@ One way we can see all the points a bit better is to facet the plot by sample, u
```{r plot fastmnn umap celltypes faceted}
scater::plotReducedDim(merged_sce,
dimred = "fastmnn_UMAP",
colour_by = "celltype_broad",
color_by = "celltype_broad",
point_size = 0.5,
point_alpha = 0.2,
# Allow for faceting by a variable using `other_fields`:
other_fields = "sample") +
guides(colour = guide_legend(override.aes = list(size = 3, alpha = 1))) +
scale_color_brewer(palette = "Dark2", name = "Broad celltype", na.value = "grey80") +
guides(color = guide_legend(override.aes = list(size = 3, alpha = 1))) +
ggtitle("UMAP after integration with fastMNN") +
# Facet by sample
facet_wrap(vars(sample)) +
Expand Down Expand Up @@ -743,11 +748,12 @@ Let's see how the `harmony` UMAP, colored by sample, looks compared to the `fast
```{r plot harmony umap batches}
scater::plotReducedDim(merged_sce,
dimred = "harmony_UMAP",
colour_by = "sample",
color_by = "sample",
point_size = 0.5,
point_alpha = 0.2) +
ggtitle("UMAP after integration with harmony") +
guides(colour = guide_legend(override.aes = list(size = 3, alpha = 1)))
scale_color_brewer(palette = "Dark2", name = "sample") +
guides(color = guide_legend(override.aes = list(size = 3, alpha = 1))) +
ggtitle("UMAP after integration with harmony")
```

How do you think this `harmony` UMAP compares to that from `fastMNN` integration?
Expand All @@ -757,19 +763,19 @@ Let's see how this UMAP looks colored by cell type, and faceted for visibility:
```{r plot harmony umap celltypes}
scater::plotReducedDim(merged_sce,
dimred = "harmony_UMAP",
colour_by = "celltype_broad",
color_by = "celltype_broad",
point_size = 0.5,
point_alpha = 0.2,
# Specify variable for faceting
other_fields = "sample") +
scale_color_brewer(palette = "Dark2", name = "Broad celltype", na.value = "grey80") +
guides(color = guide_legend(override.aes = list(size = 3))) +
ggtitle("UMAP after integration with harmony") +
guides(colour = guide_legend(override.aes = list(size = 3))) +
facet_wrap(vars(sample))
```

With the faceted view, we can now see that the small amounts of `Tumor_Myocyte` from other samples are "pulled" towards those cells in `SCPCL000481`.

What other patterns do you see that are similar or different from the `fastMNN` UMAP?
What do you now notice in this faceted view that wasn't clear previously?
Are there other patterns you see that are similar or different from the `fastMNN` UMAP?
How do you think `fastMNN` vs. `harmony` performed in integrating these samples?

### Export
Expand Down
155 changes: 93 additions & 62 deletions scRNA-seq-advanced/02-dataset_integration.nb.html

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions scRNA-seq-advanced/03-differential_expression-live.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ sample_metadata_file <- file.path(data_dir,

# directory to store output
deseq_dir <- file.path("analysis", "rms", "deseq")
if(!dir.exists(deseq_dir)){
dir.create(deseq_dir, recursive = TRUE)
}
fs::dir_create(deseq_dir)

# results file to output from DE analysis
deseq_output_file <- file.path(deseq_dir,
Expand Down Expand Up @@ -223,7 +221,7 @@ The samples which could be further classified have a mix of `Tumor_Mesoderm`, `T
scater::plotReducedDim(integrated_sce,
dimred = "fastmnn_UMAP",
# color each point by cell type
colour_by = "celltype_broad",
color_by = "celltype_broad",
point_size= 0.5,
point_alpha = 0.4)
```
Expand Down Expand Up @@ -267,6 +265,7 @@ ggplot(tumor_cells_df, aes(x = sample, fill = celltype_broad)) +
y = "Proportion of cells",
fill = "Cell type"
) +
scale_fill_brewer(palette = "Dark2") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5))+
# facet by diagnosis group
Expand Down Expand Up @@ -694,7 +693,7 @@ scater::plotExpression(tumor_sce,
# a vector of genes to plot
features = genes_to_plot,
x = "diagnosis_group",
colour_by = "diagnosis_group",
color_by = "diagnosis_group",
other_fields = "celltype_broad",
point_size = 0.1) +
# each celltype is its own column
Expand All @@ -703,7 +702,7 @@ scater::plotExpression(tumor_sce,
rows = vars(Feature)) +
# change the font size of the facet labels
theme(strip.text = element_text(size = 7)) +
guides(colour = guide_legend(
guides(color = guide_legend(
title = "Subtype", # update the legend title
# change the size of the legend colors
override.aes = list(size = 3, alpha = 1))
Expand Down
Loading
Loading