Last updated: 2023-10-18

Checks: 6 1

Knit directory: paed-airway-allTissues/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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(20230811) 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 8538338. 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:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/RDS/
    Ignored:    output/G000231_Neeland_batch1/
    Ignored:    output/G000231_Neeland_batch2_1/
    Ignored:    output/G000231_Neeland_batch2_2/
    Ignored:    output/G000231_Neeland_batch3/
    Ignored:    output/G000231_Neeland_batch4/
    Ignored:    output/G000231_Neeland_batch5/
    Ignored:    output/RDS/

Untracked files:
    Untracked:  analysis/00_AllBatches_overview.Rmd
    Untracked:  figure/

Unstaged changes:
    Deleted:    02_QC_exploratoryPlots.Rmd
    Deleted:    02_QC_exploratoryPlots.html
    Modified:   analysis/01_QC_emptyDrops.Rmd

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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


INTRODUCTION

This RMarkdown reads CellRanger output i.e filtered count matrix for each sample in a batch and creates a Seurat object for filtered CellRanger output for each batch. Batch 1- Nasal brushings (n=16)
Batch 2_1- Tonsils (n=16)
Batch 2_2- Nasal brushings (n=9) (repeats)
Batch 3- Adenoids (n=16)
Batch 4- Bronchial brushings (n=16)
Batch 5- Nasal brushings (n=16)
Batch 6- BAL (n=16) #NOTE: Only 8 samples were collected. 8 samples with 2 barcodes were run using the same 16-plex assay workflow , therefore targeting 16k cells per sample.
Batch 7- Bronchial brushings_2 (n=16)
Batch 8- Adenoids_2 (n=16)
Batch 9- Tonsils_2 (n=16)

Load libraries

suppressPackageStartupMessages({
  library(BiocStyle)
  library(tidyverse)
  library(here)
  library(dplyr)
  library(glue)
  library(Seurat)
  library(DropletUtils)
  library(kableExtra)
  library(RColorBrewer)
  library(scater)
  library(cowplot)
})

List batch files

files <- list.files(here("output",
                         "RDS", 
                         "AllBatches"), 
                      pattern = "filtered_CellRanger_SEU",
                      full.names = TRUE)
batches <- sub("_filtered_CellRanger_SEU\\.rds$", "", basename(files))
batches
 [1] "G000231_Neeland_batch1"   "G000231_Neeland_batch2_1"
 [3] "G000231_Neeland_batch2_2" "G000231_Neeland_batch3"  
 [5] "G000231_Neeland_batch4"   "G000231_Neeland_batch5"  
 [7] "G000231_Neeland_batch6"   "G000231_Neeland_batch7"  
 [9] "G000231_Neeland_batch8"   "G000231_Neeland_batch9"  
tissue_types <- c("Nasal_brushings", "Tonsils", "Nasal_brushings_repeat", "Adenoids", "Bronchial_brushings", "Nasal_brushings_2", "BAL", "Bronchial_brushings_2", "Adeoids_2", "Tonsils_2")
tissue_types
 [1] "Nasal_brushings"        "Tonsils"                "Nasal_brushings_repeat"
 [4] "Adenoids"               "Bronchial_brushings"    "Nasal_brushings_2"     
 [7] "BAL"                    "Bronchial_brushings_2"  "Adeoids_2"             
[10] "Tonsils_2"             
make_filtered_seurat <- function(sample_name, batch) {
  sub_batch <- paste0(gsub("Neeland_", "", batch), "_1")
  seu <- Read10X_h5(here("data", batch, "extdata/CellRanger", sub_batch, "outs", "per_sample_outs", sample_name, "count", "sample_filtered_feature_bc_matrix.h5")) %>%
    CreateSeuratObject()
  seu$Sample <- sample_name
  return(seu)
}
for (batch in batches) {
  sub_batch <- paste0(gsub("Neeland_", "", batch), "_1")
  out <- here("output/RDS/AllBatches", paste0(batch, "_filtered_CellRanger_SEU.rds"))
  
  if(!file.exists(out)){
    sample_dir <- here("data", batch, "extdata/CellRanger", sub_batch, "outs/per_sample_outs/")
    sample_names <- list.dirs(sample_dir, recursive = FALSE, full.names = FALSE)
    seu1 <- lapply(sample_names, function(sn) make_filtered_seurat(sn, batch))
    seu1 <- merge(seu1[[1]], unlist(seu1[2:length(seu1)]))
    saveRDS(seu1, file = out)
  }
}        

Generate barplot for counts per sample

