From a5d64f237d64020fb545fdf0fba789b661fb5a75 Mon Sep 17 00:00:00 2001 From: Rmomal <rmomaleisenring@gmail.com> Date: Fri, 13 Dec 2024 17:20:16 +0100 Subject: [PATCH] Fix for incompatibility with PLNmodels latest release --- .Rprofile | 2 +- .gitignore | 1 + DESCRIPTION | 26 +++++++---- R/F_inference.R | 4 +- README.Rmd | 6 +-- README.md | 6 +-- cran-comments.md | 15 +++--- dev_history.R | 7 +-- docs/.DS_Store | Bin 8196 -> 8196 bytes tests/.DS_Store | Bin 8196 -> 8196 bytes tests/testthat/test-F_Graphs.R | 2 - tests/testthat/test-F_inference.R | 2 - tests/testthat/test-test_gener_data.R | 1 - vignettes/.DS_Store | Bin 0 -> 6148 bytes vignettes/Fatala_Net.Rmd | 3 -- vignettes/Partial_correlations.Rmd | 65 ++++++++++++++++++++++++++ 16 files changed, 105 insertions(+), 35 deletions(-) create mode 100644 vignettes/.DS_Store create mode 100644 vignettes/Partial_correlations.Rmd diff --git a/.Rprofile b/.Rprofile index cae50de..a9fbfb2 100644 --- a/.Rprofile +++ b/.Rprofile @@ -1 +1 @@ -options(repos=structure(c(CRAN="http://cran.us.r-project.org"))) +options(repos=structure(c(CRAN="https://cloud.r-project.org/"))) diff --git a/.gitignore b/.gitignore index 138866d..44ac001 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .Ruserdata inst/doc docs +dev_history.R diff --git a/DESCRIPTION b/DESCRIPTION index edaacc3..45db86c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,37 +2,45 @@ Type: Package Package: EMtree Title: Infers Direct Species Association Networks using Tree Averaging Version: 1.1.0 -Author: Raphaelle Momal <rmomaleisenring@gmail.com> -Maintainer: Raphaelle Momal <rmomaleisenring@gmail.com> -Description: Uses averages over spanning trees within an Expectation Maximization algorithm to infer conditional dependence networks. Involves plotting functionalities. +Authors@R: c( + person("Raphaëlle", "Momal", role = c("aut", "cre","cph"), email = "rmomaleisenring@gmail.com", + comment = c(ORCID = "0000-0002-1550-4530"))) +Description: The spanning tree averaging within an Expectation-Maximization algorithm + (Momal, Robin and Ambroise, 2020 <doi:10.1111/2041-210X.13380>) leverages the + Matrix Tree Theorem to infer conditional dependence networks, such as direct species association + networks. License: GPL-3 Imports: dplyr, ggplot2, ggraph, huge, - influenceR, magrittr, Matrix, mvtnorm, parallel, PLNmodels, - purrr, tibble, tidygraph, - tidyr, vegan, + gridExtra, + pillar, ade4, - gridExtra + viridis, + gmp Suggests: testthat (>= 2.1.0), knitr, rmarkdown, networkD3, + pROC, + tidyr, RColorBrewer Encoding: UTF-8 -LazyData: false -RoxygenNote: 7.1.1 +LazyData: true +RoxygenNote: 7.3.2 +Depends: R (>= 3.5) VignetteBuilder: knitr URL: https://rmomal.github.io/EMtree/ BugReports: https://github.com/Rmomal/EMtree/issues +Language: en-US diff --git a/R/F_inference.R b/R/F_inference.R index 378e80c..7141f64 100644 --- a/R/F_inference.R +++ b/R/F_inference.R @@ -410,8 +410,8 @@ ResampleEMtree <- function(counts,covar_matrix=NULL, unlinked=NULL, #- parallel computation of S fits of new_EMtree if(is.null(user_covariance_estimation)){ suppressWarnings( - PLNfit <- PLNmodels::PLN(counts ~ -1 + offset(log(O)) + ., - data=data.frame(X),control=list("trace"=0)) + PLNfit <- PLNmodels::PLN(formula=counts ~ -1 + offset(log(O)) + ., + data=data.frame(X),control=PLN_param(trace=0)) )} obj<-parallel::mclapply(1:S,function(b){ if(init){ diff --git a/README.Rmd b/README.Rmd index 23f9080..bbf01b0 100644 --- a/README.Rmd +++ b/README.Rmd @@ -28,9 +28,9 @@ By default, it uses the Poisson log-Normal Model ([PLNmodels](https://github.com ### CRAN dependencies ```{r,eval=FALSE} -required_CRAN <- c("Matrix", "purrr","parallel", "mvtnorm", "vegan","huge", - "ggplot2", "magrittr", "dplyr","tidyr", "tibble", - "PLNmodels","ggraph", "tidygraph", "ade4") +required_CRAN <- c("Matrix", "parallel", "mvtnorm", "vegan", + "ggplot2", "magrittr", "dplyr", "tibble", + "PLNmodels","ggraph", "tidygraph","huge") not_installed_CRAN <- setdiff(required_CRAN, rownames(installed.packages())) if (length(not_installed_CRAN) > 0) install.packages(not_installed_CRAN) ``` diff --git a/README.md b/README.md index 205e588..b8e6b64 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ copulas, or Gaussian data transformations. ### CRAN dependencies ``` r -required_CRAN <- c("Matrix", "purrr","parallel", "mvtnorm", "vegan","huge", - "ggplot2", "magrittr", "dplyr","tidyr", "tibble", - "PLNmodels","ggraph", "tidygraph", "ade4") +required_CRAN <- c("Matrix", "parallel", "mvtnorm", "vegan", + "ggplot2", "magrittr", "dplyr", "tibble", + "PLNmodels","ggraph", "tidygraph","huge") not_installed_CRAN <- setdiff(required_CRAN, rownames(installed.packages())) if (length(not_installed_CRAN) > 0) install.packages(not_installed_CRAN) ``` diff --git a/cran-comments.md b/cran-comments.md index aee4e45..a2e7020 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,10 +1,13 @@ ## Test environments -* local R installation, R 4.0.2 -* ubuntu 16.04 (on travis-ci), R 4.0.2 -* win-builder (devel) +- R-hub fedora-clang-devel (r-devel) +- R-hub windows-x86_64-devel (r-devel) +- R-hub macos-highsierra-release (r-release) ## R CMD check results +> On fedora-clang-devel (r-devel), windows-x86_64-devel (r-devel) + checking CRAN incoming feasibility ... NOTE + Maintainer: ‘Raphaelle Momal <rmomaleisenring@gmail.com>’ + + New submission -0 errors | 0 warnings | 1 note - -* This is a new release. +0 errors ✓ | 0 warnings ✓ | 1 note x diff --git a/dev_history.R b/dev_history.R index a070827..cc5d078 100644 --- a/dev_history.R +++ b/dev_history.R @@ -13,6 +13,7 @@ attachment::att_to_description() use_build_ignore("dev_history.R") usethis::use_vignette("Fatala_Net","Fatala fishes") +usethis::use_vignette("Partial_correlations","Partial correlations") pkgdown::build_site() # workflow @@ -44,14 +45,14 @@ covr::report() results <- rhub::check_for_cran(platforms=c("fedora-clang-devel", "windows-x86_64-devel", "macos-highsierra-release")) - +results2 <- rhub::check_for_cran() # Get the summary of your results -results$cran_summary() +results2$cran_summary() # Generate your cran-comments.md, then you copy-paste the output from the function above usethis::use_cran_comments() devtools::check_win_devel() usethis::use_news_md(open = rlang::is_interactive()) - +devtools::release() diff --git a/docs/.DS_Store b/docs/.DS_Store index 2adaebd44dd0132e82dc41dcfb866a092674d638..d6253b8153e26b98e45a5e0424fcb2d6f1130ad9 100644 GIT binary patch delta 195 zcmZp1XmQveD#)zRRy}#6u=r+uK_ynUhH?(U!;V0{$mDD>J|wO{L55*)a(-?B0|+P< yFo4x;7t?1}_J1__rI-q9Lm^P>WFc`?D9c7%g-K<?#KNVU*(JQ#kc^_5$%_DK06M?` delta 195 zcmZp1XmQveD#$GC**JNlu=r+uK_yl;2K!$bha7=?k;&O&d`Mh@f(*mp<ow(M1`rT# wU;wMxE~d{cX1!qYOEDEzu-3^!;;K-VjkpSvxWdH3rJLC$yx5S8qMFHz0Ac(+SO5S3 diff --git a/tests/.DS_Store b/tests/.DS_Store index 6930394dd13dc9e9de40837b7596bb1f7600e83b..7ca28c76a1ed5e4e9724f889e0bddab1265914d6 100644 GIT binary patch delta 121 zcmZp1XmQveCdj07dh$kL@y+^zN~~-Qf(OJ7I|BJ4le5M6S>Zf^f(*mp<ow(M1~4dK Q04dqLU2GOR$y$6F0i|XmZ~y=R delta 121 zcmZp1XmQveCdi~5IeDY7_-1`UC04eE$G0;MIRg12le5M6SzB*Gc>)C)hQZ1CxdjYh TkiY;^vU$7MEOwH$_%Z?j)*C1f diff --git a/tests/testthat/test-F_Graphs.R b/tests/testthat/test-F_Graphs.R index d6c54f1..6283a30 100644 --- a/tests/testthat/test-F_Graphs.R +++ b/tests/testthat/test-F_Graphs.R @@ -4,9 +4,7 @@ library(PLNmodels) library(parallel) library(tidygraph) library(ggraph) -library(purrr) library(dplyr) -library(tidyr) library(gridExtra) ########################## n<-30 diff --git a/tests/testthat/test-F_inference.R b/tests/testthat/test-F_inference.R index 73bdb0f..53c78f2 100644 --- a/tests/testthat/test-F_inference.R +++ b/tests/testthat/test-F_inference.R @@ -6,8 +6,6 @@ library(dplyr) library(vegan) library(Matrix) library(mvtnorm) -library(tidyr) -library(EMtree) ########################## n<-30 p<-10 diff --git a/tests/testthat/test-test_gener_data.R b/tests/testthat/test-test_gener_data.R index 065372a..15a435a 100644 --- a/tests/testthat/test-test_gener_data.R +++ b/tests/testthat/test-test_gener_data.R @@ -6,7 +6,6 @@ library(dplyr) library(vegan) library(Matrix) library(mvtnorm) -library(tidyr) library(EMtree) ########################## n<-100 diff --git a/vignettes/.DS_Store b/vignettes/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0b4ac769b968835370123433edcab35788f6392e GIT binary patch literal 6148 zcmeHK!AiqG5S^{1M7+eC$NWP5f>@$QFFi}OX=;Up6s%s|pV1%jNBj^EzS$W<W2^=R z5t)J6m(0$~X5K<3OGIvRw-^(}L=?dp2m2U4FrH`c*gzvZ>B2Kgx}q7KQ$d?fwgvv8 z0<!sM*tZRQd;eyXBa+jKit>6q&Fg9{1za2hWBP(q)mb(#>p60Hjr-{E`J^9j@h#qZ zwf&ABOYMBeCEcLXf^J)Njh-I+aNgDR@EU(wSF=`Cx9aN6Yt=P+;kwLB0aL&f_^ATu z*=*5)ppB-0DPRgT3h?(KfitFxUNC$*FoYujaENd)T=Q9iIf-Jb=mjwYb3z3Q)#(w# z2_5l7^HN1GD0Fgq_;9+i(-VpdtK<1eNGF#H+Gq-x0&NBM<TmF1f4ckp-zM3eDPRix zD+Syzn`RS~q`kFM9QWD;ehFveJTKT#a1mNDa=8^B!Gj^5@C7hc^n!@M>_;HTV1p^} Hs|vgUpHyPn literal 0 HcmV?d00001 diff --git a/vignettes/Fatala_Net.Rmd b/vignettes/Fatala_Net.Rmd index 8434edc..f3bed38 100644 --- a/vignettes/Fatala_Net.Rmd +++ b/vignettes/Fatala_Net.Rmd @@ -208,6 +208,3 @@ forceNetwork(Links = graph_d3$links, Nodes =graph_d3$nodes, Source = 'source', Target = 'target', NodeID = 'name', Group = 'group',opacity = 1,fontSize = 15, legend=TRUE) ``` - - - diff --git a/vignettes/Partial_correlations.Rmd b/vignettes/Partial_correlations.Rmd new file mode 100644 index 0000000..c6788c7 --- /dev/null +++ b/vignettes/Partial_correlations.Rmd @@ -0,0 +1,65 @@ +--- +title: "Partial correlations" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Partial correlations} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + cache=TRUE +) +library(ggplot2) +library(dplyr) +library(tidyr) +library(magrittr) +``` + +```{r setup} +library(EMtree) +``` + +# Partial correlations simulation + +```{r} +set.seed(1) +p=300 +n=400 +simulation<-data_from_scratch(type="erdos",p=p,n=n,signed=TRUE, dens=3/p) +G=1*(simulation$omega!=0) ; diag(G) = 0 +draw_network(G, remove_isolated = TRUE, pal_edges = "gray70",pal_nodes = "steelblue",btw_rank = 1)$G +``` +simulated partial correlation matrix : +```{r} +ParCor <- - cov2cor(simulation$omega) +``` + +```{r} +ParCor %>% ToVec() %>% as_tibble() %>% filter(value!=0) %>% + ggplot(aes(value))+geom_histogram(alpha=0.8)+ + theme_light()+labs(title="Repartition of non-nul partial correlations", + x="Partial correlation values") + +``` + + +# Inference + +```{r} +EMtreefit<-ResampleEMtree(simulation$data,S = 30,cores = 3) +stab_selection=StATS(EMtreefit$Pmat, nlambda=50, stab.thresh=0.8,plot=TRUE) +``` + +```{r} +net90=ToSym(1*(stab_selection$freqs_opt>0.95)) +table(net90, G) +library(PRROC) +pr<-pr.curve(scores.class0 = stab_selection$freqs_opt, + scores.class1 = ToVec(G)) +pr +``` +