Skip to content

Commit

Permalink
update mh
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Aug 15, 2024
1 parent c5a83e4 commit 7fc9a09
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion mh-mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,44 @@
#


read.sssom <- function(file) {
read.delim(file, comment.char = "#")
}



dir <- 'mh_mapping_initiative/mappings'


hpo2do <- read.sssom(file.path(dir, 'hp_doid_pistoia.sssom.tsv'))

hpo2do <- hpo2do[, c(1,3)] |>
setNames(c("HPO", "DO")) |>
unique()

dim(hpo2do)
head(hpo2do)


hpo2omim <- read.sssom('phenotype.hpoa')[, c("hpo_id", "database_id")] |>
setNames(c("hpo_id", "omim_id"))
do2omim <- read.sssom("OMIMinDO.tsv")[, c("id", "xrefs")] |>
setNames(c("do_id", "omim_id"))
do2omim[,2] <- sprintf("O%s", do2omim[,2])
head(do2omim)

# too large, the relationship may not true
hpo2do2 <- merge(hpo2omim, do2omim, by='omim_id')[,c("hpo_id", "do_id")] |> unique()





read_mpo2hpo <- function(dir) {
ff <- list.files(path=dir, pattern="^mp_hp", full.names=TRUE)

res <- lapply(ff, function(f) {
x <- read.delim(f, comment.char="#")
x <- read.sssom(f)
x <- x[, c("subject_id", "object_id")]
x <- x[x[,1] != "sssom:NoTermFound", ]
x <- x[x[,2] != "sssom:NoTermFound", ]
Expand Down

0 comments on commit 7fc9a09

Please sign in to comment.