Skip to content

Commit 2f0b31a

Browse files
authored
Merge pull request #59 from william-hutchison/master
Added aggregate cells function to README and vignette
2 parents cc0a8b7 + f42f5f0 commit 2f0b31a

File tree

3 files changed

+66
-10
lines changed

3 files changed

+66
-10
lines changed

README.Rmd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Utilities | Description
4848
`tidy` | Add `tidySingleCellExperiment` invisible layer over a SingleCellExperiment object
4949
`as_tibble` | Convert cell-wise information to a `tbl_df`
5050
`join_features` | Add feature-wise information, returns a `tbl_df`
51+
`aggregate_cells` | Aggregate cell gene-transcription abundance as pseudobulk tissue
52+
5153

5254
## Installation
5355

@@ -459,3 +461,14 @@ If the dataset was not so small, and interactions could be identified, you would
459461
```{r}
460462
tidySingleCellExperiment::pbmc_small_nested_interactions
461463
```
464+
465+
# Aggregating cells
466+
467+
Sometimes, it is necessary to aggregate the gene-transcript abundance from a group of cells into a single value. For example, when comparing groups of cells across different samples with fixed-effect models.
468+
469+
In tidySingleCellExperiment, cell aggregation can be achieved using the `aggregate_cells` function.
470+
471+
```{r}
472+
pbmc_small_tidy %>%
473+
aggregate_cells(groups, assays = "counts")
474+
```

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ both Bioconductor and tidyverse worlds.
4949
| `ggplot2` | `ggplot` (`tidySingleCellExperiment::ggplot`) |
5050
| `plotly` | `plot_ly` (`tidySingleCellExperiment::plot_ly`) |
5151

52-
| Utilities | Description |
53-
|-----------------|-----------------------------------------------------------------------------------|
54-
| `tidy` | Add `tidySingleCellExperiment` invisible layer over a SingleCellExperiment object |
55-
| `as_tibble` | Convert cell-wise information to a `tbl_df` |
56-
| `join_features` | Add feature-wise information, returns a `tbl_df` |
52+
| Utilities | Description |
53+
|------------------|-----------------------------------------------------------------------------------|
54+
| `tidy` | Add `tidySingleCellExperiment` invisible layer over a SingleCellExperiment object |
55+
| `as_tibble` | Convert cell-wise information to a `tbl_df` |
56+
| `join_features` | Add feature-wise information, returns a `tbl_df` |
57+
| `aggregate_cells`| Aggregate cell gene-transcription abundance as pseudobulk tissue |
58+
5759

5860
## Installation
5961

@@ -98,7 +100,7 @@ pbmc_small_tidy
98100
```
99101

100102
## # A SingleCellExperiment-tibble abstraction: 80 × 17
101-
## # Features=230 | Cells=80 | Assays=counts, logcounts
103+
## # [90mFeatures=230 | Cells=80 | Assays=counts, logcounts[0m
102104
## .cell orig.…¹ nCoun…² nFeat…³ RNA_s…⁴ lette…⁵ groups RNA_s…⁶ file ident
103105
## <chr> <fct> <dbl> <int> <fct> <fct> <chr> <fct> <chr> <fct>
104106
## 1 ATGCCAGAA… Seurat… 70 47 0 A g2 0 ../d… 0
@@ -168,7 +170,7 @@ pbmc_small_polished %>%
168170
```
169171

170172
## # A SingleCellExperiment-tibble abstraction: 80 × 18
171-
## # Features=230 | Cells=80 | Assays=counts, logcounts
173+
## # [90mFeatures=230 | Cells=80 | Assays=counts, logcounts[0m
172174
## .cell sample orig.…¹ nCoun…² nFeat…³ RNA_s…⁴ lette…⁵ groups RNA_s…⁶ file
173175
## <chr> <chr> <fct> <dbl> <int> <fct> <fct> <chr> <fct> <chr>
174176
## 1 ATGCCAGA… sampl… Seurat… 70 47 0 A g2 0 ../d…
@@ -290,7 +292,7 @@ pbmc_small_pca
290292
```
291293

292294
## # A SingleCellExperiment-tibble abstraction: 80 × 18
293-
## # Features=230 | Cells=80 | Assays=counts, logcounts
295+
## # [90mFeatures=230 | Cells=80 | Assays=counts, logcounts[0m
294296
## .cell orig.…¹ nCoun…² nFeat…³ RNA_s…⁴ lette…⁵ groups RNA_s…⁶ file sample
295297
## <chr> <fct> <dbl> <int> <fct> <fct> <chr> <fct> <chr> <chr>
296298
## 1 ATGCCAGA… Seurat… 70 47 0 A g2 0 ../d… sampl…
@@ -353,7 +355,7 @@ pbmc_small_cluster %>% select(label, everything())
353355
```
354356

