Last updated: 2021-01-29

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 c1e87ec. 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/process_data_Buenrostro2018_Chen2019.Rmd
    Untracked:  output/clustering-Cusanovich2018.rds
    Untracked:  output/plotly/
    Untracked:  scripts/fit_all_models_Buenrostro_2018_chromVar_scPeaks_filtered.sbatch

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_Cusanovich2018.Rmd) and HTML (docs/process_data_Cusanovich2018.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 c1e87ec kevinlkx 2021-01-29 save data by tissues separately
html 0440e35 kevinlkx 2020-09-10 Build site.
Rmd 7b8b36f kevinlkx 2020-09-10 wflow_publish("analysis/process_data_Cusanovich2018.Rmd")
html edbd049 kevinlkx 2020-08-24 Build site.
Rmd b836761 kevinlkx 2020-08-24 wflow_publish("analysis/process_data_Cusanovich2018.Rmd")
html ceef630 kevinlkx 2020-08-21 Build site.
Rmd d0bc60c kevinlkx 2020-08-21 wflow_publish("analysis/process_data_Cusanovich2018.Rmd")
Rmd 0289508 kevinlkx 2020-08-21 wflow_rename("analysis/scATACseq_analysis_Cusanovich2018.Rmd",
html 0289508 kevinlkx 2020-08-21 wflow_rename("analysis/scATACseq_analysis_Cusanovich2018.Rmd",

About Cusanovich 2018 dataset

Reference: Cusanovich, D., Hill, A., Aghamirzaie, D., Daza, R., Pliner, H., Berletch, J., Filippova, G., Huang, X., Christiansen, L., DeWitt, W., Lee, C., Regalado, S., Read, D., Steemers, F., Disteche, C., Trapnell, C., Shendure, J. (2018). A Single-Cell Atlas of In Vivo Mammalian Chromatin Accessibility Cell 174(5), 1 35. https://dx.doi.org/10.1016/j.cell.2018.06.052

Data were downloaded from the website: https://atlas.gs.washington.edu/mouse-atac/data/. They also provided detail descriptions about these datasets.

RCC directory: /project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/

The authors included nice tutorials on how to get started with analysis of sci-ATAC-seq data: http://atlas.gs.washington.edu/mouse-atac/docs/

R/python scripts referenced in this tutorial are available on: https://github.com/shendurelab/mouse-atac and downloaded to /project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/code_from_authors/mouse-atac on RCC.

Many of the initial steps of processing raw sci-ATAC-seq libraries used for this study are similar to their previous work of sci-ATAC-seq on Drosophila melanogaster embryos at 3 different stages of development. "Cusanovich, D., Reddington, J., Garfield, D. et al. The cis-regulatory dynamics of embryonic development at single-cell resolution. Nature 555, 538–542 (2018). https://doi.org/10.1038/nature25981". Code and documentation on processing sequencing data can be found on the Fly ATAC Github. Documentation on various downstream steps can be found in the Fly ATAC documentation.

Matrix files

  • Binarized peak by cell matrix: atac_matrix.binary.qc_filtered.rds (only QC filtered cells are included).

  • The subset of peaks used as input to TFIDF: atac_matrix.tfidf.qc_filtered.peaks.txt.

  • TFIDF normalized peak by cell matrix: atac_matrix.tfidf.qc_filtered.rds. This dataset has rare peaks filtered out and is then normalized with TFIDF to allow for input to PCA/TSNE (only QC filtered cells are included).

Metadata

  • cell_metadata.txt: Metadata for cells in TSV format, including several features such as TSNE coordinates, cluster assignments, and cell type assignments. Columns in this data:
  • cell: cell barcode (combined and corrected)
  • tissue: the tissue that this cell originated from
  • tissue_replicate: same as tissue, but each replicate has a unique id
  • cluster: cluster assignment in initial t-SNE
  • subset_cluster: cluster assignment in iterative t-SNE space
  • tsne_1: t-SNE1 coordinate in initial t-SNE
  • tsne_2: t-SNE2 coordinate in initial t-SNE
  • subset_tsne1: t-SNE1 coordinate in iterative t-SNE
  • subset_tsne2: t-SNE2 coordinate in iterative t-SNE
  • id: combined ID for major + iterative cluster assignment
  • cell_label: assigned cell type
cell_metadata <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/metadata/cell_metadata.txt", header = TRUE, stringsAsFactors = TRUE, sep = "\t")

dim(cell_metadata)
[1] 81173    11
cell_metadata[1:3,]
                                  cell     tissue tissue.replicate cluster
1 AGCGATAGAACGAATTCGCCTCCGACGGCAGGACGT       Lung      Lung2_62216      10
2 AGCGATAGAACGAATTCGTTGGTAGTCGATAGAGGC     Spleen     Spleen_62016      10
3 AGCGATAGAACGCGCAGAAAGCTAGGTTAGGCGAAG BoneMarrow BoneMarrow_62016      10
  subset_cluster   tsne_1   tsne_2 subset_tsne1 subset_tsne2
1              1 16.25804 17.05674    -14.44873    -3.100071
2              1 15.28149 16.10859    -15.23808     1.123518
3              1 17.03914 14.69750    -16.88165     5.244815
                     id                cell_label
1 clusters_10.cluster_1 Hematopoietic progenitors
2 clusters_10.cluster_1 Hematopoietic progenitors
3 clusters_10.cluster_1 Hematopoietic progenitors
  • cell_metadata.tissue_freq_filtered.txt: Same as cell_metadata.txt, but removes cells in each tissue belonging to a cell_label that accounts for less than 0.5% of the cells in that tissue. These very low frequency labels are often not cell types expected their respective tissues and could be due to slight imperfections in clustering, for example. Provided matrices would need to be subsetted to match this set of cells if using this metadata.
cell_metadata <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/metadata/cell_metadata.tissue_freq_filtered.txt", header = TRUE, stringsAsFactors = TRUE, sep = "\t")

dim(cell_metadata)
[1] 80254    11
cell_metadata[1:3,]
                                  cell     tissue tissue.replicate cluster
1 AGCGATAGAACGAATTCGCCTCCGACGGCAGGACGT       Lung      Lung2_62216      10
2 AGCGATAGAACGAATTCGTTGGTAGTCGATAGAGGC     Spleen     Spleen_62016      10
3 AGCGATAGAACGCGCAGAAAGCTAGGTTAGGCGAAG BoneMarrow BoneMarrow_62016      10
  subset_cluster   tsne_1   tsne_2 subset_tsne1 subset_tsne2
1              1 16.25804 17.05674    -14.44873    -3.100071
2              1 15.28149 16.10859    -15.23808     1.123518
3              1 17.03914 14.69750    -16.88165     5.244815
                     id                cell_label
1 clusters_10.cluster_1 Hematopoietic progenitors
2 clusters_10.cluster_1 Hematopoietic progenitors
3 clusters_10.cluster_1 Hematopoietic progenitors
  • cell_type_assignments.xlsx: Excel document with three tabs expected cell types, cell type markers, and Cell type assignments that contain a pairs of tissues and expected cell types, a list of positive markers for each cell type, and the table of cell type assignments with extra details about assignment criteria when applicable, respectively. This is meant to document justification for cell type assignments provided in cell_metadata.txt above.

  • peak_promoter_intersections.txt: Metadata for peaks-intersected TSS pairs in TSV format.

peak_promoter_intersections <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/metadata/peak_promoter_intersections.txt", header = TRUE, stringsAsFactors = TRUE, sep = "\t")

dim(peak_promoter_intersections)
[1] 62545     9
peak_promoter_intersections[1:3,]
               peak_id peak_chr peak_start peak_end           ensembl_id
1 chr1_3206330_3206546     chr1    3206330  3206546 ENSMUSG00000051951.5
2 chr1_3456171_3457239     chr1    3456171  3457239 ENSMUSG00000089699.1
3 chr1_3660494_3662750     chr1    3660494  3662750 ENSMUSG00000051951.5
  gene_short_name ensembl_transcript_id              biotype strand
1            Xkr4  ENSMUST00000162897.1 processed_transcript      -
2          Gm1992  ENSMUST00000161581.1            antisense      +
3            Xkr4  ENSMUST00000070533.4       protein_coding      -

Prepare data for topic modeling

library(Matrix)
library(tools)
  • Binarized peak by cell matrix: atac_matrix.binary.qc_filtered.rds (only QC filtered cells are included).
## atac_matrix.binary.qc_filtered.rds: binarized peak by cell matrix in RDS format.
binarized_matrix <- readRDS("/project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/ATAC_matrices/atac_matrix.binary.qc_filtered.rds")
dim(binarized_matrix)
counts <- t(binarized_matrix)

## all peaks exist in all of the cells
length(which(colSums(counts > 0) == 0))
length(which(rowSums(counts > 0) == 0))

cat(sprintf("Number of samples (cells): %d\n",nrow(counts)))
cat(sprintf("Number of peaks: %d\n",ncol(counts)))
cat(sprintf("Proportion of counts that are non-zero: %0.1f%%.\n",
            100*mean(counts > 0)))
  • cell_metadata.txt: Metadata for cells in TSV format, including several features such as TSNE coordinates, cluster assignments, and cell type assignments.
samples <- read.table("/project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/metadata/cell_metadata.txt", header = TRUE, stringsAsFactors = FALSE, sep = "\t")

dim(samples)
[1] 81173    11
cat(sprintf("Number of samples: %d\n",nrow(samples)))
Number of samples: 81173
print(samples[1:3,])
                                  cell     tissue tissue.replicate cluster
1 AGCGATAGAACGAATTCGCCTCCGACGGCAGGACGT       Lung      Lung2_62216      10
2 AGCGATAGAACGAATTCGTTGGTAGTCGATAGAGGC     Spleen     Spleen_62016      10
3 AGCGATAGAACGCGCAGAAAGCTAGGTTAGGCGAAG BoneMarrow BoneMarrow_62016      10
  subset_cluster   tsne_1   tsne_2 subset_tsne1 subset_tsne2
1              1 16.25804 17.05674    -14.44873    -3.100071
2              1 15.28149 16.10859    -15.23808     1.123518
3              1 17.03914 14.69750    -16.88165     5.244815
                     id                cell_label
1 clusters_10.cluster_1 Hematopoietic progenitors
2 clusters_10.cluster_1 Hematopoietic progenitors
3 clusters_10.cluster_1 Hematopoietic progenitors

This study measured single cell chromatin accessibility in 13 different tissues in mice:

table(samples$tissue)

      BoneMarrow       Cerebellum            Heart           Kidney 
            8403             2278             7650             6431 
  LargeIntestine            Liver             Lung PreFrontalCortex 
            7086             6167             9996             5959 
  SmallIntestine           Spleen           Testes           Thymus 
            4077             4020             2723             7617 
      WholeBrain 
            8766 

Cells were labeled into the cell types:

table(samples$cell_label)

         Activated B cells       Alveolar macrophages 
                       500                        559 
                Astrocytes                    B cells 
                      1666                       5772 
            Cardiomyocytes   Cerebellar granule cells 
                      4076                       4099 
           Collecting duct                 Collisions 
                       164                       1218 
                    DCT/CD            Dendritic cells 
                       506                        958 
  Distal convoluted tubule Endothelial I (glomerular) 
                       319                        552 
       Endothelial I cells       Endothelial II cells 
                       952                       3019 
               Enterocytes              Erythroblasts 
                      4783                       2811 
           Ex. neurons CPN          Ex. neurons CThPN 
                      1832                       1540 
          Ex. neurons SCPN  Hematopoietic progenitors 
                      1466                       3425 
               Hepatocytes           Immature B cells 
                      5664                        571 
        Inhibitory neurons              Loop of henle 
                      1828                        815 
               Macrophages                  Microglia 
                       711                        422 
                 Monocytes                   NK cells 
                      1173                        321 
          Oligodendrocytes                  Podocytes 
                      1558                        498 
           Proximal tubule         Proximal tubule S3 
                      2570                        594 
            Purkinje cells         Regulatory T cells 
                       320                        507 
         SOM+ Interneurons                      Sperm 
                       553                       2089 
                   T cells         Type I pneumocytes 
                      8954                       1622 
       Type II pneumocytes                    Unknown 
                       157                      10029 
data.dir <- "/project2/mstephens/kevinluo/scATACseq-topics/data/Cusanovich_2018/processed_data/"
dir.create(data.dir, showWarnings = FALSE, recursive = TRUE)

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

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

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

Save data separately by tissues

counts_all <- counts
samples_all <- samples
rm(counts)
rm(samples)

tissues <- unique(samples_all$tissue)
for ( tissue in tissues ) {
  rows <- which(samples_all$tissue == tissue)
  cat(sprintf("%d cells in %s.\n",length(rows),tissue))
  counts <- counts_all[rows,]
  samples <- samples_all[rows,]
  save(list = c("samples","counts"), file = paste0(data.dir, "/", "Cusanovich_2018_", tissue,".RData"))
  resaveRdaFiles(paste0(data.dir, "/", "Cusanovich_2018_", tissue,".RData"))
}

Save data for heart, kidney and lung tissues.

rows <- which(samples_all$tissue %in% c("Heart", "Kidney", "Lung"))
cat(sprintf("%d cells in %s.\n",length(rows),tissue))
cat(sprintf("%d cells in heart, kidney and lung.\n",length(rows)))
counts <- counts_all[rows,]
samples <- samples_all[rows,]
save(list = c("samples","counts"), file = paste0(data.dir, "/", "Cusanovich_2018_HeartKidneyLung.RData"))
resaveRdaFiles(paste0(data.dir, "/", "Cusanovich_2018_HeartKidneyLung.RData")))

Save data for endothelial cells.

rows <- grep("Endothelial",samples_all$cell_label)
cat(sprintf("%d endothelial cells. \n",length(rows)))
counts <- counts_all[rows,]
samples <- samples_all[rows,]
save(list = c("samples","counts"), file = paste0(data.dir, "/", "Cusanovich_2018_endothelial_cells.RData"))
resaveRdaFiles(paste0(data.dir, "/", "Cusanovich_2018_endothelial_cells.RData"))

sessionInfo()
R version 3.6.1 (2019-07-05)
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] tools     stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] Matrix_1.2-18   workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6      lattice_0.20-41 rprojroot_2.0.2 digest_0.6.27  
 [5] later_1.1.0.1   grid_3.6.1      R6_2.5.0        git2r_0.27.1   
 [9] magrittr_2.0.1  evaluate_0.14   stringi_1.5.3   rlang_0.4.10   
[13] fs_1.3.1        promises_1.1.1  whisker_0.4     rmarkdown_2.6  
[17] stringr_1.4.0   glue_1.4.2      httpuv_1.5.4    xfun_0.19      
[21] yaml_2.2.1      compiler_3.6.1  htmltools_0.5.0 knitr_1.30