Last updated: 2020-09-10

Checks: 7 0

Knit directory: scATACseq-topics/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20200729) 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 39d1966. 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:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/plots_Cusanovich2018.Rmd
    Untracked:  analysis/plots_Lareau2019_bonemarrow.Rmd
    Untracked:  code/plots.R

Unstaged changes:
    Modified:   code/functions_for_assessing_fits.R
    Modified:   scripts/fit_all_models_Cusanovich2018.sh

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/process_data_Lareau2019.Rmd) and HTML (docs/process_data_Lareau2019.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 39d1966 kevinlkx 2020-09-10 wflow_publish(“analysis/process_data_Lareau2019.Rmd”)
html 68ec1d9 kevinlkx 2020-08-24 Build site.
Rmd bfb8ee6 kevinlkx 2020-08-24 wflow_publish(“analysis/process_data_Lareau2019.Rmd”)
html d36ca58 kevinlkx 2020-08-21 Build site.
Rmd e5ae61d kevinlkx 2020-08-21 wflow_publish(“analysis/process_data_Lareau2019.Rmd”)

Lareau 2019 dataset

Reference: Lareau, C., Duarte, F., Chew, J., Kartha, V., Burkett, Z., Kohlway, A., Pokholok, D., Aryee, M., Steemers, F., Lebofsky, R., Buenrostro, J. (2019). Droplet-based combinatorial indexing for massive-scale single-cell chromatin accessibility Nature Biotechnology 518(1), 1 15. https://dx.doi.org/10.1038/s41587-019-0147-6

Mouse brain data GSE123576

Downloaded GSE123576_mousebrain_countsData_revision.csv.gz from the Gene Expression Omnibus (GEO) website, accession GSE123576. RCC directory: /project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/mouse_brain/

Load and binarize ATAC-seq counts

library(Matrix)
library(readr)
out <- read_delim("/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/mouse_brain/raw_data/GSE123576_mousebrain_countsData_revision.csv.gz",delim = " ")
class(out) <- "data.frame"

# binarize counts
out$binarized_count <- as.integer(out$count > 0)

metadata

  • samples:
samples <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/mouse_brain/raw_data/GSE123576_mousebrain_cellData_revision.tsv.gz", header = TRUE, stringsAsFactors = FALSE, sep = "\t")

dim(samples)
[1] 46653     3
cat(sprintf("Number of samples: %d\n",nrow(samples)))
Number of samples: 46653
print(samples[1:3,])
                        DropBarcode  FRIP clusters
1 N701_Exp119_sample1_S1_BC0003_N01 0.505        9
2 N701_Exp119_sample1_S1_BC0004_N01 0.477       13
3 N701_Exp119_sample1_S1_BC0005_N01 0.496       13
  • peaks:
peaks <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/mouse_brain/raw_data/GSE123576_mousebrain_peaks_revision.bed.gz", header = FALSE, stringsAsFactors = FALSE, sep = "\t")
colnames(peaks) <- c("chr", "start", "end")
peaks$name <- paste0(peaks$chr, ":", peaks$start, "-", peaks$end)

cat(sprintf("Number of peaks: %d\n",nrow(peaks)))
Number of peaks: 454047
print(peaks[1:3,])
   chr   start     end                 name
1 chr1 3042897 3043397 chr1:3042897-3043397
2 chr1 3094911 3095411 chr1:3094911-3095411
3 chr1 3113443 3113943 chr1:3113443-3113943
counts <- sparseMatrix(i = out$cell_idx, j = out$peak_idx, x = out$binarized_count, 
                       dims = c(max(out$cell_idx), max(out$peak_idx)),
                       dimnames = list(sample = samples$DropBarcode,
                                       peak = peaks$name))

Remove peaks not exist in any of the cells

j <- which(colSums(counts > 0) >= 1)
peaks <- peaks[j,]
counts <- counts[,j]
data.dir <- "/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/mouse_brain/processed_data/"
dir.create(data.dir, showWarnings = FALSE, recursive = TRUE)

saveRDS(counts, file.path(data.dir, "counts_Lareau_2019_mousebrain.rds"))

save(list = c("samples", "peaks", "counts"), file = file.path(data.dir, "Lareau_2019_mousebrain.RData"))
data.dir <- "/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/mouse_brain/processed_data/"
load(file.path(data.dir, "Lareau_2019_mousebrain.RData"))
cat(sprintf("Loaded %d x %d counts matrix.\n",nrow(counts),ncol(counts)))
Loaded 46653 x 451300 counts matrix.
cat(sprintf("Number of samples (cells): %d\n",nrow(counts)))
Number of samples (cells): 46653
cat(sprintf("Number of peaks: %d\n",ncol(counts)))
Number of peaks: 451300
cat(sprintf("Proportion of counts that are non-zero: %0.1f%%.\n",
            100*mean(counts > 0)))
Proportion of counts that are non-zero: 2.1%.

Human bone marrow data GSE123580

Downloaded GSE123580_bonemarrow_countsData.csv.gz from the Gene Expression Omnibus (GEO) website, accession GSE123580. RCC directory: /project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/bone_marrow/

Load and binarize ATAC-seq counts

library(Matrix)
library(readr)

out <- read_delim("/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/bone_marrow/raw_data/GSE123580_bonemarrow_countsData.csv.gz",delim = " ")
class(out) <- "data.frame"

# binarize counts
out$binarized_count <- as.integer(out$count > 0)

metadata

  • samples:
samples <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/bone_marrow/raw_data/GSE123580_bonemarrow_cellData.tsv.gz", header = TRUE, stringsAsFactors = FALSE, sep = "\t")

dim(samples)
[1] 136463      4
cat(sprintf("Number of samples: %d\n",nrow(samples)))
Number of samples: 136463
print(samples[1:3,])
                                DropBarcode  FRIP Cluster Condition
1 Exp100-Sample9.all_Tn5-AAAGAA_BC00404_N03 0.755    HSPC   Resting
2 Exp100-Sample9.all_Tn5-AAAGAA_BC00461_N02 0.773    HSPC   Resting
3 Exp100-Sample9.all_Tn5-AAAGAA_BC00600_N02 0.763    HSPC   Resting
  • peaks:
peaks <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/bone_marrow/raw_data/GSE123580_bonemarrow_peaks.bed.gz", header = FALSE, stringsAsFactors = FALSE, sep = "\t")
colnames(peaks) <- c("chr", "start", "end")
peaks$name <- paste0(peaks$chr, ":", peaks$start, "-", peaks$end)

cat(sprintf("Number of peaks: %d\n",nrow(peaks)))
Number of peaks: 156311
print(peaks[1:3,])
   chr start   end             name
1 chr1  9942 10442  chr1:9942-10442
2 chr1 11036 11536 chr1:11036-11536
3 chr1 12478 12978 chr1:12478-12978
counts <- sparseMatrix(i = out$cell_idx, j = out$peak_idx, x = out$binarized_count, 
                       dims = c(max(out$cell_idx), max(out$peak_idx)),
                       dimnames = list(sample = samples$DropBarcode,
                                       peak = peaks$name))

Remove peaks not exist in any of the cells

j <- which(colSums(counts > 0) >= 1)
peaks <- peaks[j,]
counts <- counts[,j]
data.dir <- "/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/bone_marrow/processed_data/"
dir.create(data.dir, showWarnings = FALSE, recursive = TRUE)

saveRDS(counts, file.path(data.dir, "counts_Lareau_2019_bonemarrow.rds"))

save(list = c("samples", "peaks", "counts"), file = file.path(data.dir, "Lareau_2019_bonemarrow.RData"))
data.dir <- "/project2/mstephens/kevinluo/scATACseq-topics/data/Lareau_2019/bone_marrow/processed_data/"
load(file.path(data.dir, "Lareau_2019_bonemarrow.RData"))

cat(sprintf("Loaded %d x %d counts matrix.\n",nrow(counts),ncol(counts)))
Loaded 136463 x 146860 counts matrix.
cat(sprintf("Number of samples (cells): %d\n",nrow(counts)))
Number of samples (cells): 136463
cat(sprintf("Number of peaks: %d\n",ncol(counts)))
Number of peaks: 146860
cat(sprintf("Proportion of counts that are non-zero: %0.1f%%.\n",
            100*mean(counts > 0)))
Proportion of counts that are non-zero: 0.7%.

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] readr_1.3.1     Matrix_1.2-15   workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6    knitr_1.28      whisker_0.4     magrittr_1.5   
 [5] hms_0.4.2       lattice_0.20-38 R6_2.4.1        rlang_0.4.6    
 [9] stringr_1.4.0   tools_3.5.1     grid_3.5.1      xfun_0.14      
[13] git2r_0.27.1    ellipsis_0.3.1  htmltools_0.4.0 yaml_2.2.0     
[17] digest_0.6.25   rprojroot_1.3-2 lifecycle_0.2.0 tibble_3.0.1   
[21] crayon_1.3.4    later_1.0.0     vctrs_0.3.0     promises_1.1.0 
[25] fs_1.3.1        glue_1.4.1      evaluate_0.14   rmarkdown_2.1  
[29] stringi_1.4.6   pillar_1.4.4    compiler_3.5.1  backports_1.1.7
[33] httpuv_1.5.3.1  pkgconfig_2.0.3