plot_list <- list()
for (i in seq_along(batches)){
  batch <- batches[i]
  tissue <- tissue_types[i]
  seu <- readRDS(here("output/RDS/AllBatches", paste0(batch, "_filtered_CellRanger_SEU.rds")))
  sce <- as.SingleCellExperiment(seu)
  num_unique_samples <- length(unique(sce$Sample))
  color_palette <- colorRampPalette(brewer.pal(20, "Set3"))(num_unique_samples)

  # Extract unique sample names and assign colors from the color palette
  names(color_palette) <- sort(unique(sce$Sample))

  # Create the plot for the current batch
  p <- ggcells(sce) + 
    geom_bar(aes(x = Sample, fill = Sample)) + 
    coord_flip() + 
    ylab("Number of droplets") + 
    theme_cowplot(font_size = 10) + 
    geom_text(stat='count', aes(x = Sample, label=..count..), hjust=1.5, size=3) +
    guides(fill = "none") +
    scale_fill_manual(values = color_palette) +
    labs(title = paste0(batch, ": ", tissue)) 
  
  # Store the plot in the list
  plot_list[[batch]] <- p
}
for (i in seq_along(batches)){
  batch_name <- batches[i]
  tissue_type <- tissue_types[i]
  cat('### ', batch_name, " - ", tissue_type, '\n')
  print(plot_list[[batch_name]]) 
  cat('\n\n')
}

G000231_Neeland_batch1 - Nasal_brushings

G000231_Neeland_batch2_1 - Tonsils

G000231_Neeland_batch2_2 - Nasal_brushings_repeat

G000231_Neeland_batch3 - Adenoids

G000231_Neeland_batch4 - Bronchial_brushings

G000231_Neeland_batch5 - Nasal_brushings_2

G000231_Neeland_batch6 - BAL

G000231_Neeland_batch7 - Bronchial_brushings_2

G000231_Neeland_batch8 - Adeoids_2

G000231_Neeland_batch9 - Tonsils_2

Session Info

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

time zone: Australia/Melbourne
tzcode source: internal

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

other attached packages:
 [1] cowplot_1.1.1               scater_1.28.0              
 [3] scuttle_1.10.1              RColorBrewer_1.1-3         
 [5] kableExtra_1.3.4            DropletUtils_1.20.0        
 [7] SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2
 [9] Biobase_2.60.0              GenomicRanges_1.52.0       
[11] GenomeInfoDb_1.36.1         IRanges_2.34.1             
[13] S4Vectors_0.38.1            BiocGenerics_0.46.0        
[15] MatrixGenerics_1.12.2       matrixStats_1.0.0          
[17] SeuratObject_4.1.3          Seurat_4.3.0.1             
[19] glue_1.6.2                  here_1.0.1                 
[21] lubridate_1.9.2             forcats_1.0.0              
[23] stringr_1.5.0               dplyr_1.1.2                
[25] purrr_1.0.1                 readr_2.1.4                
[27] tidyr_1.3.0                 tibble_3.2.1               
[29] ggplot2_3.4.2               tidyverse_2.0.0            
[31] BiocStyle_2.28.0            workflowr_1.7.0            

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.21          splines_4.3.1            
  [3] later_1.3.1               bitops_1.0-7             
  [5] R.oo_1.25.0               polyclip_1.10-4          
  [7] lifecycle_1.0.3           edgeR_3.42.4             
  [9] rprojroot_2.0.3           globals_0.16.2           
 [11] processx_3.8.2            lattice_0.21-8           
 [13] MASS_7.3-60               magrittr_2.0.3           
 [15] limma_3.56.2              plotly_4.10.2            
 [17] sass_0.4.7                rmarkdown_2.23           
 [19] jquerylib_0.1.4           yaml_2.3.7               
 [21] httpuv_1.6.11             sctransform_0.3.5        
 [23] sp_2.0-0                  spatstat.sparse_3.0-2    
 [25] reticulate_1.30           pbapply_1.7-2            
 [27] abind_1.4-5               zlibbioc_1.46.0          
 [29] rvest_1.0.3               Rtsne_0.16               
 [31] R.utils_2.12.2            RCurl_1.98-1.12          
 [33] git2r_0.32.0              GenomeInfoDbData_1.2.10  
 [35] ggrepel_0.9.3             irlba_2.3.5.1            
 [37] listenv_0.9.0             spatstat.utils_3.0-3     
 [39] goftest_1.2-3             dqrng_0.3.0              
 [41] spatstat.random_3.1-5     fitdistrplus_1.1-11      
 [43] parallelly_1.36.0         svglite_2.1.1            
 [45] DelayedMatrixStats_1.22.1 leiden_0.4.3             
 [47] codetools_0.2-19          DelayedArray_0.26.6      
 [49] xml2_1.3.5                tidyselect_1.2.0         
 [51] farver_2.1.1              viridis_0.6.4            
 [53] ScaledMatrix_1.8.1        spatstat.explore_3.2-1   
 [55] webshot_0.5.5             jsonlite_1.8.7           
 [57] BiocNeighbors_1.18.0      ellipsis_0.3.2           
 [59] progressr_0.13.0          ggridges_0.5.4           
 [61] survival_3.5-5            systemfonts_1.0.4        
 [63] tools_4.3.1               ica_1.0-3                
 [65] Rcpp_1.0.11               gridExtra_2.3            
 [67] xfun_0.39                 HDF5Array_1.28.1         
 [69] withr_2.5.0               BiocManager_1.30.21.1    
 [71] fastmap_1.1.1             rhdf5filters_1.12.1      
 [73] fansi_1.0.4               rsvd_1.0.5               
 [75] callr_3.7.3               digest_0.6.33            
 [77] timechange_0.2.0          R6_2.5.1                 
 [79] mime_0.12                 colorspace_2.1-0         
 [81] scattermore_1.2           tensor_1.5               
 [83] spatstat.data_3.0-1       R.methodsS3_1.8.2        
 [85] utf8_1.2.3                generics_0.1.3           
 [87] data.table_1.14.8         httr_1.4.6               
 [89] htmlwidgets_1.6.2         S4Arrays_1.0.4           
 [91] whisker_0.4.1             uwot_0.1.16              
 [93] pkgconfig_2.0.3           gtable_0.3.3             
 [95] lmtest_0.9-40             XVector_0.40.0           
 [97] htmltools_0.5.5           scales_1.2.1             
 [99] png_0.1-8                 knitr_1.43               
