Last updated: 2020-01-23

Checks: 7 0

Knit directory: peco-paper/

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

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(20190814) 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:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/npreg_trendfilter_quantile.Rmd
    Untracked:  analysis/pca-tf.Rmd
    Untracked:  code/fig2_rev.R
    Untracked:  data/fit.quant.rds
    Untracked:  data/intensity.rds
    Untracked:  data/log2cpm.quant.rds

Unstaged changes:
    Modified:   analysis/access_data.Rmd
    Modified:   analysis/index.Rmd
    Modified:   code/fig2.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 66c350a jhsiao999 2020-01-23 move gene_filtering.Rmd and change eset to sce
html 6107391 jhsiao999 2020-01-23 Build site.
Rmd 2d495fb jhsiao999 2020-01-23 move gene_filtering.Rmd and change eset to sce


Summary

I performed gene filtering based on the criterion set forth in our previous paper.

  1. Remove outlier genes: molecule counts > 4,096 in any sample (x is the theoretical maximum of UMI count for 6-bp UMI)

Results There’s one, and turns out this over-expressed gene is one of the mitochrondrial genes.

\(~\)

  1. Remove lowly expressed genes: Lowly-expressed genes := gene mean < 2 CPM.

Results: * Of 20,421 genes, 7,637 genes are classifed as lowly-expressed. Of these, 34 are ERCC control genes and 7,603 are endogenoeus genes.


Set-up

library(knitr)
library(SingleCellExperiment)
library(dplyr)
library(heatmap3)
library(testit)
library(cowplot)
library(biomaRt)
library(knitr)
library(data.table)

sce_raw <- readRDS("data/sce-raw.rds")
anno = data.frame(colData(sce_raw))

Filter out low-quality single cell samples.

anno_filter <- anno[anno$filter_all == TRUE,]
count_filter <- assay(sce_raw)[,anno$filter_all == TRUE]
dim(count_filter)
[1] 20421   923

Over-expressed genes

There’s one, and turns out this over-expressed gene.

which_over_expressed <- which(apply(count_filter, 1, function(x) any(x>(4^6)) ))
over_expressed_genes <- rownames(count_filter)[which_over_expressed]
over_expressed_genes
character(0)

Get over-expressed gene info via biomaRt.

over_expressed_genes_info <- getBM(
  attributes = c("ensembl_gene_id", "chromosome_name",
                 "external_gene_name", "transcript_count",
                 "description"),
  filters = "ensembl_gene_id",
  values = over_expressed_genes,
  mart = ensembl)

Filter out lowly-expressed genes

  • Of 20,421 genes, 7,864 genes are classifed as lowly-expressed. Of these, 34 are ERCC control genes and 7,830 are endogenoeus genes.

Compute CPM

cpm <- t(t(count_filter)/colSums(count_filter))*(10^6)

Lowly-expressed genes := gene mean < 2 CPM

cpm <- t(t(count_filter)/anno_filter$molecules)*(10^6)
which_lowly_expressed <- which(rowMeans(cpm) < 2)

length(grep("ERCC", which_lowly_expressed))
[1] 0
length(grep("ENSG", which_lowly_expressed))
[1] 0

Get gene info via biomaRt.

lowly_expressed_genes_info <- getBM(
  attributes = c("ensembl_gene_id", "chromosome_name",
                 "external_gene_name", "transcript_count",
                 "description"),
  filters = "ensembl_gene_id",
  values = which_lowly_expressed[grep("ENSG", which_lowly_expressed_genes)],
  mart = ensembl)

Combine filters

Including 12784 genes.

gene_filter <- unique(c(which_over_expressed, which_lowly_expressed))
genes_to_include <- setdiff(1:nrow(count_filter), gene_filter)
length(genes_to_include)
[1] 11168

Session information

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] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] data.table_1.12.0           biomaRt_2.38.0             
 [3] cowplot_0.9.4               ggplot2_3.2.1              
 [5] testit_0.9                  heatmap3_1.1.6             
 [7] dplyr_0.8.0.1               SingleCellExperiment_1.4.1 
 [9] SummarizedExperiment_1.12.0 DelayedArray_0.8.0         
