1 Introduction

This document provides an introduction of the ELMER.data, which contains supporting data for ELMER (Yao, L., Shen, H., Laird, P. W., Farnham, P. J., & Berman, B. P. 2015). ELMER is package using DNA methylation to identify enhancers, and correlates enhancer state with expression of nearby genes to identify one or more transcriptional targets. Transcription factor (TF) binding site analysis of enhancers is coupled with expression analysis of all TFs to infer upstream regulators. ELMER.data provide 3 necessary data for ELMER analysis:

  1. Probes information: files with DNA methylation platforms metadata retrieved from http://zwdzwd.github.io/InfiniumAnnotation (Zhou, Wanding and Laird, Peter W and Shen, Hui 2016).
  2. Probes.motif: motif occurences within \(\pm 250bp\) of probe sites on HM450K/EPIC array aligned against hg19/hg38.

1.1 Installing and loading ELMER.data

To install this package, start R and enter

2 Contents

2.1 Probes information

Probes information were retrieved from http://zwdzwd.github.io/InfiniumAnnotation (Zhou, Wanding and Laird, Peter W and Shen, Hui 2016).

2.2 TF family and subfamily classifications

ELMER uses the TFClass (Wingender, E., Schoeps, T., Haubrock, M., & Dönitz, J 2014), a classification of eukaryotic transcription factors based on the characteristics of their DNA-binding domains, to identify which are the TF that might be binding to the same region. For example, if a FOXA1 motif is found in a region, there is FOXA2 would also be able to bind to that region. For that ELMER uses two classifications, Family and sub-family. TFClass schema is shown below.

TFClass schema is below:

Level Rank denomination Definition Example
1 Superclass General topology of the DNA-binding domain Zinc-coordinating DNA-binding domains (Superclass 2)
2 Class Structural blueprint of the DNA-binding domain Nuclear receptors with C4 zinc fingers (Class 2.1)
3 Family Sequence & functional similarity Thyroid hormone receptor-related factors (NR1) (Family 2.1.2)
4 Subfamily Sequence-based subgroupings Retinoic acid receptors (NR1B) (Subfamily 2.1.2.1)
5 Genus Transcription factor gene RAR-α (Genus 2.1.2.1.1)
4 Species TF polypeptide RAR-α1 (Species 2.1.2.1.1.1)

The following code was used to create the objects:

library(xml2)
library(httr)
library(dplyr)
library(rvest)
createMotifRelevantTfs <- function(classification = "family"){
  
  message("Accessing hocomoco to get last version of TFs ", classification)
  file <- paste0(classification,".motif.relevant.TFs.rda")
  
  # Download from http://hocomoco.autosome.ru/human/mono
  tf.family <- "http://hocomoco11.autosome.ru/human/mono?full=true" %>% read_html()  %>%  html_table()
  tf.family <- tf.family[[1]]
  # Split TF for each family, this will help us map for each motif which are the some ones in the family
  # basicaly: for a TF get its family then get all TF in that family
  col <- ifelse(classification == "family", "TF family","TF subfamily")
  family <- split(tf.family,f = tf.family[[col]])
  
  motif.relevant.TFs <- plyr::alply(tf.family,1, function(x){  
    f <- x[[col]]
    if(f == "") return(x$`Transcription factor`) # Case without family, we will get only the same object
    return(unique(family[as.character(f)][[1]]$`Transcription factor`))
  },.progress = "text")
  #names(motif.relevant.TFs) <- tf.family$`Transcription factor`
  names(motif.relevant.TFs) <- tf.family$Model
  # Cleaning object
  attr(motif.relevant.TFs,which="split_type") <- NULL
  attr(motif.relevant.TFs,which="split_labels") <- NULL
  
  return(motif.relevant.TFs)
}

updateTFClassList <- function(tf.list, classification = "family"){
  col <- ifelse(classification == "family","family.name","subfamily.name")
  TFclass <- getTFClass()
  # Hocomoco
  tf.family <- "http://hocomoco11.autosome.ru/human/mono?full=true" %>% read_html()  %>%  html_table()
  tf.family <- tf.family[[1]]
  
  tf.members <- plyr::alply(unique(TFclass %>% pull(col)),1, function(x){  
    TFclass$Gene[which(x == TFclass[,col])]
  },.progress = "text")
  names(tf.members) <- unique(TFclass %>% pull(col))
  attr(tf.members,which="split_type") <- NULL
  attr(tf.members,which="split_labels") <- NULL
  
  for(i in names(tf.list)){
    x <- tf.family[tf.family$Model == i,"Transcription factor"]
    idx <- which(sapply(lapply(tf.members, function(ch) grep(paste0("^",x,"$"), ch)), function(x) length(x) > 0))
    if(length(idx) == 0) next
    members <- tf.members[[idx]]
    tf.list[[i]] <- sort(unique(c(tf.list[[i]],members)))
  }
  return(tf.list)
}

