Skip to content

Commit 65bf440

Browse files
committed
Split vignette into articles and add Articles navbar to pkgdown site
1 parent f2c3a32 commit 65bf440

File tree

7 files changed

+490
-349
lines changed

7 files changed

+490
-349
lines changed

_pkgdown.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ url: https://verapancaldilab.github.io/multideconv/
22
template:
33
bootstrap: 5
44

5+
navbar:
6+
structure:
7+
left: [intro, articles, reference, news]
8+
right: [search, github]
9+
components:
10+
articles:
11+
text: Articles
12+
menu:
13+
- text: "Deconvolution with default methods"
14+
href: articles/a1_deconvolution.html
15+
- text: "Single-cell deconvolution"
16+
href: articles/a2_single_cell.html
17+
- text: "Pseudo-bulk profiles and benchmarking"
18+
href: articles/a3_benchmark.html
19+
- text: "Cell type subgroup analysis"
20+
href: articles/a4_subgroups.html
21+
- text: "Machine learning workflows"
22+
href: articles/a5_machine_learning.html
23+
24+
articles:
25+
- title: "Tutorial"
26+
contents:
27+
- a1_deconvolution
28+
- a2_single_cell
29+
- a3_benchmark
30+
- a4_subgroups
31+
- a5_machine_learning
32+
533
reference:
634
- title: Main
735
desc: >