[11] BiocParallel_1.16.0         matrixStats_0.55.0         
[13] Biobase_2.42.0              GenomicRanges_1.34.0       
[15] GenomeInfoDb_1.18.1         IRanges_2.16.0             
[17] S4Vectors_0.20.1            BiocGenerics_0.28.0        
[19] knitr_1.20                 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3             lattice_0.20-38        prettyunits_1.0.2     
 [4] assertthat_0.2.1       rprojroot_1.3-2        digest_0.6.20         
 [7] R6_2.4.0               backports_1.1.2        RSQLite_2.1.1         
[10] evaluate_0.12          httr_1.3.1             pillar_1.3.1          
[13] progress_1.2.0         zlibbioc_1.28.0        rlang_0.4.0           
[16] lazyeval_0.2.1         blob_1.1.1             whisker_0.3-2         
[19] Matrix_1.2-17          rmarkdown_1.10         stringr_1.3.1         
[22] bit_1.1-14             RCurl_1.95-4.11        munsell_0.5.0         
[25] compiler_3.5.1         httpuv_1.4.5           pkgconfig_2.0.3       
[28] htmltools_0.3.6        tidyselect_0.2.5       tibble_2.1.1          
[31] GenomeInfoDbData_1.2.0 workflowr_1.6.0        XML_3.98-1.16         
[34] crayon_1.3.4           withr_2.1.2            later_0.7.5           
[37] bitops_1.0-6           grid_3.5.1             gtable_0.2.0          
[40] DBI_1.0.0              git2r_0.26.1           magrittr_1.5          
[43] scales_1.0.0           stringi_1.2.4          XVector_0.22.0        
[46] fs_1.3.1               promises_1.0.1         fastcluster_1.1.25    
[49] tools_3.5.1            bit64_0.9-7            glue_1.3.0            
[52] purrr_0.3.2            hms_0.4.2              yaml_2.2.0            
[55] AnnotationDbi_1.44.0   colorspace_1.3-2       memoise_1.1.0         

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] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] data.table_1.12.0           biomaRt_2.38.0             
 [3] cowplot_0.9.4               ggplot2_3.2.1              
 [5] testit_0.9                  heatmap3_1.1.6             
 [7] dplyr_0.8.0.1               SingleCellExperiment_1.4.1 
 [9] SummarizedExperiment_1.12.0 DelayedArray_0.8.0         
[11] BiocParallel_1.16.0         matrixStats_0.55.0         
[13] Biobase_2.42.0              GenomicRanges_1.34.0       
[15] GenomeInfoDb_1.18.1         IRanges_2.16.0             
[17] S4Vectors_0.20.1            BiocGenerics_0.28.0        
[19] knitr_1.20                 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3             lattice_0.20-38        prettyunits_1.0.2     
 [4] assertthat_0.2.1       rprojroot_1.3-2        digest_0.6.20         
 [7] R6_2.4.0               backports_1.1.2        RSQLite_2.1.1         
[10] evaluate_0.12          httr_1.3.1             pillar_1.3.1          
[13] progress_1.2.0         zlibbioc_1.28.0        rlang_0.4.0           
[16] lazyeval_0.2.1         blob_1.1.1             whisker_0.3-2         
[19] Matrix_1.2-17          rmarkdown_1.10         stringr_1.3.1         
[22] bit_1.1-14             RCurl_1.95-4.11        munsell_0.5.0         
[25] compiler_3.5.1         httpuv_1.4.5           pkgconfig_2.0.3       
[28] htmltools_0.3.6        tidyselect_0.2.5       tibble_2.1.1          
[31] GenomeInfoDbData_1.2.0 workflowr_1.6.0        XML_3.98-1.16         
[34] crayon_1.3.4           withr_2.1.2            later_0.7.5           
[37] bitops_1.0-6           grid_3.5.1             gtable_0.2.0          
[40] DBI_1.0.0              git2r_0.26.1           magrittr_1.5          
[43] scales_1.0.0           stringi_1.2.4          XVector_0.22.0        
[46] fs_1.3.1               promises_1.0.1         fastcluster_1.1.25    
[49] tools_3.5.1            bit64_0.9-7            glue_1.3.0            
[52] purrr_0.3.2            hms_0.4.2              yaml_2.2.0            
[55] AnnotationDbi_1.44.0   colorspace_1.3-2       memoise_1.1.0