# Select target genes for TAP-seq

Andreas Gschwind

Department of Genetics, Stanford University

#### 2025-04-16

#### Package

TAPseq 1.20.0

# 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)
    #> Warning in lognet(xd, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : one
    #> multinomial or binomial class has fewer than 8 observations; dangerous ground
    #> Warning in lognet(xd, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : one
    #> multinomial or binomial class has fewer than 8 observations; dangerous ground
    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 100 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.5.0 RC (2025-04-04 r88126 ucrt)
    #> Platform: x86_64-w64-mingw32/x64
    #> Running under: Windows Server 2022 x64 (build 20348)
    #>
    #> Matrix products: default
    #>   LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] LC_COLLATE=C
    #> [2] LC_CTYPE=English_United States.utf8
    #> [3] LC_MONETARY=English_United States.utf8
    #> [4] LC_NUMERIC=C
    #> [5] LC_TIME=English_United States.utf8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats4    stats     graphics  grDevices utils     datasets  methods
    #> [8] base
    #>
    #> other attached packages:
    #>  [1] Seurat_5.2.1                      SeuratObject_5.0.2
    #>  [3] sp_2.2-0                          ggplot2_3.5.2
    #>  [5] dplyr_1.1.4                       BSgenome.Hsapiens.UCSC.hg38_1.4.5
    #>  [7] BSgenome_1.76.0                   rtracklayer_1.68.0
    #>  [9] BiocIO_1.18.0                     Biostrings_2.76.0
    #> [11] XVector_0.48.0                    BiocParallel_1.42.0
    #> [13] GenomicRanges_1.60.0              GenomeInfoDb_1.44.0
    #> [15] IRanges_2.42.0                    S4Vectors_0.46.0
    #> [17] BiocGenerics_0.54.0               generics_0.1.3
    #> [19] TAPseq_1.20.0                     BiocStyle_2.36.0
    #>
    #> loaded via a namespace (and not attached):
    #>   [1] RcppAnnoy_0.0.22            splines_4.5.0
    #>   [3] later_1.4.2                 bitops_1.0-9
    #>   [5] tibble_3.2.1                polyclip_1.10-7
    #>   [7] XML_3.99-0.18               fastDummies_1.7.5
    #>   [9] lifecycle_1.0.4             globals_0.16.3
    #>  [11] lattice_0.22-7              MASS_7.3-65
    #>  [13] magrittr_2.0.3              limma_3.64.0
    #>  [15] plotly_4.10.4               sass_0.4.10
    #>  [17] rmarkdown_2.29              jquerylib_0.1.4
    #>  [19] yaml_2.3.10                 httpuv_1.6.15
    #>  [21] sctransform_0.4.1           spam_2.11-1
    #>  [23] spatstat.sparse_3.1-0       reticulate_1.42.0
    #>  [25] cowplot_1.1.3               pbapply_1.7-2
    #>  [27] DBI_1.2.3                   RColorBrewer_1.1-3
    #>  [29] abind_1.4-8                 Rtsne_0.17
    #>  [31] purrr_1.0.4                 RCurl_1.98-1.17
    #>  [33] GenomeInfoDbData_1.2.14     ggrepel_0.9.6
    #>  [35] irlba_2.3.5.1               listenv_0.9.1
    #>  [37] spatstat.utils_3.1-3        goftest_1.2-3
    #>  [39] RSpectra_0.16-2             spatstat.random_3.3-3
    #>  [41] fitdistrplus_1.2-2          parallelly_1.43.0
    #>  [43] codetools_0.2-20            DelayedArray_0.34.0
    #>  [45] shape_1.4.6.1               tidyselect_1.2.1
    #>  [47] UCSC.utils_1.4.0            farver_2.1.2
    #>  [49] matrixStats_1.5.0           spatstat.explore_3.4-2
    #>  [51] GenomicAlignments_1.44.0    jsonlite_2.0.0
    #>  [53] progressr_0.15.1            iterators_1.0.14
    #>  [55] ggridges_0.5.6              survival_3.8-3
    #>  [57] foreach_1.5.2               tools_4.5.0
    #>  [59] ica_1.0-3                   Rcpp_1.0.14
    #>  [61] glue_1.8.0                  gridExtra_2.3
    #>  [63] SparseArray_1.8.0           xfun_0.52
    #>  [65] MatrixGenerics_1.20.0       withr_3.0.2
    #>  [67] BiocManager_1.30.25         fastmap_1.2.0
    #>  [69] digest_0.6.37               R6_2.6.1
    #>  [71] mime_0.13                   colorspace_2.1-1
    #>  [73] scattermore_1.2             tensor_1.5
    #>  [75] spatstat.data_3.1-6         RSQLite_2.3.9
    #>  [77] tidyr_1.3.1                 data.table_1.17.0
    #>  [79] httr_1.4.7                  htmlwidgets_1.6.4
    #>  [81] S4Arrays_1.8.0              uwot_0.2.3
    #>  [83] pkgconfig_2.0.3             gtable_0.3.6
    #>  [85] blob_1.2.4                  lmtest_0.9-40
    #>  [87] htmltools_0.5.8.1           dotCall64_1.2
    #>  [89] bookdown_0.43               scales_1.3.0
    #>  [91] Biobase_2.68.0              png_0.1-8
    #>  [93] spatstat.univar_3.1-2       knitr_1.50
    #>  [95] reshape2_1.4.4              rjson_0.2.23
    #>  [97] nlme_3.1-168                curl_6.2.2
    #>  [99] cachem_1.1.0                zoo_1.8-14
    #> [101] stringr_1.5.1               KernSmooth_2.23-26
    #> [103] parallel_4.5.0              miniUI_0.1.1.1
    #> [105] AnnotationDbi_1.70.0        restfulr_0.0.15
    #> [107] pillar_1.10.2               grid_4.5.0
    #> [109] vctrs_0.6.5                 RANN_2.6.2
    #> [111] promises_1.3.2              xtable_1.8-4
    #> [113] cluster_2.1.8.1             evaluate_1.0.3
    #> [115] tinytex_0.57                GenomicFeatures_1.60.0
    #> [117] magick_2.8.6                cli_3.6.4
    #> [119] compiler_4.5.0              Rsamtools_2.24.0
    #> [121] rlang_1.1.6                 crayon_1.5.3
    #> [123] future.apply_1.11.3         labeling_0.4.3
    #> [125] plyr_1.8.9                  stringi_1.8.7
    #> [127] deldir_2.0-4                viridisLite_0.4.2
    #> [129] munsell_0.5.1               lazyeval_0.2.2
    #> [131] spatstat.geom_3.3-6         glmnet_4.1-8
    #> [133] Matrix_1.7-3                RcppHNSW_0.6.0
    #> [135] patchwork_1.3.0             bit64_4.6.0-1
    #> [137] future_1.40.0               statmod_1.5.0
    #> [139] KEGGREST_1.48.0             shiny_1.10.0
    #> [141] SummarizedExperiment_1.38.0 ROCR_1.0-11
    #> [143] igraph_2.1.4                memoise_2.0.1
    #> [145] bslib_0.9.0                 bit_4.6.0