Last updated: 2019-07-16

Checks: 6 1

Knit directory: MAGL/

This reproducible R Markdown analysis was created with workflowr (version 1.4.0). 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.

The global environment had objects present when the code in the R Markdown file was run. These objects 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. Use wflow_publish or wflow_build to ensure that the code is always run in an empty environment.

The following objects were defined in the global environment when these results were created:

Name Class Size
data environment 56 bytes
env environment 56 bytes

The command set.seed(20190311) 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 version displayed above was the version of the Git repository at the time these results were generated.

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:    ._.Renviron
    Ignored:    ._.gitignore
    Ignored:    ._README.md
    Ignored:    ._Snakefile
    Ignored:    ._config.yaml
    Ignored:    .snakemake/
    Ignored:    MAGL/.DS_Store
    Ignored:    MAGL/.RData
    Ignored:    MAGL/.Rhistory
    Ignored:    MAGL/._.DS_Store
    Ignored:    MAGL/._.Rprofile
    Ignored:    MAGL/._.gitignore
    Ignored:    MAGL/._data
    Ignored:    MAGL/analysis/._refs.bib
    Ignored:    MAGL/analysis/0-preprocessing_cache/
    Ignored:    MAGL/analysis/3-differential_cache/
    Ignored:    MAGL/analysis/4-visualization_cache/
    Ignored:    MAGL/analysis/5-geneset_cache/
    Ignored:    MAGL/analysis/6-more_cache/
    Ignored:    MAGL/data/
    Ignored:    MAGL/output/
    Ignored:    data/
    Ignored:    figures/
    Ignored:    meta/
    Ignored:    results/
    Ignored:    scripts/.DS_Store
    Ignored:    scripts/._.DS_Store
    Ignored:    scripts/._apply_scdd.R
    Ignored:    scripts/._plot_perf_by_expr.R
    Ignored:    scripts/._plot_perf_by_lfc.R
    Ignored:    scripts/._plot_perf_by_ss.R
    Ignored:    scripts/._plot_runtimes.R
    Ignored:    scripts/._plot_sim_ex.R
    Ignored:    scripts/._prep_data.R
    Ignored:    scripts/._prep_magl.R
    Ignored:    scripts/._prep_sim.R
    Ignored:    scripts/._sim_qc.R
    Ignored:    scripts/._utils.R

Untracked files:
    Untracked:  .RData
    Untracked:  .RDataTmp
    Untracked:  .Rhistory
    Untracked:  MAGL/current
    Untracked:  figs/

Unstaged changes:
    Modified:   MAGL/.Rprofile
    Modified:   MAGL/analysis/3-differential.Rmd
    Deleted:    scripts/fig_vehicle_vs_lps.R

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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd 244411f HelenaLC 2019-07-11 update lps analysis to include removal of doublets
html 244411f HelenaLC 2019-07-11 update lps analysis to include removal of doublets
Rmd f10fe14 HelenaLC 2019-06-17 rmv old
html 08bf260 HelenaLC 2019-06-17 update
Rmd 61c0b06 HelenaLC 2019-05-20 update
html 3c5aa5f HelenaLC 2019-05-03 add MAGL prepro,clust,anno
Rmd 10c7525 HelenaLC 2019-05-03 add MAGL prepro,clust,anno
Rmd eaed7ec HelenaLC 2019-03-11 initial commit

# increase future's maximum allowed size of objects
# to be exported from default of 500 MB to 2 GB
options(future.globals.maxSize = 2048 * 1024 ^ 2)

Load packages

library(cowplot)
library(Seurat)
library(SingleCellExperiment)

Load data

sce <- readRDS(file.path("output", "MAGL-SCE.rds"))

Integration

# create SeuratObject
so <- CreateSeuratObject(
    counts = counts(sce),
    meta.data = data.frame(colData(sce)),
    project = "10xMAGL")

# split by sample
cells_by_sample <- split(colnames(sce), sce$sample_id)
so <- lapply(cells_by_sample, function(i)
    SubsetData(so, cells = i))
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
Warning: 'SubsetData' is deprecated.
Use 'subset' instead.
See help("Deprecated")
Warning: 'OldWhichCells' is deprecated.
Use 'WhichCells' instead.
See help("Deprecated")
# normalize, find variable genes, and scale
so <- lapply(so, NormalizeData, verbose = FALSE)
so <- lapply(so, FindVariableFeatures, nfeatures = 2e3,
    selection.method = "vst", do.plot = FALSE, verbose = FALSE)
so <- lapply(so, ScaleData, verbose = FALSE)

# find anchors & integrate
as <- FindIntegrationAnchors(so, verbose = FALSE)
so <- IntegrateData(anchorset = as, dims = seq_len(30), verbose = FALSE)

# scale integrated data
DefaultAssay(so) <- "integrated"
so <- ScaleData(so, display.progress = FALSE)
Centering and scaling data matrix

Dimension reduction

so <- RunPCA(so, npcs = 30, verbose = FALSE)
so <- RunTSNE(so, reduction = "pca", dims = seq_len(20),
    seed.use = 1, do.fast = TRUE, verbose = FALSE)
