Last updated: 2024-10-30
Checks: 7 0
Knit directory:
single-cell-jamboree/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 6750e29. 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:
Untracked files:
Untracked: data/Immune_ALL_human.h5ad
Untracked: data/human_pancreas_norm_complexBatch.h5ad
Unstaged changes:
Modified: _workflowr.yml
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/pancreas.Rmd
) and HTML
(docs/pancreas.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 | a1d7a17 | Peter Carbonetto | 2024-10-30 | Added some background on the pancreas data set. |
Rmd | 3fa28da | Peter Carbonetto | 2024-10-30 | Small edit to pancreas.Rmd. |
Rmd | 370a336 | Peter Carbonetto | 2024-10-30 | Still working on pancreas.Rmd. |
Rmd | fbe0b62 | Peter Carbonetto | 2024-10-30 | Made a few improvements to the pancreas analysis. |
Rmd | c090d1d | Peter Carbonetto | 2024-10-30 | Working on initial examination of pancreas data. |
“Pancreas” data set featured in in the Luecken et al 2022 benchmarking paper. Used in several previous papers benchmark data integration methods (otherwise known as “batch correction” or “harmonization” methods) [the Supplementary Note gives references; e.g., the MNN paper]. See Supplementary Fig. 13, Supplementary Note 3 andSupplementary Data 7 for more info on this data set.
First, I downloaded the file
human_pancreas_norm_complexBatch.h5ad
from figshare
and copied it to the “data” subdirectory of this git repository.
Load the packages needed for this analysis.
library(Matrix)
library(hdf5r)
library(uwot)
library(ggplot2)
library(cowplot)
Load the counts and convert to a sparse matrix.
dat <- H5File$new("../data/human_pancreas_norm_complexBatch.h5ad",mode = "r")
counts <- dat[["layers"]][["counts"]][,]
counts <- as(counts,"CsparseMatrix")
counts <- t(counts)
sample_info <- data.frame(id = dat[["obs"]][["_index"]][],
tech = dat[["obs"]][["tech"]][],
celltype = dat[["obs"]][["celltype"]][],
size_factor = dat[["obs"]][["size_factors"]][],
stringsAsFactors = FALSE)
sample_info <- transform(sample_info,
tech = factor(tech),
celltype = factor(celltype))
levels(sample_info$tech) <- dat[["obs"]][["__categories"]][["tech"]][]
levels(sample_info$celltype) <- dat[["obs"]][["__categories"]][["celltype"]][]
genes <- dat[["var"]][["_index"]][]
rownames(counts) <- sample_info$id
colnames(counts) <- genes
nrow(counts)
ncol(counts)
mean(counts > 0)
# [1] 16382
# [1] 19093
# [1] 0.1779012
Notes:
Some entries are UMI counts (“UMI-count-like”), whereas others are not.
16,382 cells.
About 18% nonzeros.
13 cell types. Some are very rare.
9 “batches”
What to do about the very large counts? I think it is okay.
normalize_rows <- function (A)
A / rowSums(A)
X <- normalize_rows(counts)
TO DO: Save the data in an .Rdata file for more convenient analysis with the matrix factorization methods.
sessionInfo()
# R version 4.3.3 (2024-02-29)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS Sonoma 14.6.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 uwot_0.1.16 hdf5r_1.3.11 Matrix_1.6-5
#
# loaded via a namespace (and not attached):
# [1] bit_4.0.5 gtable_0.3.4 jsonlite_1.8.8 dplyr_1.1.4
# [5] compiler_4.3.3 promises_1.2.1 tidyselect_1.2.1 Rcpp_1.0.12
# [9] stringr_1.5.1 git2r_0.33.0 later_1.3.2 jquerylib_0.1.4
# [13] scales_1.3.0 yaml_2.3.8 fastmap_1.1.1 lattice_0.22-5
# [17] R6_2.5.1 generics_0.1.3 workflowr_1.7.1 knitr_1.45
# [21] tibble_3.2.1 munsell_0.5.0 rprojroot_2.0.4 bslib_0.6.1
# [25] pillar_1.9.0 rlang_1.1.3 utf8_1.2.4 cachem_1.0.8
# [29] stringi_1.8.3 httpuv_1.6.14 xfun_0.42 fs_1.6.3
# [33] sass_0.4.8 bit64_4.0.5 cli_3.6.2 withr_3.0.0
# [37] magrittr_2.0.3 digest_0.6.34 grid_4.3.3 lifecycle_1.0.4
# [41] vctrs_0.6.5 evaluate_0.23 glue_1.7.0 whisker_0.4.1
# [45] colorspace_2.1-0 fansi_1.0.6 rmarkdown_2.26 tools_4.3.3
# [49] pkgconfig_2.0.3 htmltools_0.5.7