R/detect_identifier.R

Defines functions detect_identifier

# detect gene identifier given a gene_id of type either entrez, ensembl or hgnc-symbol  
# or genomic regions given as chr:from-to

detect_identifier=function(gene_id){
    # de-factor
    if (is.factor(gene_id)){
        gene_id=as.character(gene_id)
    }
    # a) entrez-IDs are numeric
        numeri=!is.na(suppressWarnings(as.numeric(gene_id)))
    if (numeri){
        return("entrezgene")
    }   
    # b) ensembl-IDs start with "ENSG" and have 15 characters   
    if (nchar(gene_id)==15 && substring(gene_id,1,4)=="ENSG"){
        return("ensembl_gene_id")
    }
    # c) genomic region is chr:from-to
    if (grepl("^.*:[0-9]*-[0-9]*$", gene_id)){
        return("blocks")
    }
    # d) neither of the above cases in present in HGNC-symbols
    return("hgnc_symbol")           
}   

Try the ABAEnrichment package in your browser

Any scripts or data that you put into this service are public.

ABAEnrichment documentation built on Nov. 8, 2020, 5:43 p.m.