waldronlab / bugphyzz

Harmonized annotation of microbial physiology

Home Page:http://waldronlab.io/bugphyzz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

makeSignatures returns a null list

JonathanYe3 opened this issue · comments

@sdgamboa When you get the chance, could you please take a look at makeSignatures? It seems broken to me because our example returns a null list, no signatures. Below are a couple of reprexes. The first demonstrates the example given in the function documentation. The second example flags df[filter_rows, select cols]. I would give fixing it a shot, but I feel that you know this function best.

library(bugphyzz)
aer <- bugphyzz::physiologies("aerophilicity")[[1]]
#> Finished aerophilicity
aer_signatures <- bugphyzz::makeSignatures(aer)
#> No signatures found.

Created on 2022-07-29 by the reprex package (v2.0.1)

library(dplyr)
sigs <- bugphyzz::physiologies(c("gram stain", "aerophilicity", "butyrate producing")) %>% 
      bugphyzz::makeSignatures()
#> Finished aerophilicity
#> Dropped 4 rows with missing Attribute_value from butyrate producing
#> Finished gram stain
#> Error in df[filter_rows, select_cols]: incorrect number of dimensions

Created on 2022-07-29 by the reprex package (v2.0.1)

@JonathanYe3, the input should be a data frame from bugphyzz, not a list. I added a more informative error (see below). Regardless, I updated the makeSignatures function to match the new colnames (frequency) in bugphyzz (that's why no signatures were found in the first example).

suppressMessages({
    library(bugphyzz)
    library(dplyr)
    data <-  physiologies(c("gram stain", "aerophilicity", "butyrate producing")) 
})

sigs <- lapply(data, makeSignatures) %>% 
    unlist(recursive = FALSE)

lapply(sigs, head)
#> $aerophilicity.aerobic
#> [1] "291967" "291968" "329726" "435"    "178900" "146475"
#> 
#> $aerophilicity.Aerobic
#> [1] "108980"  "70346"   "52133"   "1776742" "79912"   "65497"  
#> 
#> $aerophilicity.anaerobic
#> [1] "1427378" "33951"   "558418"  "28186"   "574087"  "49894"  
#> 
#> $aerophilicity.Anaerobic
#> [1] "1658"   "181487" "272548" "52768"  "52769"  "52770" 
#> 
#> $`aerophilicity.facultatively anaerobic`
#> [1] "2147"   "441768" "12914"  "933801" "507753" "243159"
#> 
#> $aerophilicity.microaerophilic
#> [1] "46352"  "572480" "12960"  "418699" "6"      "191"   
#> 
#> $aerophilicity.Microaerophilic
#> [1] "675090"  "999183"  "1302235" "1315211" "28197"   "28198"  
#> 
#> $`aerophilicity.obligately aerobic`
#> [1] "442869" "434"    "222"    "33973"  "110934" "160700"
#> 
#> $`aerophilicity.obligately anaerobic`
#> [1] "258514" "31980"  "35829"  "186831" "239759" "151038"
#> 
#> $`butyrate producing.Butyrate-Producing Bacteria`
#> [1] 105834 105835 105833 105832 360807 411490
#> 
#> $`gram stain.gram stain negative`
#> [1] 2867376 2282743 2282742 2282740 2211639 2211637
#> 
#> $`gram stain.gram stain positive`
#> [1] 2759766 2040476 1940395 1930795 1918542 1918536
#> 
#> $`gram stain.gram stain variable`
#> [1] 1943561 1649459 1494958  758601  265488  265487


## Error if list is used
makeSignatures(data)
#> Error: Input should be a data frame imported from bugphyzz, not an object of class list.

Created on 2022-08-01 by the reprex package (v2.0.1)

Ah I see, thank you so much Samuel!