NicolasH2 / gggsea

GSEA plots in ggplot2
8 stars 4 forks source link

gseaCurve function throwing a `dplyr::nth()`: error #1

Closed sg3451 closed 1 year ago

sg3451 commented 1 year ago

I am running fgsea and then using gggsea to generate enrichment plots. The fgsea function runs fine and generates the expected output. But when I try to run gseaCurve on the results, I am getting the following error: Error in dplyr::nth(): ! Can't convert from n to due to loss of precision. • Locations: 1

the code I used is given below

----------------------------------------------------------------------------------------------------

run fgsea

fgseaRes = fgsea(pathways = wiki, stats = ranks, eps = 0, minSize = 15, maxSize = 250)

---------------------------------------------------------------------------------------------------------------

see top 6 rows of fgsea output

head(fgseaRes[order(pval),]) pathway pval padj log2err ES NES size 1: WP_CYTOPLASMIC_RIBOSOMAL_PROTEINS 1.447420e-06 0.0006064688 0.6435518 0.5371137 2.041871 86 2: WP_MIRNA_TARGETS_IN_ECM_AND_MEMBRANE_RECEPTORS 1.549642e-04 0.0324649906 0.5188481 -0.7044984 -2.018585 21 3: WP_PI3KAKT_SIGNALING_PATHWAY 5.404412e-04 0.0754816230 0.4772708 -0.3456294 -1.521484 210 4: WP_FOCAL_ADHESION 8.625880e-04 0.0903560961 0.4772708 -0.3736142 -1.577802 156 5: WP_FOCAL_ADHESION_PI3KAKTMTORSIGNALING_PATHWAY 1.350562e-03 0.1042326774 0.4550599 -0.3365220 -1.481279 208 6: WP_OXIDATIVE_PHOSPHORYLATION 1.646682e-03 0.1042326774 0.4550599 0.4791410 1.705835 59 leadingEdge 1: RPL18A,RPS15,RPL29,RPL10,RPS11,RPL28,... 2: COL3A1,COL5A3,THBS2,LAMA4,COL4A1,COL1A2,... 3: PIK3CD,IL7R,PGF,EFNA1,FGF1,KDR,... 4: PIK3CD,PGF,HCK,KDR,COL1A1,ITGA8,... 5: PIK3CD,IL7R,PGF,EFNA1,FGF1,KDR,... 6: NDUFA4L2,NDUFA3,NDUFS7,ATP5F1D,ATP5MC2,NDUFS6,...

-------------------------------------------------------------------------------------------------------------------------

run gggsea

devtools::install_github("nicolash2/gggsea") library(gggsea)

call sorted ranked file and selected pathways file

rl = ranks setlist = wiki[topPathways] res = gseaCurve(rl, setlist, fgseaRes) Error in dplyr::nth(): ! Can't convert from n to due to loss of precision. • Locations: 1 Run rlang::last_error() to see where the error occurred.

backtrace of the error

Backtrace: ▆

  1. └─gggsea::gseaCurve(rl, setlist, fgseaRes)
  2. └─base::mapply(...)
  3. └─gggsea (local) <fn>(set = dots[[1L]][[1L]], setname = dots[[2L]][[1L]])
  4. ├─base::merge(...)
  5. ├─base::merge.data.frame(...)
  6. │ ├─base::nrow(y <- as.data.frame(y))
  7. │ └─base::as.data.frame(y)
  8. └─gggsea:::.colorGradient(rl, lowestPoint, sizeFactor)
  9. ├─base::unlist(...)
  10. └─base::lapply(...)
  11. └─gggsea (local) FUN(X[[i]], ...)
  12. └─*dplyr::nth(sort(abs(rl)), length(rl) x)**
  13. └─vctrs::vec_cast(n, to = integer(), x_arg = "n")
  14. └─vctrs (local) <fn>()
  15. └─vctrs:::vec_cast.integer.double(...)
  16. └─vctrs::maybe_lossy_cast(...)
  17. ├─base::withRestarts(...)
  18. │ └─base (local) withOneRestart(expr, restarts[[1L]])
  19. │ └─base (local) doWithOneRestart(return(expr), restart)
  20. └─vctrs:::stop_lossy_cast(...)
  21. └─vctrs::stop_incompatible_cast(...)
  22. └─vctrs::stop_incompatible_type(...)
  23. └─vctrs:::stop_incompatible(...)
  24. └─vctrs:::stop_vctrs(...)
  25. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
siwei-deng commented 1 year ago

Hi,

I fixed it - please re-install the package using: devtools::install_github("siwei-deng/gggsea")

Best,

NicolasH2 commented 1 year ago

Hi @sg3451 , I implemented siwei-deng's fix into the regular nicolash2/gggsea. Does this fix your problem? Many thanks @siwei-deng for looking into this :) Your help is much appreciated!

Best

sg3451 commented 1 year ago

Hi @sg3451 , I implemented siwei-deng's fix into the regular nicolash2/gggsea. Does this fix your problem? Many thanks @siwei-deng for looking into this :) Your help is much appreciated!

Best

Yes, I just ran it yesterday and it worked perfectly! Thank you very much @siwei-deng and @NicolasH2 for your help. Best