Contents

1 DELocal

1.1 Introduction

Exploration of genetically modified organisms, developmental processes, diseases or responses to various treatments require accurate measurement of changes in gene expression. This can be done for thousands of genes using high throughput technologies such as microarray and RNAseq. However, identification of differentially expressed (DE) genes poses technical challenges due to limited sample size, few replicates, or simply very small changes in expression levels. Consequently, several methods have been developed to determine DE genes, such as Limma, edgeR, and DESeq2. These methods identify DE genes based on the expression levels alone. As genomic co-localization of genes is generally not linked to co-expression, we deduced that DE genes could be detected with the help of genes from chromosomal neighbourhood. Here, we present a new method, DELocal, which identifies DE genes by comparing their expression changes to changes in adjacent genes in their chromosomal regions.

neighbor
In the above figure it can be seen that Sostdc1 is differentially expressed in developing tooth tissues (E13 and E14). DELocal helps in identifying similar genes.

1.2 Installation

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("delocal")

To install from github

if (!requireNamespace("devtools")) {
  install.packages("devtools")
}
devtools::install_github("dasroy/delocal")

1.3 How to run

This is a basic example which shows you how to use DELocal:

First a SummarizedExperiment object will be configured with gene expression count matrix and gene location info.

1.3.0.1 Read the raw count values

library(DELocal)
count_matrix <- as.matrix(read.table(file = system.file("extdata", 
                                              "tooth_RNASeq_counts.txt", 
                                              package = "DELocal")))
colData <- data.frame(condition=gsub("\\..*",x=colnames(count_matrix),
                                     replacement = ""))

1.3.0.2 Getting gene chromosomal location

Example of required gene location information

gene_location <- read.table(file = system.file("extdata", 
                                              "gene_location.txt", 
                                              package = "DELocal"))
head(gene_location)
#>                       ensembl_gene_id start_position chromosome_name
#> ENSMUSG00000000001 ENSMUSG00000000001      108107280               3
#> ENSMUSG00000000003 ENSMUSG00000000003       77837901               X
#> ENSMUSG00000000028 ENSMUSG00000000028       18780447              16
#> ENSMUSG00000000031 ENSMUSG00000000031      142575529               7
#> ENSMUSG00000000037 ENSMUSG00000000037      161082525               X
#> ENSMUSG00000000049 ENSMUSG00000000049      108343354              11

1.3.0.3 Example code to get gene location information like above

library(biomaRt)
gene_attributes <- c("ensembl_gene_id", "start_position", "chromosome_name")
ensembl_ms_mart <- useMart(biomart="ENSEMBL_MART_ENSEMBL",
                           dataset="mmusculus_gene_ensembl", host="www.ensembl.org")
#> Warning: Ensembl will soon enforce the use of https.
#> Ensure the 'host' argument includes "https://"
gene_location_sample <- getBM(attributes=gene_attributes, mart=ensembl_ms_mart,
                       verbose = FALSE)
rownames(gene_location_sample) <- gene_location_sample$ensembl_gene_id

1.3.0.4 Integrating gene expression and location into a single object.

library(SummarizedExperiment)
smrExpt <- SummarizedExperiment(assays=list(counts=count_matrix),
                                                      rowData = gene_location, 
                                                      colData=colData)
smrExpt
#> class: SummarizedExperiment 
#> dim: 52183 14 
#> metadata(0):
#> assays(1): counts
#> rownames(52183): ENSMUSG00000000001 ENSMUSG00000000003 ...
#>   ENSMUSG00000114967 ENSMUSG00000114968
#> rowData names(3): ensembl_gene_id start_position chromosome_name
#> colnames(14): ME14.E1M1R ME14.E2M1R ... ME13.E9M1R ME13.EXM1L
#> colData names(1): condition

1.3.0.5 Final results

These may take long time to run the whole data therefore here we will analyse genes only from X chromosome. Here in this example DELocal compares each gene with 5 ‘nearest_neighbours’ and returns only genes whose adjusted p-value is less than pValue_cut.

library(dplyr)
x_genes <- SummarizedExperiment::rowData(smrExpt) %>% 
    as.data.frame() %>% 
    filter(chromosome_name=="X") %>% rownames() 

DELocal_result <- DELocal(pSmrExpt = smrExpt[x_genes,],
                         nearest_neighbours = 5,pDesign = ~ condition,
                         pValue_cut = 0.05)

head(round(DELocal_result,digits = 9))
#>                    relative.logFC  P.Value   adj.P.Val         B
#> ENSMUSG00000037217       508.8688 0.00e+00 0.000000091 15.033054
#> ENSMUSG00000062184      -694.6147 4.07e-07 0.000267921  4.970833
#> ENSMUSG00000059401       140.0683 4.35e-07 0.000267921  4.899633
#> ENSMUSG00000016319       955.2564 4.85e-07 0.000267921  4.781442
#> ENSMUSG00000045103       417.2448 5.18e-07 0.000267921  4.711055
#> ENSMUSG00000031103       370.1563 6.98e-07 0.000300492  4.392911

The results are already sorted in ascending order of adjusted p-value (adj.P.Val)

1.3.0.6 Plot expression pattern of a neighbourhood of a gene

plotNeighbourhood function can be used to plot median expressions of different ‘condition’ for a gene of interest and its pNearest_neighbours genes.

DELocal::plotNeighbourhood(pSmrExpt = smrExpt, pGene_id = "ENSMUSG00000059401", 
                           pNearest_neighbours=5, pDesign = ~ condition)$plot

1.3.0.7 Dynamic neighbour

