snystrom / memes

An R interface to the MEME Suite
https://snystrom.github.io/memes/
Other
44 stars 5 forks source link

TomTom error with HOCOMOCOv11 mouse database #111

Open j-andrews7 opened 1 year ago

j-andrews7 commented 1 year ago

When using streme output, it seems some databases throw an error due to a missing column that's expected.

hocomoco.dn <- runTomTom(streme_out[[1]], database = "../motif_databases/MOUSE/HOCOMOCOv11_core_MOUSE_mono_meme_format.meme", 
    outdir = "./motifs/de_novo/tomtom/hocomocov11_decreased_K27M")
Error in `dplyr::mutate()`:
ℹ In argument: `match_motif = purrr::pmap(...)`.
Caused by error in `.data$alt`:
! Column `alt` not found in `.data`.

Other databases (JASPAR2022_CORE_vertebrates_non-redundant_v2.meme, for instance) run fine.

snystrom commented 1 year ago

Ah yeah. I can work on a fix probably this weekend (sorry for the delay). In the mean time, you could do something like:

library(universalmotif)

read_meme("../motif_databases/MOUSE/HOCOMOCOv11_core_MOUSE_mono_meme_format.meme") %>%
  to_df() %>%
  mutate(altname = dplyr::row_number()) %>%
  to_list() %>%
  write_meme("your_db_file_with_altnames.meme")

Or if you prefer a non-tidy style method:

library(universalmotif)
db <- read_meme("/path/to/db.meme")
db["altname"] <- seq_along(db)
write_meme(db, "your_db_with_altname.meme")

You'll have to forgive me if there are some code errors above, cause I wrote this from memory quickly.

snystrom commented 1 year ago

Oh and even more alternatively, since you'd be reading the db into memory at this point anyway, you could pass the corrected db object directly to runTomTom(database = db).

j-andrews7 commented 1 year ago

Thanks. Worked with:

db <- read_meme("../motif_databases/MOUSE/HOCOMOCOv11_core_MOUSE_mono_meme_format.meme")
db <- lapply(seq_along(db), function(x) {
  y <- db[[x]]
  y@altname <- as.character(x)
  y
})

Edit: this actually works better for this specific database and keeps them all as one database:

db <- read_meme("/hpcf/authorized_apps/rhel8_apps/meme/install/5.5.4/share/meme-5.5.4/db/motif_databases/MOUSE/HOCOMOCOv11_core_MOUSE_mono_meme_format.meme") %>%
  to_df()

db$altname <- unlist(strsplit(db$name, "_"))[c(TRUE, FALSE)]