Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task3a - illumina annotation to output: gene, feature and relation to… #53

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions R/annotateDMR.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#' Function to annotate
#'
#' This function annotates a methylated region
#' TxDbannotation package is required
#' @param data DataFrame-like object.
#' @param db Database to use for annotation. E.g: IlluminaHumanMethylationEPICanno.ilm10b2.hg19.
#' @param epi_col CpG ids, should be rownames in database.
#' @param gene_col Column name from where to extract gene names. Default: 'GencodeBasicV12_NAME'.
#' @param feat_col Column name from where to extract CpG feature groups. Default: 'Regulatory_Feature_Group'.
#' @param relat_col Column name from where to extract relation to island info. Default: 'Relation_to_Island'.
#' @return DataFrame-like object annotated.
#' @export
annotate_CpG <- function(data, db, epi_col='CpG_ids', gene_col='GencodeBasicV12_NAME', feat_col='Regulatory_Feature_Group', relat_col='Relation_to_Island'){
message('Annotating:')
anno <- getAnnotation(IlluminaHumanMethylationEPICanno.ilm10b2.hg19)
epids_list <- data[[epi_col]]
message(paste('-', gene_col))
annotated_genes <- lapply(epids_list, function(x){
paste(anno[x,][[gene_col]], collapse='///')
})
message(paste('-', feat_col))
annotated_regions <- lapply(epids_list, function(x){
paste(anno[x,][[feat_col]], collapse='///')
})
message(paste('-', relat_col))
annotated_relation <- lapply(epids_list, function(x){
paste(anno[x,][[relat_col]], collapse='///')
})


data[[gene_col]] <- annotated_genes
data[[feat_col]] <- annotated_regions
data[[relat_col]] <- annotated_relation
return(data)
}