355357
## # A SingleCellExperiment-tibble abstraction: 80 × 19
356-
## # Features=230 | Cells=80 | Assays=counts, logcounts
358+
## # [90mFeatures=230 | Cells=80 | Assays=counts, logcounts[0m
357359
## .cell label orig.…¹ nCoun…² nFeat…³ RNA_s…⁴ lette…⁵ groups RNA_s…⁶ file
358360
## <chr> <fct> <fct> <dbl> <int> <fct> <fct> <chr> <fct> <chr>
359361
## 1 ATGCCAGAA… 2 Seurat… 70 47 0 A g2 0 ../d…
@@ -503,7 +505,7 @@ pbmc_small_cell_type %>%
503505
## workflow to reflect the new vocabulary (.cell)
504506

505507
## # A SingleCellExperiment-tibble abstraction: 80 × 23
506-
## # Features=230 | Cells=80 | Assays=counts, logcounts
508+
## # [90mFeatures=230 | Cells=80 | Assays=counts, logcounts[0m
507509
## cell first…¹ orig.…² nCoun…³ nFeat…⁴ RNA_s…⁵ lette…⁶ groups RNA_s…⁷ file
508510
## <chr> <chr> <fct> <dbl> <int> <fct> <fct> <chr> <fct> <chr>
509511
## 1 ATGCCAG… CD4+ T… Seurat… 70 47 0 A g2 0 ../d…
@@ -757,3 +759,32 @@ tidySingleCellExperiment::pbmc_small_nested_interactions
757759
## # … with 90 more rows, and abbreviated variable names ¹​receptor, ²​ligand.name,
758760
## # ³​receptor.name, ⁴​destination, ⁵​interaction.type
759761
## # ℹ Use `print(n = ...)` to see more rows
762+
763+
# Aggregating cells
764+
765+
Sometimes, it is necessary to aggregate the gene-transcript abundance from a group of cells into a single value. For example, when comparing groups of cells across different samples with fixed-effect models.
766+
767+
In tidySingleCellExperiment, cell aggregation can be achieved using the `aggregate_cells` function.
768+
769+
``` r
770+
pbmc_small_tidy %>%
771+
aggregate_cells(groups, assays = "counts")
772+
```
773+
774+
## # A SummarizedExperiment-tibble abstraction: 460 × 2
775+
## # Features=230 | Samples=2 | Assays=counts
776+
## .feature .sample counts groups .aggregated_cells orig.ident file feature
777+
## <chr> <chr> <dbl> <chr> <int> <fct> <chr> <chr>
778+
## 1 ACAP1 g1 9 g1 44 SeuratProject ../data/sample1/out… ACAP1
779+
## 2 ACRBP g1 29 g1 44 SeuratProject ../data/sample1/out… ACRBP
780+
## 3 ACSM3 g1 2 g1 44 SeuratProject ../data/sample1/out… ACSM3
781+
## 4 ADAR g1 33 g1 44 SeuratProject ../data/sample1/out… ADAR
782+
## 5 AIF1 g1 209 g1 44 SeuratProject ../data/sample1/out… AIF1
783+
## 6 AKR1C3 g1 14 g1 44 SeuratProject ../data/sample1/out… AKR1C3
784+
## 7 ALOX5AP g1 19 g1 44 SeuratProject ../data/sample1/out… ALOX5AP
785+
## 8 ANXA2 g1 87 g1 44 SeuratProject ../data/sample1/out… ANXA2
786+
## 9 ARHGDIA g1 23 g1 44 SeuratProject ../data/sample1/out… ARHGDIA
787+
## 10 ASGR1 g1 9 g1 44 SeuratProject ../data/sample1/out… ASGR1
788+
## # … with 40 more rows
789+
## # ℹ Use `print(n = ...)` to see more rows
790+

vignettes/introduction.Rmd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Utilities | Description
4545
`tidy` | Add `tidySingleCellExperiment` invisible layer over a SingleCellExperiment object
4646
`as_tibble` | Convert cell-wise information to a `tbl_df`
4747
`join_features` | Add feature-wise information, returns a `tbl_df`
48+
`aggregate_cells` | Aggregate cell gene-transcription abundance as pseudobulk tissue
4849

4950
## Installation
5051

@@ -457,6 +458,17 @@ If the dataset was not so small, and interactions could be identified, you would
457458
tidySingleCellExperiment::pbmc_small_nested_interactions
458459
```
459460

461+
# Aggregating cells
462+
463+
Sometimes, it is necessary to aggregate the gene-transcript abundance from a group of cells into a single value. For example, when comparing groups of cells across different samples with fixed-effect models.
464+
465+
In tidySingleCellExperiment, cell aggregation can be achieved using the `aggregate_cells` function.
466+
467+
```{r}
468+
pbmc_small_tidy %>%
469+
aggregate_cells(groups, assays = "counts")
470+
```
471+
460472
# Session Info
461473

462474
```{r}

0 commit comments

Comments
 (0)