In previous example 1 Mb chromosomal area around each gene to define its neighbourhood. The choice of 1Mb window is obviously somewhat arbitrary. However it is also possible to use different size of neighbourhood for each gene. For that user can provide “neighbors_start” and “neighbors_end” for each gene in the rowData.
To demonstrate this, TADs (topologically associating domains) boundaries which are different for each gene are used next.

gene_location_dynamicNeighbourhood <- read.csv(system.file("extdata", "Mouse_TAD_boundaries.csv",
                             package = "DELocal"))

rownames(gene_location_dynamicNeighbourhood) <- 
    gene_location_dynamicNeighbourhood$ensembl_gene_id

# rename the columns as required by DELocal
colnames(gene_location_dynamicNeighbourhood)[4:5] <- c("neighbors_start",
                                                       "neighbors_end")
common_genes <- intersect(rownames(count_matrix),
                          rownames(gene_location_dynamicNeighbourhood) )

smrExpt_dynamicNeighbour <-
    SummarizedExperiment::SummarizedExperiment(
        assays = list(counts = count_matrix[common_genes,]),
        rowData = gene_location_dynamicNeighbourhood[common_genes, ],
        colData = colData
    )

## Selecting only chromosome 1 genes to reduce the runtime                                                      
# one_genes <- SummarizedExperiment::rowData(smrExpt_dynamicNeighbour) %>% 
#     as.data.frame() %>% 
#     filter(chromosome_name=="1") %>% rownames() 

DELocal_result_tad <- DELocal(pSmrExpt = smrExpt_dynamicNeighbour[x_genes,], 
                         nearest_neighbours = 5,pDesign = ~ condition,
                         pValue_cut = 0.05, pLogFold_cut = 0)

head(DELocal_result_tad)
#>                    relative.logFC      P.Value    adj.P.Val         B
#> ENSMUSG00000037217       508.8688 3.520588e-11 9.097200e-08 15.036315
#> ENSMUSG00000062184      -694.6147 4.068015e-07 2.679164e-04  4.974179
#> ENSMUSG00000059401       140.0683 4.347483e-07 2.679164e-04  4.902978
#> ENSMUSG00000016319       955.2564 4.854489e-07 2.679164e-04  4.784788
#> ENSMUSG00000045103       417.2448 5.184140e-07 2.679164e-04  4.714401
#> ENSMUSG00000031103       370.1563 6.977232e-07 3.004861e-04  4.396258

1.4 SessionInfo

#> R Under development (unstable) (2024-01-16 r85808)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> 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       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] dplyr_1.1.4                 SummarizedExperiment_1.33.3
#>  [3] Biobase_2.63.0              GenomicRanges_1.55.2       
#>  [5] GenomeInfoDb_1.39.5         IRanges_2.37.1             
#>  [7] S4Vectors_0.41.3            BiocGenerics_0.49.1        
#>  [9] MatrixGenerics_1.15.0       matrixStats_1.2.0          
#> [11] biomaRt_2.59.1              DELocal_1.3.1              
#> [13] BiocStyle_2.31.0           
#> 
#> loaded via a namespace (and not attached):
#>  [1] DBI_1.2.1               bitops_1.0-7            httr2_1.0.0            
#>  [4] rlang_1.1.3             magrittr_2.0.3          compiler_4.4.0         
#>  [7] RSQLite_2.3.5           png_0.1-8               vctrs_0.6.5            
#> [10] reshape2_1.4.4          stringr_1.5.1           pkgconfig_2.0.3        
#> [13] crayon_1.5.2            fastmap_1.1.1           magick_2.8.2           
#> [16] dbplyr_2.4.0            XVector_0.43.1          labeling_0.4.3         
#> [19] utf8_1.2.4              rmarkdown_2.25          purrr_1.0.2            
#> [22] bit_4.0.5               xfun_0.41               zlibbioc_1.49.0        
#> [25] cachem_1.0.8            jsonlite_1.8.8          progress_1.2.3         
#> [28] blob_1.2.4              highr_0.10              DelayedArray_0.29.1    
#> [31] BiocParallel_1.37.0     parallel_4.4.0          prettyunits_1.2.0      
#> [34] R6_2.5.1                bslib_0.6.1             stringi_1.8.3          
#> [37] limma_3.59.2            jquerylib_0.1.4         Rcpp_1.0.12            
#> [40] bookdown_0.37           knitr_1.45              Matrix_1.6-5           
#> [43] tidyselect_1.2.0        abind_1.4-5             yaml_2.3.8             
#> [46] codetools_0.2-19        curl_5.2.0              lattice_0.22-5         
#> [49] tibble_3.2.1            plyr_1.8.9              withr_3.0.0            
#> [52] KEGGREST_1.43.0         evaluate_0.23           BiocFileCache_2.11.1   
#> [55] xml2_1.3.6              Biostrings_2.71.2       pillar_1.9.0           
#> [58] BiocManager_1.30.22     filelock_1.0.3          generics_0.1.3         
#> [61] RCurl_1.98-1.14         hms_1.1.3               ggplot2_3.4.4          
#> [64] munsell_0.5.0           scales_1.3.0            glue_1.7.0             
#> [67] tools_4.4.0             locfit_1.5-9.8          grid_4.4.0             
#> [70] AnnotationDbi_1.65.2    colorspace_2.1-0        GenomeInfoDbData_1.2.11
#> [73] cli_3.6.2               rappdirs_0.3.3          fansi_1.0.6            
#> [76] S4Arrays_1.3.3          gtable_0.3.4            DESeq2_1.43.2          
#> [79] sass_0.4.8              digest_0.6.34           SparseArray_1.3.3      
#> [82] farver_2.1.1            memoise_2.0.1           htmltools_0.5.7        
#> [85] lifecycle_1.0.4         httr_1.4.7              statmod_1.5.0          
#> [88] bit64_4.0.5