jorainer / ensembldb

This is the ensembldb development repository.
https://jorainer.github.io/ensembldb
33 stars 10 forks source link

ensembldb and dplyr: filter, select #135

Open Shicheng-Guo opened 2 years ago

Shicheng-Guo commented 2 years ago

Dear ensembldb team,

Both ensembldb and dplyr are widely and frequently used in my analysis, there are several functions are conflicted between ensembldb and dplyr, for example, filter, select. Maybe it will be helpful to think about a solution how to handle them well.

error in evaluating the argument 'x' in selecting a method for function 'select': ensembldb::filter requires an 'EnsDb' object as input. To call the filter function from the stats or dplyr package use stats::filter and dplyr::filter instead.

Thanks.

Shicheng

jorainer commented 2 years ago

Any suggestions (or even better pull request) solving this would be highly appreciated. The problem for me is that both the stats and dplyr packages define filter as a function (and also overwrite each other). A solution using a S4Generic would be maybe cleaner. The only solution I found is the one mentioned by the error message above, i.e. to use the package prefix to use any of the other filter functions that overwrite each other upon package loading (i.e. use dplyr::filter or stats::filter or ensembldb::filter).

cui-shuang commented 1 year ago

Hello,could you say detailed this solution? Can I see your code? "The only solution I found is the one mentioned by the error message above, i.e. to use the package prefix to use any of the other filter functions that overwrite each other upon package loading (i.e. use dplyr::filter or stats::filter or ensembldb::filter)."

cui-shuang commented 1 year ago

The code I run is as follows: Signature <- FeatureSelect.V4(CellLines.matrix = NULL, Heatmap = FALSE, export = TRUE, sigName = "MyReference00", Stroma.matrix = RefData, deltaBeta = 0.2, FDR = 0.01, MaxDMRs = 100, Phenotype.stroma = RefPheno)

Then an error occurs, “Error in filter(., adj.P.Val < FDR) : ensembldb::filter requires an 'EnsDb' object as input. To call the filter function from the stats or dplyr package use stats::filter and dplyr::filter instead.‘

jorainer commented 1 year ago

The FeatureSelect.V4 function is not defined in ensembldb so I can not say how this error was generated or how to solve this. From which package is this function? What might help is to load ensembldb before this other package. That way the filter function of ensembldb will be overwritten.

Example:

library(ensembldb)
library(dplyr)

would cause that dplyr's filter function overwrites the ensembldb filter function. Just calling filter will then use the version of dplyr. If you want to use the filter function from ensembldb you would need to specifically call ensembldb::filter.

cui-shuang commented 1 year ago

Thank you very much for your reply and suggestion. Now the problem has been solved. The R package I used is MethylCIBERSORT. It should be that this package conflicts with other packages. I can run the code after uninstalling dplyr. Thank you again.