Last updated: 2025-05-19
Checks: 7 0
Knit directory: lps/analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
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 6425fe5. 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/cytokine_combo_2ndrun/counts_cytocombo.csv.gz
Ignored: data/raw_read_counts.csv.gz
Ignored: output/fit-lps-k=16.RData
Ignored: output/fits-lps-bytissue.RData
Ignored: output/gsea-lps-k=16-CP+GO-only.RData
Ignored: output/gsea-lps-k=16.RData
Untracked files:
Untracked: analysis/structure_plot_k16.pdf
Untracked: analysis/structure_plot_k16.png
Untracked: analysis/volcano_plot_k1+k5.html
Untracked: analysis/volcano_plot_k1.html
Untracked: analysis/volcano_plot_k10.html
Untracked: analysis/volcano_plot_k11.html
Untracked: analysis/volcano_plot_k12.html
Untracked: analysis/volcano_plot_k13.html
Untracked: analysis/volcano_plot_k14.html
Untracked: analysis/volcano_plot_k15.html
Untracked: analysis/volcano_plot_k16.html
Untracked: analysis/volcano_plot_k2+k13.html
Untracked: analysis/volcano_plot_k2.html
Untracked: analysis/volcano_plot_k3.html
Untracked: analysis/volcano_plot_k4.html
Untracked: analysis/volcano_plot_k5.html
Untracked: analysis/volcano_plot_k6+k14.html
Untracked: analysis/volcano_plot_k6.html
Untracked: analysis/volcano_plot_k7.html
Untracked: analysis/volcano_plot_k8.html
Untracked: analysis/volcano_plot_k9.html
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/examine_topic_model_k16.Rmd
) and HTML
(docs/examine_topic_model_k16.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 | 6425fe5 | Peter Carbonetto | 2025-05-19 | wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE, |
html | 9512227 | Peter Carbonetto | 2025-05-19 | Ran wflow_publish("examine_topic_model_k16.Rmd") |
Rmd | 81bea77 | Peter Carbonetto | 2025-05-19 | wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE, |
Rmd | 6419ec8 | Peter Carbonetto | 2022-06-14 | Created PDF containing single-topic structure plots. |
Rmd | a584893 | Peter Carbonetto | 2022-06-14 | Removed a file that is not needed. |
Rmd | 6b2ab80 | Peter Carbonetto | 2022-06-13 | Added metadata csv file; implemented script check_outlier.R. |
Rmd | 0428e4c | Peter Carbonetto | 2022-06-02 | Added some code to create a PDF of the main structure plot in the examine_topic_model_k16 analysis. |
Rmd | abc3e45 | Peter Carbonetto | 2022-05-19 | A few small fixes to the examine_topic_model_k16 analysis. |
html | abc3e45 | Peter Carbonetto | 2022-05-19 | A few small fixes to the examine_topic_model_k16 analysis. |
html | 2e949c0 | Peter Carbonetto | 2022-05-10 | Added links to volcano plots. |
Rmd | ba08036 | Peter Carbonetto | 2022-05-10 | workflowr::wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE) |
html | 29047dc | Peter Carbonetto | 2022-05-10 | Build site. |
Rmd | 23fcc2b | Peter Carbonetto | 2022-05-10 | workflowr::wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE) |
html | 6e95930 | Peter Carbonetto | 2022-05-10 | Fixed interactive volcano_plots. |
Rmd | a136de3 | Peter Carbonetto | 2022-05-10 | workflowr::wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE) |
html | bef8deb | Peter Carbonetto | 2022-05-10 | Added volcano plots. |
Rmd | 567870b | Peter Carbonetto | 2022-05-10 | workflowr::wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE) |
html | 6dabc4d | Peter Carbonetto | 2022-05-05 | Added another structure plot to examine_topic_model_k16 analysis. |
Rmd | 1899304 | Peter Carbonetto | 2022-05-05 | workflowr::wflow_publish("examine_topic_model_k16.Rmd") |
html | b5a1eae | Peter Carbonetto | 2022-05-04 | Build site. |
Rmd | a628c54 | Peter Carbonetto | 2022-05-04 | workflowr::wflow_publish("examine_topic_model_k16.Rmd", verbose = TRUE) |
Rmd | e01a993 | Peter Carbonetto | 2022-05-04 | First build of overview page. |
Load the packages used in the analysis.
library(data.table)
library(fastTopics)
library(ggplot2)
library(cowplot)
source("../code/lps_data.R")
Initialize the sequence of pseudorandom numbers.
set.seed(1)
Load the count data.
dat <- read_lps_data("../data/raw_read_counts.csv.gz")
samples <- dat$samples
counts <- dat$counts
table(samples$tissue)
table(samples$timepoint)
table(samples$mouse)
#
# BM BR CO HE iLN KI LI LU PBMC SI SK SP TH
# 28 28 28 28 28 28 28 28 28 28 28 28 28
#
# d0 d0.25 d0.5 d1 d2 d3 d5
# 52 52 52 52 52 52 52
#
# 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 27 28 3 4 5 6 7
# 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13
# 8 9
# 13 13
Remove genes with very low (or no) expression.
j <- which(colSums(counts) > 20)
counts <- counts[,j]
Load the results of the topic modeling analysis.
load("../output/fit-lps-k=16.RData")
Plot the improvement in the solution over time.
p1 <- plot_progress(fit,x = "timing",y = "loglik",colors = "black",
add.point.every = 10,e = 1e-4) +
guides(color = "none",fill = "none",shape = "none",
linetype = "none",size = "none")
p2 <- plot_progress(fit,x = "timing",y = "res",colors = "black",
add.point.every = 10,e = 1e-4) +
guides(color = "none",fill = "none",shape = "none",
linetype = "none",size = "none")
plot_grid(p1,p2)
Visualize the structure identified in each of the tissues using a Structure plot, in which the samples in each tissue are ordered by time in which the sample was taken:
set.seed(1)
rows <- order(samples$timepoint)
topic_colors <- c("darkblue","dodgerblue","darkorange","forestgreen",
"limegreen","tomato","darkred","olivedrab","magenta",
"darkmagenta","sienna","royalblue","lightskyblue",
"gold","red","cyan")
p <- structure_plot(fit,grouping = samples$tissue,gap = 5,
colors = topic_colors,
topics = c(15,3,4,5,6,7,8,9,10,11,12,13,2,14,1,16),
loadings_order = rows) +
theme(legend.key.height = unit(0.15,"cm"),
legend.text = element_text(size = 7))
print(p)
See here for more Structure plots.
There is a single topic (topic 9, blue in the plot below) that is capturing changes in expression over time across many tissues. Two other topics (topics 1 and 6) show similar patterns, except these patterns are specific to two tissues (PBMC and LI).
set.seed(1)
topic_colors <- c("gold","darkorange","dodgerblue","white")
fit2 <- poisson2multinom(fit)
fit2 <- merge_topics(fit2,paste0("k",setdiff(1:16,c(1,6,9))))
colnames(fit2$L) <- c("k1","k6","k9","other")
p <- structure_plot(fit2,grouping = samples$tissue,gap = 5,
colors = topic_colors,topics = c(4,1:3),
loadings_order = rows)
print(p)
These volcano plots summarize the results of the DE analysis for topics capturing different tissues (and topic 9, which is capturing changes in expression at different time points):
topics <- colnames(de_merged$z)
p <- vector("list",13)
names(p) <- topics
for (k in topics) {
p[[k]] <- volcano_plot(de_merged,k = k,ymax = 500) +
guides(color = "none")
volcano_plotly(de_merged,k = k,ymax = 500,
file = paste("volcano_plot_",k,".html",sep = ""))
}
do.call("plot_grid",c(p,list(ncol = 3,nrow = 5)))
These volcano plots summarize the results of the DE analysis for topics capturing expression patterns within tissues:
topics <- c("k1","k2","k5","k6","k13","k14")
p <- vector("list",6)
names(p) <- topics
for (k in topics) {
p[[k]] <- volcano_plot(de,k = k,ymax = 300) +
guides(color = "none")
volcano_plotly(de,k = k,ymax = 300,
file = paste("volcano_plot_",k,".html",sep = ""))
}
do.call("plot_grid",c(p,list(ncol = 3,nrow = 2)))
These results may also be browsed interactively: k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14, k15, k16, k1+k5, k2+k13, k6+k14.
sessionInfo()
# R version 4.3.3 (2024-02-29)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS 15.4.1
#
# Matrix products: default
# BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
#
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#
# time zone: America/Chicago
# tzcode source: internal
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] cowplot_1.1.3 ggplot2_3.5.0 fastTopics_0.7-24 data.table_1.15.2
#
# loaded via a namespace (and not attached):
# [1] gtable_0.3.4 xfun_0.42 bslib_0.6.1
# [4] htmlwidgets_1.6.4 ggrepel_0.9.5 lattice_0.22-5
# [7] crosstalk_1.2.1 quadprog_1.5-8 vctrs_0.6.5
# [10] tools_4.3.3 generics_0.1.3 parallel_4.3.3
# [13] tibble_3.2.1 fansi_1.0.6 highr_0.10
# [16] R.oo_1.26.0 pkgconfig_2.0.3 Matrix_1.6-5
# [19] SQUAREM_2021.1 RcppParallel_5.1.7 lifecycle_1.0.4
# [22] truncnorm_1.0-9 farver_2.1.1 compiler_4.3.3
# [25] stringr_1.5.1 git2r_0.33.0 textshaping_0.3.7
# [28] progress_1.2.3 munsell_0.5.0 RhpcBLASctl_0.23-42
# [31] httpuv_1.6.14 htmltools_0.5.8.1 sass_0.4.9
# [34] yaml_2.3.8 lazyeval_0.2.2 plotly_4.10.4
# [37] crayon_1.5.2 later_1.3.2 pillar_1.9.0
# [40] jquerylib_0.1.4 whisker_0.4.1 tidyr_1.3.1
# [43] R.utils_2.12.3 uwot_0.2.3 cachem_1.0.8
# [46] gtools_3.9.5 tidyselect_1.2.1 digest_0.6.34
# [49] Rtsne_0.17 stringi_1.8.3 reshape2_1.4.4
# [52] dplyr_1.1.4 purrr_1.0.2 ashr_2.2-66
# [55] labeling_0.4.3 rprojroot_2.0.4 fastmap_1.1.1
# [58] grid_4.3.3 colorspace_2.1-0 cli_3.6.4
# [61] invgamma_1.1 magrittr_2.0.3 utf8_1.2.4
# [64] withr_3.0.2 prettyunits_1.2.0 scales_1.3.0
# [67] promises_1.2.1 rmarkdown_2.26 httr_1.4.7
# [70] workflowr_1.7.1 ragg_1.2.7 R.methodsS3_1.8.2
# [73] hms_1.1.3 pbapply_1.7-2 evaluate_1.0.3
# [76] knitr_1.45 irlba_2.3.5.1 viridisLite_0.4.2
# [79] rlang_1.1.5 Rcpp_1.0.12 mixsqp_0.3-54
# [82] glue_1.8.0 jsonlite_1.8.8 plyr_1.8.9
# [85] R6_2.5.1 systemfonts_1.0.6 fs_1.6.5