[101] rstudioapi_0.15.0         tzdb_0.4.0               
[103] reshape2_1.4.4            nlme_3.1-162             
[105] cachem_1.0.8              zoo_1.8-12               
[107] rhdf5_2.44.0              KernSmooth_2.23-22       
[109] vipor_0.4.5               parallel_4.3.1           
[111] miniUI_0.1.1.1            pillar_1.9.0             
[113] grid_4.3.1                vctrs_0.6.3              
[115] RANN_2.6.1                promises_1.2.0.1         
[117] BiocSingular_1.16.0       beachmat_2.16.0          
[119] xtable_1.8-4              cluster_2.1.4            
[121] beeswarm_0.4.0            evaluate_0.21            
[123] locfit_1.5-9.8            cli_3.6.1                
[125] compiler_4.3.1            rlang_1.1.1              
[127] crayon_1.5.2              future.apply_1.11.0      
[129] labeling_0.4.2            ps_1.7.5                 
[131] ggbeeswarm_0.7.2          getPass_0.2-2            
[133] plyr_1.8.8                fs_1.6.3                 
[135] stringi_1.7.12            viridisLite_0.4.2        
[137] deldir_1.0-9              BiocParallel_1.34.2      
[139] munsell_0.5.0             lazyeval_0.2.2           
[141] spatstat.geom_3.2-4       Matrix_1.6-0             
[143] hms_1.1.3                 patchwork_1.1.2          
[145] sparseMatrixStats_1.12.2  future_1.33.0            
[147] Rhdf5lib_1.22.0           shiny_1.7.4.1            
[149] highr_0.10                ROCR_1.0-11              
[151] igraph_1.5.0              bslib_0.5.0              

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

time zone: Australia/Melbourne
tzcode source: internal

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

other attached packages:
 [1] cowplot_1.1.1               scater_1.28.0              
 [3] scuttle_1.10.1              RColorBrewer_1.1-3         
 [5] kableExtra_1.3.4            DropletUtils_1.20.0        
 [7] SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2
 [9] Biobase_2.60.0              GenomicRanges_1.52.0       