getTFClass <- function(){
  # get TF classification
  file <- "TFClass.rda"
  if(file.exists(file)) {
    return(get(load(file)))
  }
  file <- "http://tfclass.bioinf.med.uni-goettingen.de/suppl/tfclass.ttl.gz"
  downloader::download(file,basename(file))
  char_vector <- readLines(basename(file))
  # Find TF idx
  idx <- grep("genus",char_vector,ignore.case = T)
  
  # get TF names
  TF <- char_vector[sort(c( idx +1, idx + 2, idx + 4))]
  TF <- TF[-grep("LOGO_|rdf:type",TF)]
  TF <- gsub("  rdfs:label | ;| rdfs:subClassOf <http://sybig.de/tfclass#|>","",TF)
  TF <- stringr::str_trim(gsub('"', '', TF))
  TF <- tibble::as.tibble(t(matrix(TF,nrow = 2)))
  colnames(TF) <- c("Gene", "class")
  
  # Get family and subfamily classification
  family.pattern <-  "^<http://sybig.de/tfclass#[0-9]+\\.[0-9]+\\.[0-9]+>"
  
  idx <- grep(family.pattern,char_vector)
  family.names <- char_vector[ sort(c(idx,idx+ 2))]
  family.names <- gsub("  rdfs:label | ;| rdfs:subClassOf <http://sybig.de/tfclass#|>|<http://sybig.de/tfclass#| rdf:type owl:Class","",family.names)
  family.names <- stringr::str_trim(gsub('"', '', family.names))
  family.names <- tibble::as.tibble(t(matrix(family.names,nrow = 2)))
  colnames(family.names) <- c("family", "family.name")
  
  
  subfamily.pattern <-  "^<http://sybig.de/tfclass#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+>"
  
  idx <- grep(subfamily.pattern,char_vector)
  subfamily.names <- char_vector[ sort(c(idx,idx+ 2))]
  subfamily.names <- gsub("  rdfs:label | ;| rdfs:subClassOf <http://sybig.de/tfclass#|>|<http://sybig.de/tfclass#| rdf:type owl:Class","",subfamily.names)
  subfamily.names <- stringr::str_trim(gsub('"', '', subfamily.names))
  subfamily.names <- tibble::as.tibble(t(matrix(subfamily.names,nrow = 2)))
  colnames(subfamily.names) <- c("subfamily", "subfamily.name")
  subfamily.names$family <- stringr::str_sub(subfamily.names$subfamily,1,5)
  
  classification <- left_join(family.names,subfamily.names)
  classification$class <- ifelse(is.na(classification$subfamily),classification$family,classification$subfamily)
  
  # Add classification to TF list
  TFclass <- left_join(TF,classification)
  
  # Break ( into multiple cases)
  m <- grep("\\(|/",TFclass$Gene)
  df <- NULL
  for(i in m){
    gene <- sort(stringr::str_trim(unlist(stringr::str_split(TFclass$Gene[i],"\\(|,|\\)|/"))))
    gene <- gene[stringr::str_length(gene) > 0]
    aux <- TFclass[rep(i,length(gene)),]
    aux$Gene <- gene
    df <- rbind(df,aux)
  }
  TFclass <- rbind(TFclass,df)
  TFclass <- TFclass[!duplicated(TFclass),]
  
  # Break ( into multiple cases)
  m <- grep("-",TFclass$Gene)
  df <- NULL
  for(i in m){
    gene <- gsub("-","",sort(stringr::str_trim(unlist(stringr::str_split(TFclass$Gene[i],"\\(|,|\\)|/")))))
    gene <- gene[stringr::str_length(gene) > 0]
    aux <- TFclass[rep(i,length(gene)),]
    aux$Gene <- gene
    df <- rbind(df,aux)
  }
  TFclass <- rbind(TFclass,df)
  
  df <- NULL
  for(i in 1:length(TFclass$Gene)){