vignettes/a1_deconvolution.Rmd

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: "Deconvolution with default methods"
3+
output: rmarkdown::html_vignette
4+
vignette: >
5+
%\VignetteIndexEntry{Deconvolution with default methods}
6+
%\VignetteEngine{knitr::rmarkdown}
7+
%\VignetteEncoding{UTF-8}
8+
---
9+
10+
```{r, include = FALSE}
11+
knitr::opts_chunk$set(
12+
collapse = TRUE,
13+
comment = "#>"
14+
)
15+
```
16+
17+
```{r setup}
18+
library(multideconv)
19+
```
20+
21+
## **Deconvolution with default methods**
22+
23+
The basic function is to perform cell type deconvolution using six default methods (`quanTIseq`, `DeconRNASeq`, `CIBERSORTx`, `EpiDISH`, `DWLS`, `MOMF`) and nine default signatures (see paper [Hurtado et al., 2025](https://www.biorxiv.org/content/10.1101/2025.04.29.651220v2.article-info)). The function accepts either raw counts or TPM-normalized counts as input (with genes as SYMBOL).
24+
25+
**NOTE:** If you plan to use `CIBERSORTx`, you must provide your credentials (see README for details). The resulting deconvolution matrix is automatically saved in the `Results/` directory.
26+
27+
The output includes all combinations of deconvolution features, method-signature-cell type.
28+
29+
```{r, eval = FALSE}
30+
bulk = multideconv::raw_counts
31+
deconv = compute.deconvolution(raw.counts = bulk,
32+
methods = c("Quantiseq", "Epidish",
33+
"DeconRNASeq", "DWLS","MOMF"),
34+
normalized = TRUE,
35+
return = TRUE,
36+
file_name = "Tutorial")
37+
```
38+
39+
To exclude specific methods or signatures, use the methods or signatures_exclude arguments:
40+
41+
```{r, eval = FALSE}
42+
deconv = compute.deconvolution(raw.counts = bulk,
43+
methods = c("Quantiseq", "DeconRNASeq"),
44+
normalized = TRUE,
45+
signatures_exclude = "BPRNACan",
46+
return = TRUE,
47+
file_name = "Tutorial")
48+
```
49+
50+
To speed up computation, `multideconv` supports parallelization. Set `doParallel = TRUE` and specify the number of workers based on your system's resources:
51+
52+
```{r, eval = FALSE}
53+
deconv = compute.deconvolution(raw.counts = bulk,
54+
methods = "DWLS",
55+
normalized = TRUE,
56+
return = TRUE,
57+
file_name = "Tutorial",
58+
doParallel = TRUE,
59+
workers = 3)
60+
```
61+
62+
## **Cell type signatures**
63+
64+
In order to access the default signatures `multideconv` provides, you can do the following:
65+
66+
To list all signatures
67+
68+
```{r}
69+
path <- system.file("signatures/", package = "multideconv")
70+
list.files(path)
71+
```
72+
73+
To access a specific signature
74+
75+
```{r}
76+
signature = read.delim(paste0(path, "CBSX-Melanoma-scRNAseq.txt"))
77+
head(signature)
78+
```

vignettes/a2_single_cell.Rmd

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: "Single-cell deconvolution"
3+
output: rmarkdown::html_vignette
4+
vignette: >
5+
%\VignetteIndexEntry{Single-cell deconvolution}
6+
%\VignetteEngine{knitr::rmarkdown}
7+
%\VignetteEncoding{UTF-8}
8+
bibliography: references.bib
9+
link-citations: yes
10+
colorlinks: yes
11+
biblio-style: apalike
12+
---
13+
14+
```{r, include = FALSE}
15+
knitr::opts_chunk$set(
16+
collapse = TRUE,
17+
comment = "#>"
18+
)
19+
```
20+
21+
```{r setup}
22+
library(multideconv)
23+
```
24+
25+
## **Single-cell metacell construction**
26+
27+
If single-cell data is available, we recommend generating metacells to reduce computation time and prevent session crashes. Deconvolution methods that rely on single-cell data can be computationally intensive, especially with large matrices. We suggest using a maximum of 20k cells; if your object exceeds this size, creating metacells is strongly advised. However, if your computational resources are sufficient to handle the full single-cell dataset, you may skip this step.
28+
29+
We adapted functions from the R package hdWGCNA (@morabito2023hdwgcna; @langfelder2008wgcna) for the construction of metacells using the KNN algorithm.
30+
31+
- **sc_object**: Normalized gene expression matrix with genes as rows and cells as columns
32+
33+
- **labels_column**: Vector of cell annotations
34+
35+
- **samples_column**: Vector of sample IDs for each cell
36+
37+
- **exclude_cells**: Vector specifying which cell types to ignore during metacell construction (default is NULL)
38+
39+
- **min_cells**: Minimum number of cells required to construct metacells in a group
40+
41+
- **k**: Number of nearest neighbors used for the KNN algorithm
42+
43+
- **max_shared**: Maximum number of cells shared between two metacells
44+
45+
- **n_workers**: Number of cores to use for parallelizing metacell construction
46+
47+
- **min_meta**: Minimum number of metacells required for a cell type to be retained
48+
49+
Because of space limitations, we have not included a complete single-cell object in this tutorial. However, users are expected to provide their own single-cell data and supply it to the `sc_object` parameter in the function call.
50+
```{r, eval=FALSE}
51+
metacells = create_metacells(sc_object,
52+
labels_column = cell_labels,
53+
samples_column = sample_labels,
54+
exclude_cells = NULL,
55+
min_cells = 50,
56+
k = 15,
57+
max_shared = 15,
58+
n_workers = 4,
59+
min_meta = 10)
60+
```
61+
62+
## **Second-generation deconvolution methods**
63+
64+
Once the single-cell data is prepared, users can supplement the default deconvolution methods with second-generation approaches such as `AutogeneS`, `BayesPrism`, `Bisque`, `CPM`, `MuSic`, and `SCDC`. These methods learn cell-type signatures directly from annotated single-cell RNA-seq data, rather than relying on predefined static signatures (@Dietrich2024.06.10.598226), to deconvolve bulk RNA-seq profiles.
65+
66+
- **sc_deconv**: Boolean indicating whether to run second-generation methods
67+
68+
- **sc_matrix**: Normalized single-cell gene expression matrix
69+
70+
- **sc_metadata**: Dataframe containing single-cell metadata
71+
72+
- **cell_annotations**: Vector of cell type labels
73+
74+
- **cell_samples**: Vector of sample IDs
75+
76+
- **name_sc_signature**: Name to assign to the resulting signature
77+
78+
```{r}
79+
metacell_obj = multideconv::metacells_data
80+
metacell_metadata = multideconv::metacells_metadata
81+
head(metacell_obj[1:5,1:5])
82+
head(metacell_metadata)
83+
```
84+
85+
This function computes cell type deconvolution using the six default methods (`quanTIseq`, `DeconRNASeq`, `EpiDISH`, `DWLS`, `MOMF`) and `CIBERSORTx` (if credentials are provided), along with second-generation deconvolution approaches. The output includes all combinations of methods and signatures.
86+
87+
```{r, eval=FALSE}
88+
deconv = compute.deconvolution(raw.counts = bulk,
89+
normalized = TRUE,
90+
return = TRUE,
91+
methods = c("Quantiseq", "Epidish", "DeconRNASeq"),
92+
file_name = "Tutorial",
93+
sc_deconv = TRUE,
94+
sc_matrix = metacell_obj,
95+
sc_metadata = metacell_metadata,
96+
methods_sc = c("Autogenes", "BayesPrism",
97+
"Bisque", "CPM", "MuSic", "SCDC"),
98+
cell_label = "annotated_ct",
99+
sample_label = "sample",
100+
name_sc_signature = "Test")
101+
```
102+
103+
To run only the second-generation deconvolution methods based on single-cell data, without using any static cell-type signatures, use the following:
104+
105+
```{r, eval=FALSE}
106+
deconv_sc = compute_sc_deconvolution_methods(raw_counts = bulk,
107+
normalized = TRUE,
108+
methods_sc = c("Autogenes", "BayesPrism",
109+
"Bisque", "CPM", "MuSic", "SCDC"),
110+
sc_object = metacell_obj,
111+
sc_metadata = metacell_metadata,
112+
cell_annotations = "annotated_ct",
113+
samples_ids = "sample",
114+
name_object = "Test",
115+
n_cores = 2,
116+
return = TRUE,
117+
file_name = "Tutorial")
118+
```

vignettes/a3_benchmark.Rmd

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: "Pseudo-bulk profiles and benchmarking"
3+
output: rmarkdown::html_vignette
4+
vignette: >
5+
%\VignetteIndexEntry{Pseudo-bulk profiles and benchmarking}
6+
%\VignetteEngine{knitr::rmarkdown}
7+
%\VignetteEncoding{UTF-8}
8+
---
9+
10+
```{r, include = FALSE}
11+
knitr::opts_chunk$set(
12+
collapse = TRUE,
13+
comment = "#>"
14+
)
15+
```
16+
17+
```{r setup}
18+
library(multideconv)
19+
metacell_obj = multideconv::metacells_data
20+
metacell_metadata = multideconv::metacells_metadata
21+
```
22+
23+
## **Pseudo-bulk profiles**
24+
25+
To create pseudo-bulk profiles from the original single-cell objects, simulating a bulk RNA-seq dataset, you can use the following function:
26+
27+
**NOTE:** You can input either your original single-cell object or the metacell object. Just be sure to select the same object when examining the real cell proportions (if needed).
28+
29+
```{r}
30+
metacells_seurat = Seurat::CreateSeuratObject(metacell_obj, meta.data = metacell_metadata)
31+
pseudobulk = create_sc_pseudobulk(metacells_seurat, cells_labels = "annotated_ct", sample_labels = "sample", normalized = TRUE, file_name = "Tutorial")
32+
```
33+
34+
## **Creating cell type signatures**
35+
36+
To create cell type signatures, `multideconv` uses four methods: `CIBERSORTx`, `DWLS`, `MOMF`, and `BSeq-SC`. You must provide single-cell data as input. Signatures are saved in the `Results/custom_signatures` directory, and returned as a list. From now and after `compute.deconvolution()` will use these signatures additionally to the default ones! So if you would like to have the deconvolution results based on your new files, make sure to run `compute.deconvolution()`
37+
38+
To run `BSeq-SC`, supply the `cell_markers` argument, which should contain the differential markers for each cell type (these can be obtained using `FindMarkers()` or `FindAllMarkers()` from Seurat).
39+
40+
```{r, eval=FALSE}
41+
bulk_pseudo = multideconv::pseudobulk
42+
signatures = create_sc_signatures(metacell_obj,
43+
metacell_metadata,
44+
cells_labels = "annotated_ct",
45+
sample_labels = "sample",
46+
bulk_rna = bulk_pseudo,
47+
cell_markers = NULL,
48+
name_signature = "Test",
49+
methods_sig = c("DWLS", "CIBERSORTx", "MOMF", "BSeqsc"))
50+
```
51+
52+
## **Cell types signatures benchmark**
53+
54+
To validate the generated signatures, we provide a benchmarking function to compare deconvolution outputs against known cell proportions (e.g., from single-cell or imaging data). The `cells_extra` argument should include any non-standard cell types present in your ground truth. Make sure cell names match those in the deconvolution matrix (e.g., use B.cells instead of B cells if that is the naming convention used - see README for more information).
55+
56+
```{r}
57+
deconv_pseudo = multideconv::deconvolution
58+
cells_groundtruth = multideconv::cells_groundtruth
59+
benchmark = compute.benchmark(deconv_pseudo,
60+
cells_groundtruth,
61+
cells_extra = c("Mural.cells", "Myeloid.cells"),
62+
corr_type = "spearman",
63+
scatter = FALSE,
64+
plot = TRUE,
65+
pval = 0.05,
66+
file_name = "Tutorial",
67+
width = 10,
68+
height = 15)
69+
```
70+
71+
```{r hdwgcna-figure, echo=FALSE, fig.align='center', out.width='70%'}
72+
knitr::include_graphics("Results/Benchmark.png")
73+
```
74+
75+
::: {style="text-align: center;"}
76+
<em>Figure 1. Example of performance of different methods and signature combinations on the pseudo bulk.</em>
77+
:::

0 commit comments

Comments
 (0)