[11] GenomeInfoDb_1.36.1         IRanges_2.34.1             
[13] S4Vectors_0.38.1            BiocGenerics_0.46.0        
[15] MatrixGenerics_1.12.2       matrixStats_1.0.0          
[17] SeuratObject_4.1.3          Seurat_4.3.0.1             
[19] glue_1.6.2                  here_1.0.1                 
[21] lubridate_1.9.2             forcats_1.0.0              
[23] stringr_1.5.0               dplyr_1.1.2                
[25] purrr_1.0.1                 readr_2.1.4                
[27] tidyr_1.3.0                 tibble_3.2.1               
[29] ggplot2_3.4.2               tidyverse_2.0.0            
[31] BiocStyle_2.28.0            workflowr_1.7.0            

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.21          splines_4.3.1            
  [3] later_1.3.1               bitops_1.0-7             
  [5] R.oo_1.25.0               polyclip_1.10-4          
  [7] lifecycle_1.0.3           edgeR_3.42.4             
  [9] rprojroot_2.0.3           globals_0.16.2           
 [11] processx_3.8.2            lattice_0.21-8           
 [13] MASS_7.3-60               magrittr_2.0.3           
 [15] limma_3.56.2              plotly_4.10.2            
 [17] sass_0.4.7                rmarkdown_2.23           
 [19] jquerylib_0.1.4           yaml_2.3.7               
 [21] httpuv_1.6.11             sctransform_0.3.5        
 [23] sp_2.0-0                  spatstat.sparse_3.0-2    
 [25] reticulate_1.30           pbapply_1.7-2            
 [27] abind_1.4-5               zlibbioc_1.46.0          
 [29] rvest_1.0.3               Rtsne_0.16               
 [31] R.utils_2.12.2            RCurl_1.98-1.12          
 [33] git2r_0.32.0              GenomeInfoDbData_1.2.10  
 [35] ggrepel_0.9.3             irlba_2.3.5.1            
 [37] listenv_0.9.0             spatstat.utils_3.0-3     
 [39] goftest_1.2-3             dqrng_0.3.0              
 [41] spatstat.random_3.1-5     fitdistrplus_1.1-11      
 [43] parallelly_1.36.0         svglite_2.1.1            
 [45] DelayedMatrixStats_1.22.1 leiden_0.4.3             
 [47] codetools_0.2-19          DelayedArray_0.26.6      
 [49] xml2_1.3.5                tidyselect_1.2.0         
 [51] farver_2.1.1              viridis_0.6.4            
 [53] ScaledMatrix_1.8.1        spatstat.explore_3.2-1   
 [55] webshot_0.5.5             jsonlite_1.8.7           
 [57] BiocNeighbors_1.18.0      ellipsis_0.3.2           
 [59] progressr_0.13.0          ggridges_0.5.4           
 [61] survival_3.5-5            systemfonts_1.0.4        
 [63] tools_4.3.1               ica_1.0-3                
 [65] Rcpp_1.0.11               gridExtra_2.3            
 [67] xfun_0.39                 HDF5Array_1.28.1         
 [69] withr_2.5.0               BiocManager_1.30.21.1    
 [71] fastmap_1.1.1             rhdf5filters_1.12.1      
 [73] fansi_1.0.4               rsvd_1.0.5               
 [75] callr_3.7.3               digest_0.6.33            
 [77] timechange_0.2.0          R6_2.5.1                 
 [79] mime_0.12                 colorspace_2.1-0         
 [81] scattermore_1.2           tensor_1.5               
 [83] spatstat.data_3.0-1       R.methodsS3_1.8.2        
 [85] utf8_1.2.3                generics_0.1.3           
 [87] data.table_1.14.8         httr_1.4.6               
 [89] htmlwidgets_1.6.2         S4Arrays_1.0.4           
 [91] whisker_0.4.1             uwot_0.1.16              
 [93] pkgconfig_2.0.3           gtable_0.3.3             
 [95] lmtest_0.9-40             XVector_0.40.0           
 [97] htmltools_0.5.5           scales_1.2.1             
 [99] png_0.1-8                 knitr_1.43               
[101] rstudioapi_0.15.0         tzdb_0.4.0               
[103] reshape2_1.4.4            nlme_3.1-162             
[105] cachem_1.0.8              zoo_1.8-12               
[107] rhdf5_2.44.0              KernSmooth_2.23-22       
[109] vipor_0.4.5               parallel_4.3.1           
[111] miniUI_0.1.1.1            pillar_1.9.0             
[113] grid_4.3.1                vctrs_0.6.3              
[115] RANN_2.6.1                promises_1.2.0.1         
[117] BiocSingular_1.16.0       beachmat_2.16.0          
[119] xtable_1.8-4              cluster_2.1.4            
[121] beeswarm_0.4.0            evaluate_0.21            
[123] locfit_1.5-9.8            cli_3.6.1                
[125] compiler_4.3.1            rlang_1.1.1              
[127] crayon_1.5.2              future.apply_1.11.0      
[129] labeling_0.4.2            ps_1.7.5                 
[131] ggbeeswarm_0.7.2          getPass_0.2-2            
[133] plyr_1.8.8                fs_1.6.3                 
[135] stringi_1.7.12            viridisLite_0.4.2        
[137] deldir_1.0-9              BiocParallel_1.34.2      
[139] munsell_0.5.0             lazyeval_0.2.2           
[141] spatstat.geom_3.2-4       Matrix_1.6-0             
[143] hms_1.1.3                 patchwork_1.1.2          
[145] sparseMatrixStats_1.12.2  future_1.33.0            
[147] Rhdf5lib_1.22.0           shiny_1.7.4.1            
[149] highr_0.10                ROCR_1.0-11              
[151] igraph_1.5.0              bslib_0.5.0