# Sample Metadata Inference

SeSAMe implements inference of sex, age, ethnicity. These are valuable information for checking the integrity of the experiment and detecting sample swaps.

# Sex, XCI

Sex is inferred based on our curated X-linked probes and Y chromosome probes excluding pseudo-autosomal regions and XCI escapes.

Human:

    betas = openSesame(sesameDataGet("EPICv2.8.SigDF")[[1]])
    inferSex(betas)

    ## [1] "FEMALE"

Mouse:

    betas = openSesame(sesameDataGet("MM285.1.SigDF"))
    inferSex(betas)

    ## [1] "MALE"

# Age & Epigenetic Clock

SeSAMe provides age regression through multiple previously established models, e.g., the well-known Horvath 353 model (Horvath 2013) which returns the chronological age in the number of years. Here is an example:

    betas <- sesameDataGet('HM450.1.TCGA.PAAD')$betas
    ## download clock file from http://zwdzwd.github.io/InfiniumAnnotation
    model <- readRDS("~/Downloads/Clock_Horvath353.rds")
    predictAge(betas, model)

And MM285 mouse array data using a set of 347 CpGs (see Zhou et al. 2022) The function returns the age in the number of months. We recommend using SeSAMe preprocessed data as input to the function. Here’s an example:

    library(SummarizedExperiment)
    betas <- assay(sesameDataGet("MM285.10.SE.tissue"))[,1]
    ## download clock file from http://zwdzwd.github.io/InfiniumAnnotation
    model <- readRDS("~/Downloads/Clock_Zhou347.rds")
    predictAge(betas, model)

This indicates that this mouse is approximately 1.41 months old. The function looks for overlapping probes and estimates age using the corresponding clock models.

# Copy Number

See Supplemental Vignette

# Cell Count Deconvolution

SeSAMe estimates leukocyte fraction using a two-component model.This function works for samples whose targeted cell-of-origin is not related to white blood cells.

    betas.tissue <- sesameDataGet('HM450.1.TCGA.PAAD')$betas
    estimateLeukocyte(betas.tissue)

    ## [1] 0.2007592

# Genomic Privacy

The goal of data sanitization is to modifiy IDAT files in place, so they can be released to public domain without privacy leak. This will be achieved by deIdentification.

Let’s take DNA methylation data from the HM450 platform for example. First, let’s download test IDATs from https://github.com/zhou-lab/InfiniumAnnotationV1/tree/main/Test

## De-identify by Masking

This first method of deIdentification masks SNP probe intensity mean by zero. As a consequence, the allele frequency will be 0.5.

    deIdentify("~/Downloads/3999492009_R01C01_Grn.idat",
        "~/Downloads/deidentified_Grn.idat")
    deIdentify("~/Downloads/3999492009_R01C01_Red.idat",
        "~/Downloads/deidentified_Red.idat")

    betas1 = getBetas(readIDATpair("~/Downloads/3999492009_R01C01"))
    betas2 = getBetas(readIDATpair("~/Downloads/deidentified"))

    head(betas1[grep('rs',names(betas1))])
    head(betas2[grep('rs',names(betas2))])

Note that before deIdentify, the rs values will all be different. After deIdentify, the rs values will all be masked at an intensity of 0.5.

## De-identify by Scrambling

This second method of deIdentification will scramble the intensities using a secret key to help formalize a random number. Therefore, randomize needs to be set to TRUE.

    my_secret <- 13412084
    set.seed(my_secret)

    deIdentify("~/Downloads/3999492009_R01C01_Grn.idat",
        "~/Downloads/deidentified_Grn.idat", randomize=TRUE)

    my_secret <- 13412084
    set.seed(my_secret)
    deIdentify("~/Downloads/3999492009_R01C01_Red.idat",
        "~/Downloads/deidentified_Red.idat", randomize=TRUE)

    betas1 = getBetas(readIDATpair("~/Downloads/3999492009_R01C01"))
    betas2 = getBetas(readIDATpair("~/Downloads/deidentified"))

    head(betas1[grep('rs',names(betas1))])
    head(betas2[grep('rs',names(betas2))])

Note that the rs values are scrambled after deIdentify.

## Re-identify

