Skip to content

Commit

Permalink
Fix for incompatibility with PLNmodels latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
Rmomal committed Dec 13, 2024
1 parent 0358eb8 commit a5d64f2
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .Rprofile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
options(repos=structure(c(CRAN="http://cran.us.r-project.org")))
options(repos=structure(c(CRAN="https://cloud.r-project.org/")))
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.Ruserdata
inst/doc
docs
dev_history.R
26 changes: 17 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,45 @@ Type: Package
Package: EMtree
Title: Infers Direct Species Association Networks using Tree Averaging
Version: 1.1.0
Author: Raphaelle Momal <[email protected]>
Maintainer: Raphaelle Momal <[email protected]>
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 = "[email protected]",
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
4 changes: 2 additions & 2 deletions R/F_inference.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
15 changes: 9 additions & 6 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

New submission

0 errors | 0 warnings | 1 note

* This is a new release.
0 errors ✓ | 0 warnings ✓ | 1 note x
7 changes: 4 additions & 3 deletions dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Binary file modified docs/.DS_Store
Binary file not shown.
Binary file modified tests/.DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions tests/testthat/test-F_Graphs.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ library(PLNmodels)
library(parallel)
library(tidygraph)
library(ggraph)
library(purrr)
library(dplyr)
library(tidyr)
library(gridExtra)
##########################
n<-30
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-F_inference.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ library(dplyr)
library(vegan)
library(Matrix)
library(mvtnorm)
library(tidyr)
library(EMtree)
##########################
n<-30
p<-10
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-test_gener_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ library(dplyr)
library(vegan)
library(Matrix)
library(mvtnorm)
library(tidyr)
library(EMtree)
##########################
n<-100
Expand Down
Binary file added vignettes/.DS_Store
Binary file not shown.
3 changes: 0 additions & 3 deletions vignettes/Fatala_Net.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```



65 changes: 65 additions & 0 deletions vignettes/Partial_correlations.Rmd
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit a5d64f2

Please sign in to comment.