so <- RunUMAP(so, reduction = "pca", dims = seq_len(20),
    seed.use = 1, verbose = FALSE)

Clustering

so <- FindNeighbors(so, reduction = "pca", dims = seq_len(20), verbose = FALSE)
for (res in c(0.1, 0.2, 0.4, 0.8, 1, 1.2, 2))
    so <- FindClusters(so, resolution = res, random.seed = 1, verbose = FALSE)

DR colored by sample, group, and cluster ID

thm <- theme(aspect.ratio = 1, legend.position = "none")
ps <- lapply(c("sample_id", "group_id", "ident"), function(u) {
    p1 <- DimPlot(so, reduction = "tsne", group.by = u) + thm
    p2 <- DimPlot(so, reduction = "umap", group.by = u)
    lgd <- get_legend(p2)
    p2 <- p2 + thm
    list(p1, p2, lgd)
    plot_grid(p1, p2, lgd, nrow = 1,
        rel_widths = c(1, 1, 0.5))
})
plot_grid(plotlist = ps, ncol = 1)

Version Author Date
244411f HelenaLC 2019-07-11

Save SeuratObject to .rds

saveRDS(so, file.path("output", "MAGL-SeuratObject.rds"))

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS:   /usr/local/R/R-3.6.0/lib/libRblas.so
LAPACK: /home/HelenaLC/soft/miniconda3/lib/libmkl_rt.so

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

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

other attached packages:
 [1] SingleCellExperiment_1.6.0  SummarizedExperiment_1.14.0
 [3] DelayedArray_0.10.0         BiocParallel_1.18.0        
 [5] matrixStats_0.54.0          Biobase_2.44.0             
 [7] GenomicRanges_1.36.0        GenomeInfoDb_1.20.0        
 [9] IRanges_2.18.1              S4Vectors_0.22.0           
[11] BiocGenerics_0.30.0         Seurat_3.0.2               
[13] cowplot_0.9.4               ggplot2_3.2.0              

loaded via a namespace (and not attached):
  [1] Rtsne_0.15             colorspace_1.4-1       ggridges_0.5.1        
  [4] rprojroot_1.3-2        XVector_0.24.0         fs_1.3.1              
  [7] listenv_0.7.0          npsurv_0.4-0           ggrepel_0.8.1         
 [10] codetools_0.2-16       splines_3.6.0          R.methodsS3_1.7.1     
 [13] lsei_1.2-0             knitr_1.23             jsonlite_1.6          
 [16] workflowr_1.4.0        ica_1.0-2              cluster_2.1.0         
 [19] png_0.1-7              R.oo_1.22.0            sctransform_0.2.0     
 [22] compiler_3.6.0         httr_1.4.0             backports_1.1.4       
 [25] assertthat_0.2.1       Matrix_1.2-17          lazyeval_0.2.2        
 [28] htmltools_0.3.6        tools_3.6.0            rsvd_1.0.1            
 [31] igraph_1.2.4.1         gtable_0.3.0           glue_1.3.1            
 [34] GenomeInfoDbData_1.2.1 RANN_2.6.1             reshape2_1.4.3        
 [37] dplyr_0.8.3            Rcpp_1.0.1             gdata_2.18.0          
 [40] ape_5.3                nlme_3.1-140           gbRd_0.4-11           
 [43] lmtest_0.9-37          xfun_0.8               stringr_1.4.0         
 [46] globals_0.12.4         irlba_2.3.3            gtools_3.8.1          
 [49] future_1.14.0          MASS_7.3-51.4          zlibbioc_1.30.0       
 [52] zoo_1.8-6              scales_1.0.0           RColorBrewer_1.1-2    
 [55] yaml_2.2.0             reticulate_1.12        pbapply_1.4-0         
 [58] gridExtra_2.3          stringi_1.4.3          highr_0.8             
 [61] caTools_1.17.1.2       bibtex_0.4.2           Rdpack_0.11-0         
 [64] SDMTools_1.1-221.1     rlang_0.4.0            pkgconfig_2.0.2       
 [67] bitops_1.0-6           evaluate_0.14          lattice_0.20-38       
 [70] ROCR_1.0-7             purrr_0.3.2            htmlwidgets_1.3       
 [73] labeling_0.3           tidyselect_0.2.5       plyr_1.8.4            
 [76] magrittr_1.5           R6_2.4.0               gplots_3.0.1.1        
 [79] pillar_1.4.2           whisker_0.3-2          withr_2.1.2           
 [82] fitdistrplus_1.0-14    survival_2.44-1.1      RCurl_1.95-4.12       
 [85] tibble_2.1.3           future.apply_1.3.0     tsne_0.1-3            
 [88] crayon_1.3.4           KernSmooth_2.23-15     plotly_4.9.0          
 [91] rmarkdown_1.13         grid_3.6.0             data.table_1.12.2     
 [94] git2r_0.26.1           metap_1.1              digest_0.6.20         
 [97] tidyr_0.8.3            R.utils_2.9.0          munsell_0.5.0         
[100] viridisLite_0.3.0