To restore order of the deIdentified intensities, one can re-identify IDATs. The reIdentify function can thus restore the scrambled SNP intensities.

    my_secret <- 13412084
    set.seed(my_secret)

    reIdentify(sprintf("%s/deidentified_Grn.idat", tmp),
        sprintf("%s/reidentified_Grn.idat", tmp))

    my_secret <- 13412084
    set.seed(my_secret)
    reIdentify("~/Downloads/deidentified_Red.idat",
        "~/Downloads/reidentified_Red.idat")

    betas1 = getBetas(readIDATpair("~/Downloads/3999492009_R01C01"))
    betas2 = getBetas(readIDATpair("~/Downloads/reidentified"))

    head(betas1[grep('rs',names(betas1))])
    head(betas2[grep('rs',names(betas2))])

Note that reIdentify restored the values. Subsequently, they are the same as betas1.

# Session Info

    sessionInfo()

    ## R version 4.6.1 (2026-06-24)
    ## Platform: x86_64-pc-linux-gnu
    ## Running under: Ubuntu 26.04 LTS
    ##
    ## Matrix products: default
    ## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
    ##
    ## 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
    ##
    ## time zone: Etc/UTC
    ## tzcode source: system (glibc)
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] sesame_1.31.4        sesameData_1.31.0    ExperimentHub_3.3.1
    ## [4] AnnotationHub_4.3.2  BiocFileCache_3.3.0  dbplyr_2.6.0
    ## [7] BiocGenerics_0.59.10 generics_0.1.4
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] tidyselect_1.2.1            dplyr_1.2.1
    ##  [3] farver_2.1.2                blob_1.3.0
    ##  [5] filelock_1.0.3              Biostrings_2.81.5
    ##  [7] S7_0.2.2                    fastmap_1.2.0
    ##  [9] digest_0.6.39               lifecycle_1.0.5
    ## [11] KEGGREST_1.53.5             RSQLite_3.53.3
    ## [13] magrittr_2.0.5              compiler_4.6.1
    ## [15] rlang_1.3.0                 sass_0.4.10
    ## [17] tools_4.6.1                 yaml_2.3.12
    ## [19] knitr_1.51                  S4Arrays_1.13.0
    ## [21] bit_4.6.0                   curl_7.1.0
    ## [23] DelayedArray_0.39.3         plyr_1.8.9
    ## [25] RColorBrewer_1.1-3          abind_1.4-8
    ## [27] BiocParallel_1.47.0         withr_3.0.3
    ## [29] purrr_1.2.2                 sys_3.4.3
    ## [31] grid_4.6.1                  stats4_4.6.1
    ## [33] preprocessCore_1.75.0       wheatmap_0.2.4
    ## [35] colorspace_2.1-3            ggplot2_4.0.3
    ## [37] MASS_7.3-66                 scales_1.4.0
    ## [39] dichromat_2.0-0.1           SummarizedExperiment_1.43.0
    ## [41] cli_3.6.6                   rmarkdown_2.31
    ## [43] crayon_1.5.3                otel_0.2.0
    ## [45] reshape2_1.4.5              httr_1.4.8
    ## [47] tzdb_0.5.0                  BiocBaseUtils_1.15.1
    ## [49] DBI_1.3.0                   cachem_1.1.0
    ## [51] stringr_1.6.0               parallel_4.6.1
    ## [53] AnnotationDbi_1.75.2        BiocManager_1.30.27
    ## [55] XVector_0.53.0              matrixStats_1.5.0
    ## [57] vctrs_0.7.3                 Matrix_1.7-5
    ## [59] jsonlite_2.0.0              IRanges_2.47.2
    ## [61] hms_1.1.4                   S4Vectors_0.51.5
    ## [63] bit64_4.8.2                 maketools_1.3.2
    ## [65] jquerylib_0.1.4             glue_1.8.1
    ## [67] codetools_0.2-20            stringi_1.8.7
    ## [69] gtable_0.3.6                BiocVersion_3.24.0
    ## [71] GenomicRanges_1.65.1        tibble_3.3.1
    ## [73] pillar_1.11.1               rappdirs_0.3.4
    ## [75] htmltools_0.5.9             Seqinfo_1.3.0
    ## [77] R6_2.6.1                    httr2_1.3.0
    ## [79] lattice_0.22-9              evaluate_1.0.5
    ## [81] Biobase_2.73.1              readr_2.2.0
    ## [83] png_0.1-9                   memoise_2.0.1
    ## [85] BiocStyle_2.41.0            bslib_0.11.0
    ## [87] Rcpp_1.1.2                  SparseArray_1.13.2
    ## [89] xfun_0.60                   MatrixGenerics_1.25.0
    ## [91] buildtools_1.0.0            pkgconfig_2.0.3