달력

52025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

library(ontologyIndex)

phe_dat = as.matrix(read.csv('/home/starjjbang/Storage/part1/SAAVpedia/data/anno_file/tmp/9_ESP_1000G_pheno_drug_PTM_ontology_function.txt',sep='\t',header = FALSE, row.names = NULL))

of = '/home/starjjbang/Storage/part1/SAAVpedia/data/ontology/efo.obo'

efo = get_OBO(of, propagate_relationships = "is_a", extract_tags = "everything")

data(hpo)

tmp1 = rep('NA',nrow(phe_dat))

for(i in 1:nrow(phe_dat))

{

  term = phe_dat[i,41]

  if (is.na(term)==FALSE)

  {

    if(term=="COSMIC"){ tmp1[i] = "cancer"  }

    else if ( grepl('^Orphanet',term)) { tmp1[i] = "rare disease" }

    else if ( grepl('^EFO',term)) 

      {

        p_id =get_term_property(ontology=efo, property="ancestors", term=term, as_names=TRUE)

        if("EFO:0000408" %in% names(p_id)){tmp1[i] = p_id[which(names(p_id) == "EFO:0000408") +1]}

        else if ("EFO:0004725" %in% names(p_id)){tmp1[i] = p_id[which(names(p_id) == "EFO:0004725") +1]}

        else {tmp1[i] = 'ETC'}

        

      }

    else if ( grepl('^HP',term)) 

      {

        if(is.na(hpo$id["HP:0025268"]) == FALSE)

        {

          p_id =get_term_property(ontology=hpo, property="ancestors", term=term, as_names=TRUE)

          if("HP:0000118" %in% names(p_id)){tmp1[i] = p_id[which(names(p_id) == "HP:0000118") +1]}

          else {tmp1[i] = 'ETC'}          

        }

      }

    else {tmp1[i] = 'ETC'}

  }

 }



https://cran.r-project.org/web/packages/ontologyIndex/vignettes/intro-to-ontologyX.html


Posted by jjbang
|