Skip to content

Commit 5e8c44b

Browse files
authored
Merge pull request #16 from tidytranscriptomics-workshops/details_stefano
update vignette and presentation
2 parents 9d2d5df + b16521f commit 5e8c44b

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ bioc2022tidytranscriptomics*.tgz
1010
dev
1111
/doc/
1212
/Meta/
13+
.DS_Store
14+
._.DS_Store

data-raw/seurat_obj.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ sce_obj =
4444
rename(cell_type = curated_cell_type) |>
4545

4646
# filtering because of to few samples per cell types
47-
filter(cell_type !="CD8+_Tem")
47+
filter(cell_type !="CD8+_Tem") |>
48+
49+
# Replace file path
50+
mutate(file = file |> str_replace("bhupinder_10X_260819", "single_cell"))
4851

4952
# job::job({
5053
save(sce_obj , file="data/sce_obj.rda", compress = "xz")

data/sce_obj.rda

-1.98 KB
Binary file not shown.

inst/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
._.smbdeleteAAA240c2803
2+
._bioc2022_tidytranscriptomics.pdf
3+
.smbdeleteAAA240c2803

inst/bioc2022_tidytranscriptomics.pdf

-1.12 MB
Binary file not shown.

vignettes/tidytranscriptomics_case_study.Rmd

+13-10
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,16 @@ We use tidyverse `nest` to group the data. The command below will create a tibbl
453453

454454
```{r}
455455
pseudo_bulk |>
456-
nest(data = -cell_type)
456+
nest(grouped_summarized_experiment = -cell_type)
457457
```
458458

459459
To explore the grouping, we can use tidyverse `slice` to choose a row (cell_type) and `pull` to extract the values from a column. If we pull the data column we can view the SummarizedExperiment object.
460460

461461
```{r}
462462
pseudo_bulk |>
463-
nest(data = -cell_type) |>
463+
nest(grouped_summarized_experiment = -cell_type) |>
464464
slice(1) |>
465-
pull(data)
465+
pull(grouped_summarized_experiment)
466466
```
467467

468468
We can then identify differentially expressed genes for each cell type for our condition of interest, treated versus untreated patients. We use tidyverse `map` to apply differential expression functions to each cell type group in the nested data.
@@ -473,11 +473,11 @@ pseudo_bulk <-
473473
474474
pseudo_bulk |>
475475
476-
nest(data = -cell_type) |>
476+
nest(grouped_summarized_experiment = -cell_type) |>
477477
478478
# map accepts a data column (.x) and applies functions to each element
479-
mutate(data = map(
480-
data,
479+
mutate(grouped_summarized_experiment = map(
480+
grouped_summarized_experiment,
481481
~ .x |>
482482
# Now using tidybulk on SummarizedExperiment
483483
identify_abundant(factor_of_interest = treatment) |>
@@ -497,7 +497,7 @@ If we pull out the SummarizedExperiment object for the first cell type, as befor
497497
```{r}
498498
pseudo_bulk |>
499499
slice(1) |>
500-
pull(data)
500+
pull(grouped_summarized_experiment)
501501
```
502502

503503
Now we can create plots for significant genes for each cell type, visualising their transcriptional abundance, also without needing to create multiple objects.
@@ -509,16 +509,19 @@ pseudo_bulk <-
509509
510510
# Filter out significant
511511
# using a high FDR value as this is toy data
512-
mutate(data = map(data, ~ filter(.x, FDR < 0.5))) |>
512+
mutate(grouped_summarized_experiment = map(
513+
grouped_summarized_experiment,
514+
~ filter(.x, FDR < 0.5)
515+
)) |>
513516
514517
# Filter cell types with no differential abundant gene-transcripts
515518
# map_int is map that returns integer instead of list
516-
filter(map_int(data, ~ nrow(.x)) > 0) |>
519+
filter(map_int(grouped_summarized_experiment, ~ nrow(.x)) > 0) |>
517520
518521
# Plot
519522
# map2 is map that accepts 2 input columns (.x, .y)
520523
mutate(plot = map2(
521-
data, cell_type,
524+
grouped_summarized_experiment, cell_type,
522525
~ .x |>
523526
ggplot(aes(treatment, counts_scaled + 1)) +
524527
geom_boxplot(aes(fill = treatment)) +

0 commit comments

Comments
 (0)