Contents

One application of TAP-seq is to measure the expression of genes that enable assigning cells to different cell types. The TAPseq package offers a simple approach to identify a desired number of cell type markers based on differentially expressed genes between cell types.

This optional functionality requires additional R-packages such as Seurat. Please install the TAPseq package with all suggested dependencies.

1 Data

The TAPseq package contains a small subset of the mouse bone marrow data from Baccin et al., 2019 (https://www.nature.com/articles/s41556-019-0439-6). The full dataset can be downloaded here. This dataset is stored in a Seurat object which contains both gene expression and cell type data for every cell.

library(TAPseq)
library(Seurat)

# example of mouse bone marrow 10x gene expression data
data("bone_marrow_genex")

# transcript counts
GetAssayData(bone_marrow_genex)[1:10, 1:10]

# number of cells per cell type
table(Idents(bone_marrow_genex))

2 Select target genes

A linear model with lasso regularization is used to select target genes that best identify cell types. By default 10-fold cross-validation is used to select the number of target genes based on the largest value of lambda within 1 standard error of the minimum. See ?glmnet::cv.glmnet for more details.

# automatically select a number of target genes using 10-fold cross-validation
target_genes_cv <- selectTargetGenes(bone_marrow_genex)
head(target_genes_cv)
length(target_genes_cv)

This example results in a reasonable target gene panel, but in cases with many different cell types the resulting panels might be very large.

To avoid this, we can specify a desired number of targets. This selects a value for lamda in the lasso model that results in approximately this number of non-zero coefficients, i.e. marker genes.

# identify approximately 100 target genes that can be used to identify cell populations
target_genes_100 <- selectTargetGenes(bone_marrow_genex, targets = 100)
length(target_genes_100)

3 Assess target gene panels

To intuitively assess how well a chosen set of target genes distinguishes cell types, we can use UMAP plots based on the full gene expression data and on target genes only.

plotTargetGenes(bone_marrow_genex, target_genes = target_genes_100)

We can see that the expression of the 99 selected target genes groups cells of different populations together.

A good follow up would be to cluster the cells based on only the target genes following the same workflow used to define the cell identities in the original object. This could then be used to verify that the selected target genes reliably identify the correct cell types.

4 Session information

All of the output in this vignette was produced under the following conditions:

sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [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] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] SeuratObject_4.0.2                Seurat_4.0.5                     
#>  [3] ggplot2_3.3.5                     dplyr_1.0.7                      
#>  [5] BSgenome.Hsapiens.UCSC.hg38_1.4.4 BSgenome_1.62.0                  
#>  [7] rtracklayer_1.54.0                Biostrings_2.62.0                
#>  [9] XVector_0.34.0                    BiocParallel_1.28.0              
#> [11] GenomicRanges_1.46.0              GenomeInfoDb_1.30.0              
#> [13] IRanges_2.28.0                    S4Vectors_0.32.0                 
#> [15] BiocGenerics_0.40.0               TAPseq_1.6.0                     
#> [17] BiocStyle_2.22.0                 
#> 
#> loaded via a namespace (and not attached):
#>   [1] utf8_1.2.2                  reticulate_1.22            
#>   [3] tidyselect_1.1.1            RSQLite_2.2.8              
#>   [5] AnnotationDbi_1.56.0        htmlwidgets_1.5.4          
#>   [7] grid_4.1.1                  Rtsne_0.15                 
#>   [9] munsell_0.5.0               codetools_0.2-18           
#>  [11] ica_1.0-2                   future_1.22.1              
#>  [13] miniUI_0.1.1.1              withr_2.4.2                
#>  [15] colorspace_2.0-2            Biobase_2.54.0             
#>  [17] filelock_1.0.2              highr_0.9                  
#>  [19] knitr_1.36                  ROCR_1.0-11                
#>  [21] tensor_1.5                  listenv_0.8.0              
#>  [23] MatrixGenerics_1.6.0        labeling_0.4.2             
#>  [25] GenomeInfoDbData_1.2.7      polyclip_1.10-0            
#>  [27] bit64_4.0.5                 farver_2.1.0               
#>  [29] parallelly_1.28.1           vctrs_0.3.8                
#>  [31] generics_0.1.1              xfun_0.27                  
#>  [33] BiocFileCache_2.2.0         R6_2.5.1                   
#>  [35] bitops_1.0-7                spatstat.utils_2.2-0       
#>  [37] cachem_1.0.6                DelayedArray_0.20.0        
#>  [39] assertthat_0.2.1            promises_1.2.0.1           
#>  [41] BiocIO_1.4.0                scales_1.1.1               
#>  [43] gtable_0.3.0                globals_0.14.0             
#>  [45] goftest_1.2-3               rlang_0.4.12               
#>  [47] splines_4.1.1               lazyeval_0.2.2             
#>  [49] spatstat.geom_2.3-0         BiocManager_1.30.16        
#>  [51] yaml_2.2.1                  reshape2_1.4.4             
#>  [53] abind_1.4-5                 GenomicFeatures_1.46.0     
#>  [55] httpuv_1.6.3                tools_4.1.1                
#>  [57] bookdown_0.24               ellipsis_0.3.2             
#>  [59] spatstat.core_2.3-0         jquerylib_0.1.4            
#>  [61] RColorBrewer_1.1-2          ggridges_0.5.3             
#>  [63] Rcpp_1.0.7                  plyr_1.8.6                 
#>  [65] progress_1.2.2              zlibbioc_1.40.0            
#>  [67] purrr_0.3.4                 RCurl_1.98-1.5             
#>  [69] prettyunits_1.1.1           rpart_4.1-15               
#>  [71] deldir_1.0-6                pbapply_1.5-0              
#>  [73] cowplot_1.1.1               zoo_1.8-9                  
#>  [75] SummarizedExperiment_1.24.0 ggrepel_0.9.1              
#>  [77] cluster_2.1.2               magrittr_2.0.1             
#>  [79] RSpectra_0.16-0             data.table_1.14.2          
#>  [81] magick_2.7.3                scattermore_0.7            
#>  [83] lmtest_0.9-38               RANN_2.6.1                 
#>  [85] fitdistrplus_1.1-6          matrixStats_0.61.0         
#>  [87] hms_1.1.1                   patchwork_1.1.1            
#>  [89] mime_0.12                   evaluate_0.14              
#>  [91] xtable_1.8-4                XML_3.99-0.8               
#>  [93] shape_1.4.6                 gridExtra_2.3              
#>  [95] compiler_4.1.1              biomaRt_2.50.0             
#>  [97] tibble_3.1.5                KernSmooth_2.23-20         
#>  [99] crayon_1.4.1                htmltools_0.5.2            
#> [101] mgcv_1.8-38                 later_1.3.0                
#> [103] tidyr_1.1.4                 DBI_1.1.1                  
#> [105] dbplyr_2.1.1                MASS_7.3-54                
#> [107] rappdirs_0.3.3              Matrix_1.3-4               
#> [109] parallel_4.1.1              igraph_1.2.7               
#> [111] pkgconfig_2.0.3             GenomicAlignments_1.30.0   
#> [113] plotly_4.10.0               spatstat.sparse_2.0-0      
#> [115] foreach_1.5.1               xml2_1.3.2                 
#> [117] bslib_0.3.1                 stringr_1.4.0              
#> [119] digest_0.6.28               sctransform_0.3.2          
#> [121] RcppAnnoy_0.0.19            spatstat.data_2.1-0        
#> [123] rmarkdown_2.11              leiden_0.3.9               
#> [125] uwot_0.1.10                 restfulr_0.0.13            
#> [127] curl_4.3.2                  shiny_1.7.1                
#> [129] Rsamtools_2.10.0            rjson_0.2.20               
#> [131] lifecycle_1.0.1             nlme_3.1-153               
#> [133] jsonlite_1.7.2              limma_3.50.0               
#> [135] viridisLite_0.4.0           fansi_0.5.0                
#> [137] pillar_1.6.4                lattice_0.20-45            
#> [139] KEGGREST_1.34.0             fastmap_1.1.0              
#> [141] httr_1.4.2                  survival_3.2-13            
#> [143] glue_1.4.2                  iterators_1.0.13           
#> [145] png_0.1-7                   glmnet_4.1-2               
#> [147] bit_4.0.4                   stringi_1.7.5              
#> [149] sass_0.4.0                  blob_1.2.2                 
#> [151] memoise_2.0.0               irlba_2.3.3                
#> [153] future.apply_1.8.1