phenoscape / rphenoscape

R package to make phenotypic traits from the Phenoscape Knowledgebase available from within R.
https://rphenoscape.phenoscape.org/
Other
5 stars 5 forks source link

get_char_matrix() error #263

Closed wdahdul closed 1 year ago

wdahdul commented 1 year ago

When using get_char_matrix() to extract the matrix as a data.frame from a NeXML object, I'm getting an error and can't extract the matrix:

lundberg_matrix <- get_char_matrix(lundbergnexml) Warning: `select()was deprecated in dplyr 0.7.0. Please useselect()` instead.Error in slot(node, element) : cannot get a slot ("otus") from an object of type "list"

The above is from running the short course tutorial https://phenoscape.org/scate-shortcourse/articles/01_rphenoscape.html

johnbradley commented 1 year ago

@wdahdul I think lundberg_nexml in your code is a list. Try using lapply to apply get_char_matrix. Something like:

lundberg_matrix <- lapply(lundberg_nexml, function(nex) get_char_matrix(nex))

See the updated example for version 0.3.0: http://rphenoscape.phenoscape.org/articles/rphenoscape.html#character-matrices-for-studies.

wdahdul commented 1 year ago

Thanks John!

hlapp commented 1 year ago

You could also (and it be more straightforward to) just say

lundberg_matrix <- get_char_matrix(lundberg_nexml[[1]])