-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.Rhistory | ||
.Rproj.user | ||
.DS_Store | ||
*vignettes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
title: "FuseNet Tutorial" | ||
date: 'Last Run: `r format(Sys.Date(), "%B %d, %Y")`' | ||
output: | ||
html_document: | ||
theme: united | ||
df_print: kable | ||
--- | ||
|
||
```{r, include = FALSE} | ||
options(width = 150) | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
tidy = FALSE, | ||
message = FALSE, | ||
warning = FALSE | ||
) | ||
``` | ||
|
||
### Load data | ||
|
||
We will be analyzing the [CITE-seq](https://www.nature.com/articles/nmeth.4380) human PBMC data. This data can be installed with [SeuratData](https://github.com/satijalab/seurat-data). | ||
|
||
```{r setup} | ||
# install Seurat v4.0.0 and SeuratData | ||
if (!requireNamespace("Seurat", quietly = TRUE) | utils::packageVersion("Seurat") < "4.0.0") | ||
remotes::install_version("Seurat", version = "4.0.0") | ||
if (!requireNamespace("SeuratData", quietly = TRUE)) | ||
devtools::install_github('satijalab/seurat-data') | ||
library(FuseNet) | ||
library(Seurat) | ||
library(SeuratData) | ||
InstallData("cbmc") | ||
library(cbmc.SeuratData) | ||
# Find highly variable features/genes | ||
cbmc <- FindVariableFeatures(cbmc, selection.method = "vst", verbose = FALSE) | ||
``` | ||
|
||
### Run FuseNet on RNA data | ||
|
||
```{r RNA, fig.height=5, fig.width=10} | ||
data_rna <- cbmc@assays$RNA@counts[VariableFeatures(cbmc),] | ||
cbmc_rna <- InitiateFuseNet(raw_data = data_rna, project_name = "RNA", normalization = "cosine", pca_dims = 20, kernel = "gaussian", k = 15) | ||
cbmc_rna <- GeomSketch(object = cbmc_rna, geom_pca_dims = 20, geom_size = 3000, sketch_n_pca = 20, sketch_k = 15) | ||
ptm <- proc.time() | ||
cbmc_rna <- RunFuseNet(object = cbmc_rna, n_iters = 100, pca_dims = 20, k = 15, ratio = 0.5, norm_type = "l1") | ||
ptm1 <- proc.time() | ||
print(x = ptm1 - ptm) | ||
``` | ||
|
||
### Run FuseNet on ADT data | ||
|
||
```{r ADT} | ||
data_prt <- cbmc@assays$ADT@counts | ||
cbmc_prt <- InitiateFuseNet(raw_data = data_prt, project_name = "Protein", normalization = "cosine", kernel = "gaussian", k = 15, verbose = FALSE) | ||
cbmc_prt <- GeomSketch(object = cbmc_prt, geom_size = 3000, geom_pca_dims = 3, sketch_n_pca = 0, sketch_k = 15) | ||
ptm <- proc.time() | ||
cbmc_prt <- RunFuseNet(object = cbmc_prt, n_iters = 100, ratio = 0.5, k = 15, norm_type = "l1") | ||
ptm1 <- proc.time() | ||
print(x = ptm1 - ptm) | ||
``` | ||
|
||
### Fuse the RNA and ADT data. | ||
|
||
We see that the mouse cells, which were used as the spike-in controls, were defined almost exclusively by RNA modality (RNA weight > 0.8). This is because there is no anti-mouse antibodies were used in the study. | ||
|
||
In general lymphocytes were well defined in the ADT modality (protein weights > 0.6). Especially, CD8+ and CD4+ naive and memory T cells were more defined by the ADT data, on the other hand, dendritic cells (DC and pDCs) were more defined in the RNA data due to the absence of its surface markers in the ADT data. | ||
|
||
```{r fuse, fig.height=6, fig.width=10} | ||
fused <- FuseData(cbmc_rna, cbmc_prt, project_k = 15) | ||
[email protected]["RNA_Weight"] <- fused$fused_weight["RNA",] | ||
[email protected]["Protein_Weight"] <- fused$fused_weight["Protein",] | ||
VlnPlot(object = cbmc, features = c("RNA_Weight", "Protein_Weight"), sort = TRUE, group.by = "rna_annotations") | ||
``` | ||
|
||
### Downstream analysis | ||
|
||
We can perform UMAP dimensional reduction or clustering on the fused data for downstream analysis. | ||
|
||
```{r umap, fig.height=8, fig.width=10} | ||
umap.dims <- uwot::umap(X = fused$fused_dist, n_components = 2) | ||
dimnames(x = umap.dims) <- list(Cells(cbmc), c("UMAP_1", "UMAP_2")) | ||
cbmc@reductions$umap <- CreateDimReducObject(embeddings = umap.dims, key = "UMAP_", assay = c("RNA", "ADT")) | ||
cbmc@[email protected] = umap.dims | ||
DimPlot(object = cbmc, group.by = "rna_annotations", reduction = "umap", label = TRUE, repel = TRUE, label.box = TRUE) | ||
``` | ||
|
||
### Session Information | ||
```{r session} | ||
print(sessionInfo()) | ||
``` |