Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit c247465

Browse files
committed
Edits after today's meeting
1 parent 669afa6 commit c247465

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This can be achieved with the integration of packages present in the R CRAN and
6060

6161
### Workshop Participation
6262

63-
The workshop format is a 2 hour session consisting of lecture, hands-on demos, exercises and Q&A.
63+
The workshop format is a 1.5 hour session consisting of lecture, hands-on demo, exercises and Q&A.
6464

6565

6666
### Workshop goals and objectives

vignettes/solutions.Rmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ seurat_obj |>
4545
count(gate) %>%
4646
summarise(proportion = n/sum(n))
4747
48-
4948
```
5049

5150
## Question 2
5251

53-
There is a cluster of cells characterised by a low RNA output (nCount_RNA). Use tidygate to asses the cell composition (curated_cell_type) of that cluster.
52+
There is a cluster of cells characterised by a low RNA output (nCount_RNA). Use tidygate to identify the cell composition (curated_cell_type) of that cluster.
5453

5554

5655
```{r, eval=FALSE}

vignettes/tidytranscriptomics_case_study.Rmd

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,22 @@ We can use `select` to choose columns, for example, to see the sample, cell, tot
110110
seurat_obj |> select(.cell, nCount_RNA, Phase)
111111
```
112112

113-
We can use `mutate` to create a column. For example, we could create a new `ident_l` column that contains a lower-case version of `ident`.
113+
We also see the UMAP columns as they are not part of the cell metadata, they are read-only.
114+
If we want to save the edited metadata, the Seurat object is modified accordingly.
115+
```{r}
116+
# Save edited metadata
117+
seurat_modified <- seurat_obj |> select(.cell, nCount_RNA, Phase)
118+
# View Seurat metadata
119+
seurat_modified[[]]
120+
```
121+
122+
We can use `mutate` to create a column. For example, we could create a new `Phase_l` column that contains a lower-case version of `Phase`.
114123

115124
```{r}
116125
seurat_obj |>
117126
mutate(Phase_l=tolower(Phase)) |>
118-
# select columns to view
127+
128+
# Select columns to view
119129
select(Phase, Phase_l)
120130
```
121131

@@ -137,7 +147,7 @@ seurat_obj <- seurat_obj |>
137147
seurat_obj |> select(sample)
138148
```
139149

140-
We could use tidyverse `unite` to combine columns, for example to create a new column for sample id combining the sample and BCB columns.
150+
We could use tidyverse `unite` to combine columns, for example to create a new column for sample id that combines the sample and patient identifier (BCB) columns.
141151

142152
```{r}
143153
seurat_obj <- seurat_obj |> unite("sample_id", sample, BCB, remove = FALSE)
@@ -287,6 +297,8 @@ seurat_obj |>
287297
288298
```
289299

300+
Here we draw one gate but multiple gates can be drawn.
301+
290302
After the selection we can reload from file the gate drawn for reproducibility.
291303

292304
```{r eval=FALSE}
@@ -357,18 +369,18 @@ seurat_obj |>
357369
scales::rescale(CD8A + CD8B, to=c(0,1))
358370
) |>
359371
360-
mutate( gate = tidygate::gate_int(UMAP_1, UMAP_2, gate_list = iscb2022tidytranscriptomics::gate_seurat_obj) ) |>
372+
mutate(gate = tidygate::gate_int(UMAP_1, UMAP_2, gate_list = iscb2022tidytranscriptomics::gate_seurat_obj) ) |>
361373
362374
filter(gate == 1) |>
363375
364376
# Reanalyse
365377
NormalizeData(assay="RNA") |>
366-
FindVariableFeatures( nfeatures = 100, assay="RNA") |>
378+
FindVariableFeatures(nfeatures = 100, assay="RNA") |>
367379
SplitObject(split.by = "file") |>
368380
RunFastMNN(assay="RNA") |>
369381
RunUMAP(reduction = "mnn", dims = 1:20) |>
370-
FindNeighbors( dims = 1:20, reduction = "mnn") |>
371-
FindClusters( resolution = 0.3)
382+
FindNeighbors(dims = 1:20, reduction = "mnn") |>
383+
FindClusters(resolution = 0.3)
372384
```
373385

374386
For comparison, we show the alternative using base R and Seurat
@@ -389,24 +401,25 @@ seurat_obj$signature_score = counts_positive - counts_negative
389401
390402
p = FeaturePlot(seurat_obj, features = "signature_score")
391403
392-
# This is not reproducible (on the contrary of tidygate)
404+
# This is not reproducible (in contrast to tidygate)
393405
seurat_obj$within_gate = colnames(seurat_obj) %in% CellSelector(plot = p)
394406
395407
seurat_obj |>
396408
subset(within_gate == TRUE) |>
397409
398410
# Reanalyse
399411
NormalizeData(assay="RNA") |>
400-
FindVariableFeatures( nfeatures = 100, assay="RNA") |>
412+
FindVariableFeatures(nfeatures = 100, assay="RNA") |>
401413
SplitObject(split.by = "file") |>
402414
RunFastMNN(assay="RNA") |>
403415
RunUMAP(reduction = "mnn", dims = 1:20) |>
404-
FindNeighbors( dims = 1:20, reduction = "mnn") |>
405-
FindClusters( resolution = 0.3)
416+
FindNeighbors(dims = 1:20, reduction = "mnn") |>
417+
FindClusters(resolution = 0.3)
406418
```
407419

408-
It was also possible to visualise the cells as a 3D plot using plotly.
409-
The example data used here only contains a few genes, for the sake of time and size in this demonstration, but below is how you could generate the 3 dimensions needed for 3D plot with a full dataset.
420+
As a final note, it's also possible to do complex and powerful things in a simple way, due to the integration of the tidy transcriptomics packages with the tidy universe. As one example, we can visualise the cells as a 3D plot using plotly.
421+
422+
The example data we've been using only contains a few genes, for the sake of time and size in this demonstration, but below is how you could generate the 3 dimensions needed for 3D plot with a full dataset.
410423

411424
```{r eval = FALSE}
412425
single_cell_object |>

0 commit comments

Comments
 (0)