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

Commit 669afa6

Browse files
authored
Merge pull request #10 from tidytranscriptomics-workshops/edits-stefano
Edits stefano
2 parents a2d99cd + f416cbf commit 669afa6

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

data/seurat_obj.rda

-904 Bytes
Binary file not shown.

data/seurat_obj_UMAP3.rda

-47.4 KB
Binary file not shown.

vignettes/solutions.Rmd

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "solutions"
3+
author: "Stefano Mangiola and Maria Doyle"
4+
date: "2/18/2022"
5+
output: html_document
6+
---
7+
8+
```{r message = FALSE}
9+
library(Seurat)
10+
library(ggplot2)
11+
library(plotly)
12+
library(dplyr)
13+
library(colorspace)
14+
library(SeuratWrappers)
15+
library(dittoSeq)
16+
```
17+
18+
## Question 1
19+
20+
What is the proportion of gamma-delta T cells, among all cells?
21+
22+
```{r, eval=FALSE}
23+
24+
seurat_obj |>
25+
26+
27+
join_features(
28+
features = c("CD3D", "TRDC", "TRGC1", "TRGC2", "CD8A", "CD8B"),
29+
shape = "wide",
30+
assay = "SCT"
31+
32+
) |>
33+
34+
mutate(signature_score =
35+
scales::rescale(CD3D + TRDC + TRGC1+ TRGC2, to=c(0,1)) -
36+
scales::rescale(CD8A + CD8B, to=c(0,1))
37+
) |>
38+
39+
mutate(gate = tidygate::gate_int(
40+
UMAP_1, UMAP_2,
41+
.size = 0.1,
42+
.color =signature_score
43+
)) |>
44+
45+
count(gate) %>%
46+
summarise(proportion = n/sum(n))
47+
48+
49+
```
50+
51+
## Question 2
52+
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.
54+
55+
56+
```{r, eval=FALSE}
57+
58+
seurat_obj |>
59+
60+
mutate(gate = tidygate::gate_int(
61+
UMAP_1, UMAP_2,
62+
.size = 0.1,
63+
.color =nCount_RNA
64+
)) %>%
65+
66+
filter(gate==1) %>%
67+
count(curated_cell_type)
68+
69+
```

vignettes/tidytranscriptomics_case_study.Rmd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,17 +377,19 @@ For comparison, we show the alternative using base R and Seurat
377377
378378
counts_positive =
379379
GetAssayData(seurat_obj, assay="SCT")[c("CD3D", "TRDC", "TRGC1", "TRGC2"),] |>
380-
colSums()
380+
colSums() |>
381+
scales::rescale(to=c(0,1))
381382
382383
counts_negative =
383384
GetAssayData(seurat_obj, assay="SCT")[c("CD8A", "CD8B"),] |>
384-
colSums()
385+
colSums() |>
386+
scales::rescale(to=c(0,1))
385387
386388
seurat_obj$signature_score = counts_positive - counts_negative
387389
388390
p = FeaturePlot(seurat_obj, features = "signature_score")
389391
390-
# This is not reproducible (on the constrary of tidygate)
392+
# This is not reproducible (on the contrary of tidygate)
391393
seurat_obj$within_gate = colnames(seurat_obj) %in% CellSelector(plot = p)
392394
393395
seurat_obj |>

0 commit comments

Comments
 (0)