Search code examples
rbioconductor

Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure("mmquery_bioc", package = "multiMiR")’ to a data.frame


I'm having trouble getting a table of results.

Command: answer <- get_multimir(url = NULL, org = "hsa", mirna = "MIMAT0000450", target = NULL, disease.drug = "cancer", table = "validated", predicted.cutoff = NULL, predicted.cutoff.type = "p", predicted.site = "conserved", summary = FALSE, add.link = FALSE, use.tibble = TRUE, limit = NULL, legacy.out = FALSE)

When I am trying to create a table using: write.table(answer,"C:\\Users\\Someone\\Desktop\\Rresults\\data.csv", row.names=FALSE)

it results in the following error:

Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure("mmquery_bioc", package = "multiMiR")’ to a data.frame


Solution

  • get_multimir is used to retrieve predicted and validated miRNA-target interactions and their disease and drug associations from the multiMiR package.

    It returns an object of class mmquery_bioc

    The error:

    Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure("mmquery_bioc", package = "multiMiR")’ to a data.frame

    is informing you that R does not know how to convert this object into a data frame.

    It is not completely clear what you are trying to achieve but if I was to take a guess, perhaps you just need the data slot from this object:

    write.table(answer@data,"C:\\Users\\Someone\\Desktop\\Rresults\\data.csv", row.names=FALSE)