Last updated: 2021-03-01
Checks: 6 1
Knit directory: single-cell-topics/analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2.9000). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(1)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
To ensure reproducibility of the results, delete the cache directory plots_purified_pbmc_cache
and re-run the analysis. To have workflowr automatically delete the cache directory prior to building the file, set delete_cache = TRUE
when running wflow_build()
or wflow_publish()
.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version fdef8d8. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: data/droplet.RData
Ignored: data/pbmc_68k.RData
Ignored: data/pbmc_purified.RData
Ignored: data/pulseseq.RData
Ignored: output/droplet/diff-count-droplet.RData
Ignored: output/droplet/fits-droplet.RData
Ignored: output/droplet/rds/
Ignored: output/pbmc-68k/fits-pbmc-68k.RData
Ignored: output/pbmc-68k/rds/
Ignored: output/pbmc-purified/fits-pbmc-purified.RData
Ignored: output/pbmc-purified/rds/
Ignored: output/pulseseq/diff-count-pulseseq.RData
Ignored: output/pulseseq/fits-pulseseq.RData
Ignored: output/pulseseq/rds/
Untracked files:
Untracked: analysis/gsea_plot_bcells.html
Untracked: analysis/gsea_plot_cd14.html
Untracked: analysis/gsea_plot_cd34.html
Untracked: analysis/gsea_plot_nk.html
Untracked: analysis/gsea_plot_rp.html
Untracked: analysis/gsea_plot_tcells.html
Untracked: analysis/plots_purified_pbmc_cache/
Untracked: plots/
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/plots_purified_pbmc.Rmd
) and HTML (docs/plots_purified_pbmc.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | fdef8d8 | Peter Carbonetto | 2021-03-01 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”) |
html | 93ac093 | Peter Carbonetto | 2021-03-01 | Build site. |
html | b84788d | Peter Carbonetto | 2021-03-01 | Build site. |
Rmd | f65e1f8 | Peter Carbonetto | 2021-03-01 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
html | dac053f | Peter Carbonetto | 2021-02-28 | Added gsea plots to plots_purified_pbmc analysis. |
Rmd | d50e70e | Peter Carbonetto | 2021-02-28 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
Rmd | 54894e2 | Peter Carbonetto | 2021-02-26 | Working on gsea in plots_purified_pbmc analysis. |
Rmd | 36d8c92 | Peter Carbonetto | 2021-02-26 | Working on new gsea step in plots_purified_pbmc analysis. |
html | 5773c6c | Peter Carbonetto | 2021-02-25 | Adjusted dimensions of the scatterplots in the plots_purified_pbmc |
Rmd | 3a31fac | Peter Carbonetto | 2021-02-25 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
html | ced5127 | Peter Carbonetto | 2021-02-25 | Added scatterplots back to plots_purified_pbmc analysis. |
Rmd | 4d9e8ba | Peter Carbonetto | 2021-02-25 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
html | d21aab5 | Peter Carbonetto | 2021-02-24 | Re-built the plots_purified_pbmc analysis with the revised volcano plots. |
Rmd | f79d2e8 | Peter Carbonetto | 2021-02-24 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”) |
html | 7be2e95 | Peter Carbonetto | 2021-02-24 | Rebuilt the plots_purified_pbmc analysis. |
Rmd | 3d7de41 | Peter Carbonetto | 2021-02-24 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
Rmd | 0163047 | Peter Carbonetto | 2021-02-24 | Updated volcano plots using K=6 topic model in plots_purified_pbmc analysis. |
Rmd | a5c70b4 | Peter Carbonetto | 2021-02-24 | Revised the FACS-based and cluster-based volcano plots in the plots_pbmc_purified analysis. |
Rmd | 0748309 | Peter Carbonetto | 2021-02-19 | Revised volcano plots in plots_purified_pbmc analysis; working on examine_de_calculations.R. |
Rmd | 65dbb1e | Peter Carbonetto | 2021-02-17 | Made improvements to volcano plots in plots_purified_pbmc analysis after fixing DE calculations. |
Rmd | 14401d5 | Peter Carbonetto | 2021-02-10 | Working on GSEA in plots_purified_pbmc analysis. |
html | 6e2b53a | Peter Carbonetto | 2021-02-10 | Adjusted dimensions of scatterplots in plots_purified_pbmc analysis. |
Rmd | 81c6f10 | Peter Carbonetto | 2021-02-10 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
Rmd | d6340b7 | Peter Carbonetto | 2021-02-10 | Updated the volcano plots for GitHub Pages. |
html | 9afb462 | Peter Carbonetto | 2021-02-10 | Updated volcano plots and added ribosomal gene scatterplots to |
Rmd | 13fedd9 | Peter Carbonetto | 2021-02-10 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
html | f8e1d99 | Peter Carbonetto | 2021-02-10 | Re-built plots_purified_pbmc page. |
Rmd | 3e298d4 | Peter Carbonetto | 2021-02-10 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
html | d1d4185 | Peter Carbonetto | 2021-02-10 | Re-built plots_purified_pbmc with interactive volcano plots. |
Rmd | 676e053 | Peter Carbonetto | 2021-02-10 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
Rmd | 52d16f3 | Peter Carbonetto | 2021-02-10 | Created topic volcano plots for paper in plots_purified_pbmc analysis. |
html | f596d8a | Peter Carbonetto | 2021-02-09 | Made further refinements to the volcano plots in the |
Rmd | cf1e3d2 | Peter Carbonetto | 2021-02-09 | Added script purified_pbmc_k7.R. |
Rmd | dd1d2ca | Peter Carbonetto | 2021-02-09 | Working on volcano plots in plots_purified_pbmc analysis. |
html | d0775d2 | Peter Carbonetto | 2021-02-09 | Re-built plots_purified_pbmc page after making improvements to the |
Rmd | aecd700 | Peter Carbonetto | 2021-02-09 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
Rmd | 1f0eb8c | Peter Carbonetto | 2021-02-08 | More improvements to volcano plots in plots_purified_pbmc.Rmd. |
Rmd | be27738 | Peter Carbonetto | 2021-02-08 | Improved volcano plots for FACS cell populations in plots_purified_pbmc.Rmd. |
html | ab3eeb8 | Peter Carbonetto | 2021-01-29 | Build site. |
Rmd | 0b73397 | Peter Carbonetto | 2021-01-29 | Added more volcano plots to plots_purified_pbmc analysis. |
html | 42ebc62 | Peter Carbonetto | 2021-01-29 | Added volcano plots for FACS populations in plots_purified_pbmc |
Rmd | 4edefd0 | Peter Carbonetto | 2021-01-29 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”) |
Rmd | 01c1139 | Peter Carbonetto | 2021-01-29 | Adding new code for volcano plots in plots_purified_pbmc analysis. |
html | a4bc59b | Peter Carbonetto | 2021-01-06 | Re-built plots_purified_pbmc page after removing cache. |
Rmd | b92d4db | Peter Carbonetto | 2021-01-06 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”) |
html | a0b6c2b | Peter Carbonetto | 2021-01-06 | Build site. |
Rmd | ed8a595 | Peter Carbonetto | 2021-01-06 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
html | 0411340 | Peter Carbonetto | 2021-01-06 | Added scatterplots to plots_purified_pbmc analysis. |
Rmd | e16bf80 | Peter Carbonetto | 2021-01-06 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”) |
Rmd | a12c42a | Peter Carbonetto | 2021-01-05 | Implemented function lfc_scatterplot in functions_for_plots_purified_pbmc.R. |
Rmd | 9fd0455 | Peter Carbonetto | 2021-01-05 | Added steps to save volcano plots in plots_purified_pbmc analysis. |
html | fad8e3d | Peter Carbonetto | 2021-01-05 | First build of plots_purified_pbmc page. |
Rmd | bf07930 | Peter Carbonetto | 2021-01-05 | workflowr::wflow_publish(“plots_purified_pbmc.Rmd”, verbose = TRUE) |
Rmd | 40c2d84 | Peter Carbonetto | 2021-01-04 | Working on log-fold change scatterplots in plots_purified_pbmc analysis. |
Rmd | e437ddf | Peter Carbonetto | 2021-01-04 | Working on volcano plots in plots_purified_pbmc analysis. |
Here we perform a differential expression analysis using the topic model fit to the mixture of FACS-purified data, as well as the clusters identified from this topic model.
Load the packages used in the analysis below, as well as additional functions that we will use to generate some of the plots.
library(Matrix)
library(fastTopics)
library(pathways)
library(ggplot2)
library(cowplot)
library(ggrepel)
source("../code/functions_for_plots_purified_pbmc.R")
Load the count data, the \(K = 6\) topic model fit, and the 7 clusters identified in the clustering analysis.
load("../data/pbmc_purified.RData")
fit <- readRDS(file.path("../output/pbmc-purified/rds",
"fit-pbmc-purified-scd-ex-k=6.rds"))$fit
fit <- poisson2multinom(fit)
samples <- readRDS("../output/pbmc-purified/clustering-pbmc-purified.rds")
Perform differential expression analysis using the FACS labeling:
celltype <- as.character(samples$celltype)
celltype[celltype == "CD4+/CD45RA+/CD25- Naive T" |
celltype == "CD4+/CD45RO+ Memory" |
celltype == "CD8+/CD45RA+ Naive Cytotoxic" |
celltype == "CD4+ T Helper2" |
celltype == "CD4+/CD25 T Reg"] <- "T cell"
celltype <- factor(celltype)
table(celltype)
diff_count_facs <- diff_count_clusters(celltype,counts)
# celltype
# CD14+ Monocyte CD19+ B CD34+ CD56+ NK
# 2612 10085 9232 8385
# CD8+ Cytotoxic T T cell
# 10209 54132
# Fitting 21952 x 6 = 131712 univariate Poisson models.
# Computing log-fold change statistics.
# Stabilizing log-fold change estimates using adaptive shrinkage.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE)
at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson
for each individual chunk that is cached. Using either autodep
or dependson
will remove this warning. See the knitr cache options for more details.
These volcano plots summarize the results of the differential expression analysis using the FACS labeling:
p1 <- volcano_plot(diff_count_facs,"CD19+ B",genes$symbol,
betamax = 10,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("B cells")
p2 <- volcano_plot(diff_count_facs,"CD14+ Monocyte",genes$symbol,
betamax = 10,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("CD14+ cells")
p3 <- volcano_plot(diff_count_facs,"CD34+",genes$symbol,
betamax = 10,label_above_lfc = 2,
label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("CD34+ cells")
p4 <- volcano_plot(diff_count_facs,"CD56+ NK",genes$symbol,
betamax = 10,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("NK cells")
p5 <- volcano_plot(diff_count_facs,"CD8+ Cytotoxic T",genes$symbol,
betamax = 10,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("CD8+ T cells")
p6 <- volcano_plot(diff_count_facs,"T cell",genes$symbol,
betamax = 10,label_above_quantile = 0.998,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("T cells")
plot_grid(p1,p2,p3,p4,p5,p6,nrow = 2,ncol = 3)
Version | Author | Date |
---|---|---|
93ac093 | Peter Carbonetto | 2021-03-01 |
b84788d | Peter Carbonetto | 2021-03-01 |
dac053f | Peter Carbonetto | 2021-02-28 |
5773c6c | Peter Carbonetto | 2021-02-25 |
ced5127 | Peter Carbonetto | 2021-02-25 |
d21aab5 | Peter Carbonetto | 2021-02-24 |
7be2e95 | Peter Carbonetto | 2021-02-24 |
6e2b53a | Peter Carbonetto | 2021-02-10 |
9afb462 | Peter Carbonetto | 2021-02-10 |
f8e1d99 | Peter Carbonetto | 2021-02-10 |
d1d4185 | Peter Carbonetto | 2021-02-10 |
f596d8a | Peter Carbonetto | 2021-02-09 |
d0775d2 | Peter Carbonetto | 2021-02-09 |
ab3eeb8 | Peter Carbonetto | 2021-01-29 |
42ebc62 | Peter Carbonetto | 2021-01-29 |
a4bc59b | Peter Carbonetto | 2021-01-06 |
a0b6c2b | Peter Carbonetto | 2021-01-06 |
0411340 | Peter Carbonetto | 2021-01-06 |
fad8e3d | Peter Carbonetto | 2021-01-05 |
Perform differential expression analysis using the clusters:
table(samples$cluster)
diff_count_clusters <- diff_count_clusters(samples$cluster,counts)
#
# B CD14+ CD34+ CD8+ dendritic NK T
# 10439 2956 8237 3757 308 8380 60578
# Fitting 21952 x 7 = 153664 univariate Poisson models.
# Computing log-fold change statistics.
# Stabilizing log-fold change estimates using adaptive shrinkage.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE)
at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson
for each individual chunk that is cached. Using either autodep
or dependson
will remove this warning. See the knitr cache options for more details.
These volcano plots summarize the results of the differential expression analysis using the clusters:
p7 <- volcano_plot(diff_count_clusters,"B",genes$symbol,betamax = 10,
label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("B cells")
p8 <- volcano_plot(diff_count_clusters,"CD14+",genes$symbol,betamax = 10,
label_above_quantile = 0.993,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("CD14+ cells")
p9 <- volcano_plot(diff_count_clusters,"CD34+",genes$symbol,betamax = 10,
label_above_lfc = 4,label_above_quantile = 0.99,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("CD34+ cells")
p10 <- volcano_plot(diff_count_clusters,"dendritic",genes$symbol,betamax = 10,
label_above_lfc = 4,label_above_quantile = 0.98,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("dendritic cells")
p11 <- volcano_plot(diff_count_clusters,"NK",genes$symbol,betamax = 10,
label_above_lfc = 2,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("NK cells")
p12 <- volcano_plot(diff_count_clusters,"CD8+",genes$symbol,betamax = 10,
label_above_lfc = 2,label_above_quantile = 0.98,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("CD8+ T cells")
p13 <- volcano_plot(diff_count_clusters,"T",genes$symbol,betamax = 10,
label_above_lfc = 2,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("T cells")
plot_grid(p7,p8,p9,p10,p11,p12,p13,nrow = 3,ncol = 3)
Version | Author | Date |
---|---|---|
93ac093 | Peter Carbonetto | 2021-03-01 |
b84788d | Peter Carbonetto | 2021-03-01 |
dac053f | Peter Carbonetto | 2021-02-28 |
5773c6c | Peter Carbonetto | 2021-02-25 |
ced5127 | Peter Carbonetto | 2021-02-25 |
d21aab5 | Peter Carbonetto | 2021-02-24 |
7be2e95 | Peter Carbonetto | 2021-02-24 |
6e2b53a | Peter Carbonetto | 2021-02-10 |
9afb462 | Peter Carbonetto | 2021-02-10 |
f8e1d99 | Peter Carbonetto | 2021-02-10 |
d1d4185 | Peter Carbonetto | 2021-02-10 |
f596d8a | Peter Carbonetto | 2021-02-09 |
d0775d2 | Peter Carbonetto | 2021-02-09 |
ab3eeb8 | Peter Carbonetto | 2021-01-29 |
42ebc62 | Peter Carbonetto | 2021-01-29 |
a4bc59b | Peter Carbonetto | 2021-01-06 |
a0b6c2b | Peter Carbonetto | 2021-01-06 |
0411340 | Peter Carbonetto | 2021-01-06 |
fad8e3d | Peter Carbonetto | 2021-01-05 |
Perform differential expression analysis using the multinomial topic model, after removing the dendritic cells cluster:
rows <- which(samples$cluster != "dendritic")
fit_no_dendritic <- select_loadings(fit,loadings = rows)
diff_count_topics <- diff_count_analysis(fit_no_dendritic,counts[rows,])
# Fitting 21952 x 6 = 131712 univariate Poisson models.
# Computing log-fold change statistics.
# Stabilizing log-fold change estimates using adaptive shrinkage.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE)
at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson
for each individual chunk that is cached. Using either autodep
or dependson
will remove this warning. See the knitr cache options for more details.
These volcano plots summarize the results of the differential expression analysis using the topic model:
p14 <- volcano_plot(diff_count_topics,"k3",genes$symbol,
label_above_lfc = 4,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("topic 3 (B cells)")
p15 <- volcano_plot(diff_count_topics,"k2",genes$symbol,
label_above_quantile = 0.994,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("topic 2 (CD14+ cells)")
p16 <- volcano_plot(diff_count_topics,"k5",genes$symbol,
label_above_lfc = 2,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("topic 5 (CD34+ cells)")
p17 <- volcano_plot(diff_count_topics,"k4",genes$symbol,
label_above_lfc = 4,label_above_quantile = 0.995,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("topic 4 (NK cells)")
p18 <- volcano_plot(diff_count_topics,"k1",genes$symbol,
label_above_quantile = 0.998,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("topic 1 (T cells)")
p19 <- volcano_plot(diff_count_topics,"k6",genes$symbol,
label_above_quantile = 0.998,
subsample_below_quantile = 0.5) +
guides(fill = "none") +
ggtitle("topic 6 (ribosomal proteins)")
plot_grid(p14,p15,p16,p17,p18,p19,nrow = 2,ncol = 3)
Version | Author | Date |
---|---|---|
93ac093 | Peter Carbonetto | 2021-03-01 |
b84788d | Peter Carbonetto | 2021-03-01 |
dac053f | Peter Carbonetto | 2021-02-28 |
5773c6c | Peter Carbonetto | 2021-02-25 |
ced5127 | Peter Carbonetto | 2021-02-25 |
d21aab5 | Peter Carbonetto | 2021-02-24 |
7be2e95 | Peter Carbonetto | 2021-02-24 |
6e2b53a | Peter Carbonetto | 2021-02-10 |
9afb462 | Peter Carbonetto | 2021-02-10 |
f8e1d99 | Peter Carbonetto | 2021-02-10 |
d1d4185 | Peter Carbonetto | 2021-02-10 |
f596d8a | Peter Carbonetto | 2021-02-09 |
d0775d2 | Peter Carbonetto | 2021-02-09 |
The results of the differential expression analysis can also be browsed in interactive volcano plots:
volcano_plotly(diff_count_topics,"k3",
"volcano_plot_purified_pbmc_bcells.html",
genes$symbol,title = "topic 3 (B cells)",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_topics,"k2",
"volcano_plot_purified_pbmc_cd14.html",
genes$symbol,title = "topic 2 (CD14+)",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_topics,"k5",
"volcano_plot_purified_pbmc_cd34.html",
genes$symbol,title = "topic 5 (CD34+)",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_topics,"k4",
"volcano_plot_purified_pbmc_nk.html",
genes$symbol,title = "topic 4 (NK cells)",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_topics,"k1",
"volcano_plot_purified_pbmc_tcells.html",
genes$symbol,title = "topic 1 (T cells)",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_topics,"k6",
"volcano_plot_purified_pbmc_ribosomal_proteins.html",
genes$symbol,title = "topic 6 (ribosomal proteins)",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_clusters,"CD8+",
"volcano_plot_purified_pbmc_cd8.html",
genes$symbol,title = "CD8+ cluster",
subsample_below_quantile = 0.5,
width = 450,height = 500)
volcano_plotly(diff_count_clusters,"dendritic",
"volcano_plot_purified_pbmc_dendritic.html",
genes$symbol,title = "dendritic cells cluster",
subsample_below_quantile = 0.5,
width = 450,height = 500)
The interactive volcano plots may also be viewed by clicking these links: topic 3 (B cells), topic 4 (NK cells), topic 2 (CD14+), topic 5 (CD34+), topics 1 (T cells), topics 6 (T cells), CD8+ cluster and dendritic cells cluster.
The volcano plot for topic 6 suggests an enrichment of ribosomal protein genes. Indeed, there is a very strong correlation between the topic 6 mixture proportion and the fraction of total expression attributed to ribosomal genes:
rpgenes <- c("RPS2","RPS3","RPS3A","RPS4X","RPS6","RPS7","RPS8","RPS9",
"RPS10","RPS11","RPS12","RPS13","RPS14","RPS15","RPS15A",
"RPS16","RPS17","RPS18","RPS19","RPS20","RPS21","RPS23",
"RPS24","RPS25","RPS26","RPS27","RPS27A","RPS28","RPS29",
"RPL3","RPL4","RPL5","RPL6","RPL7A","RPL8","RPL9","RPL10",
"RPL10A","RPL12","RPL13A","RPL14","RPL15","RPL17","RPL18",
"RPL18A","RPL19","RPL21","RPL22","RPL23","RPL23A","RPL24",
"RPL26","RPL27A","RPL30","RPL31","RPL32","RPL34","RPL35",
"RPL36","RPL36A","RPL37","RPL39","RPL41")
rgscatterplot <- function (i, title = NULL) {
j <- which(is.element(genes$symbol,rpgenes))
pdat <- data.frame(x = fit$L[i,6],
y = rowSums(counts[i,j])/rowSums(counts[i,]))
return(ggplot(pdat,aes(x = x,y = y)) +
geom_point() +
geom_smooth(method = "lm",se = FALSE,color = "dodgerblue",
size = 0.5,linetype = "dashed") +
ylim(0,0.6) +
labs(x = "topic 6 proportion",
y = "ribosomal expression",
title = title) +
theme_cowplot(font_size = 10) +
theme(plot.title = element_text(size = 10,face = "plain")))
}
p20 <- rgscatterplot(which(celltype == "CD19+ B"),"B cells")
p21 <- rgscatterplot(which(celltype == "CD34+"),"CD34+ cells")
p22 <- rgscatterplot(which(!(celltype == "CD19+ B" | celltype == "CD34+")),
"all other cells")
plot_grid(p20,p21,p22,nrow = 1,ncol = 3)
The list of ribosomal protein genes comes from Yoshihama et al (2002).
Four out of the 6topics closely correspond to the FACS cell populations: B cells, T cells, NK cells and CD14+ cells. We would expect then that the differential expression in these 4 topics is similar to differential expression in the corresponding FACS populations. Let’s check this.
celltype <- as.character(celltype)
celltype[celltype == "CD8+ Cytotoxic T"] <- "T cell"
celltype <- factor(celltype)
table(celltype)
diff_count_facs <- diff_count_clusters(celltype,counts)
# celltype
# CD14+ Monocyte CD19+ B CD34+ CD56+ NK T cell
# 2612 10085 9232 8385 64341
# Fitting 21952 x 5 = 109760 univariate Poisson models.
# Computing log-fold change statistics.
# Stabilizing log-fold change estimates using adaptive shrinkage.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE)
at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson
for each individual chunk that is cached. Using either autodep
or dependson
will remove this warning. See the knitr cache options for more details.
These scatterplots compare log-fold change estimated using the FACS labeling and using the topic model. Some of the top genes in each topic are highlighted.
p23 <- lfc_scatterplot(diff_count_facs,diff_count_topics,"CD19+ B","k3",
genes$symbol,label_above_lfc = 6,
label_above_quantile = 0.99,
xlab = "B cells FACS subpopulation",ylab = "topic 3")
p24 <- lfc_scatterplot(diff_count_facs,diff_count_topics,"CD14+ Monocyte",
"k2",genes$symbol,label_above_lfc = 6,
label_above_quantile = 0.98,
xlab = "CD14+ FACS subpopulation",ylab = "topic 2")
p25 <- lfc_scatterplot(diff_count_facs,diff_count_topics,"CD56+ NK","k4",
genes$symbol,label_above_lfc = 5,
label_above_quantile = 0.99,
xlab = "NK cells FACS subpopulation",ylab = "topic 4")
p26 <- lfc_scatterplot(diff_count_facs,diff_count_topics,"T cell","k1",
genes$symbol,label_above_lfc = 5,
label_above_quantile = 0.99,
xlab = "T cells FACS subpopulation",
ylab = "topic 1")
plot_grid(p23,p24,p25,p26,nrow = 2,ncol = 2)
Overall, the LFC estimates are strongly correlated. But the differential expression in the topic is much higher for many of the top genes. In particular, the topic model seems to be more adept at picking out cell-type-specific genes—that is, genes that are uniquely expressed in a cell type.
For each topic, we also perform a gene-set enrichment analysis. Here we only consider gene sets with at least 4 genes and no more than 400 genes.
data(gene_sets_human)
i <- which(with(gene_sets_human,
colSums(gene_sets) >= 4 &
colSums(gene_sets) <= 400))
gene_set_info <- gene_sets_human$gene_set_info[i,]
gene_sets <- gene_sets_human$gene_sets[,i]
gsea_res <- perform_gsea(gene_sets,diff_count_topics$Z,nproc = 4)
# Using statistics from 17348 genes for gene set enrichment analysis.
# Converting gene set data for fgsea.
# Computing enrichment statistics for 35084 gene sets and
# 6 collections of gene-level statistics:
# k1, k2, k3, k4, k5, k6
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE)
at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson
for each individual chunk that is cached. Using either autodep
or dependson
will remove this warning. See the knitr cache options for more details.
The results of the gene set enrichment analysis can be explored in these interactive plots.
gsea_plotly(gsea_res,gene_set_info,"k1",file = "gsea_plot_tcells.html",title = "T cells")
gsea_plotly(gsea_res,gene_set_info,"k2",file = "gsea_plot_cd14.html",title = "CD14+ cells")
gsea_plotly(gsea_res,gene_set_info,"k3",file = "gsea_plot_bcells.html",title = "B cells")
gsea_plotly(gsea_res,gene_set_info,"k4",file = "gsea_plot_nk.html",title = "NK cells")
gsea_plotly(gsea_res,gene_set_info,"k5",file = "gsea_plot_cd34.html",title = "CD34+ cells")
gsea_plotly(gsea_res,gene_set_info,"k6",file = "gsea_plot_rp.html",title = "Ribosomal proteins")
The interactive volcano plots may also be viewed by clicking these links: topic 1 (T cells), topic 2 (CD14+ cells), topic 3 (B cells), topic 4 (NK cells), topic 5 (CD34+ cells) and topic 6 (ribosomal proteins).
sessionInfo()
# R version 3.6.2 (2019-12-12)
# Platform: x86_64-apple-darwin15.6.0 (64-bit)
# Running under: macOS Catalina 10.15.7
#
# Matrix products: default
# BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] ggrepel_0.9.0 cowplot_1.0.0 ggplot2_3.3.0 pathways_0.1-20
# [5] fastTopics_0.5-20 Matrix_1.2-18
#
# loaded via a namespace (and not attached):
# [1] httr_1.4.2 tidyr_1.0.0 splines_3.6.2
# [4] jsonlite_1.6 viridisLite_0.3.0 RcppParallel_4.4.2
# [7] shiny_1.4.0 assertthat_0.2.1 mixsqp_0.3-44
# [10] yaml_2.2.0 progress_1.2.2 pillar_1.4.3
# [13] backports_1.1.5 lattice_0.20-38 quantreg_5.54
# [16] glue_1.3.1 quadprog_1.5-8 digest_0.6.23
# [19] promises_1.1.0 colorspace_1.4-1 htmltools_0.4.0
# [22] httpuv_1.5.2 pkgconfig_2.0.3 invgamma_1.1
# [25] SparseM_1.78 xtable_1.8-4 purrr_0.3.3
# [28] scales_1.1.0 whisker_0.4 later_1.0.0
# [31] Rtsne_0.15 BiocParallel_1.18.1 MatrixModels_0.4-1
# [34] git2r_0.26.1 tibble_2.1.3 mgcv_1.8-31
# [37] farver_2.0.1 withr_2.1.2 ashr_2.2-51
# [40] lazyeval_0.2.2 mime_0.8 magrittr_1.5
# [43] crayon_1.3.4 mcmc_0.9-6 evaluate_0.14
# [46] fs_1.3.1 nlme_3.1-142 MASS_7.3-51.4
# [49] truncnorm_1.0-8 tools_3.6.2 data.table_1.12.8
# [52] prettyunits_1.1.1 hms_0.5.2 lifecycle_0.1.0
# [55] stringr_1.4.0 MCMCpack_1.4-5 plotly_4.9.2
# [58] munsell_0.5.0 irlba_2.3.3 compiler_3.6.2
# [61] rlang_0.4.5 grid_3.6.2 htmlwidgets_1.5.1
# [64] crosstalk_1.0.0 labeling_0.3 rmarkdown_2.3
# [67] gtable_0.3.0 R6_2.4.1 gridExtra_2.3
# [70] knitr_1.26 dplyr_0.8.3 fastmap_1.0.1
# [73] zeallot_0.1.0 fastmatch_1.1-0 workflowr_1.6.2.9000
# [76] fgsea_1.15.1 rprojroot_1.3-2 stringi_1.4.3
# [79] parallel_3.6.2 SQUAREM_2017.10-1 Rcpp_1.0.5
# [82] vctrs_0.2.1 tidyselect_0.2.5 xfun_0.11
# [85] coda_0.19-3