diff --git a/DESCRIPTION b/DESCRIPTION index a353311..86c99a6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,15 +20,15 @@ Depends: deSolve (>= 1.12), Matrix (>= 1.2) Imports: - glpkAPI, + igraph, methods, utils, stats, graphics, Rcpp Suggests: + glpkAPI, sybilSBML, - igraph, knitr, rmarkdown LinkingTo: Rcpp, diff --git a/NAMESPACE b/NAMESPACE index 88b73ca..05b36e2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,6 +27,7 @@ export(diffuseR) export(emptyHood) export(evalArena) export(extractMed) +export(findFeeding) export(flushSubs) export(getArena) export(getCorrM) @@ -77,6 +78,7 @@ exportMethods(diffuseR) exportMethods(emptyHood) exportMethods(evalArena) exportMethods(extractMed) +exportMethods(findFeeding) exportMethods(flushSubs) exportMethods(getArena) exportMethods(getCorrM) @@ -112,6 +114,15 @@ importFrom(graphics,par) importFrom(graphics,points) importFrom(graphics,segments) importFrom(graphics,text) +importFrom(igraph,E) +importFrom(igraph,V) +importFrom(igraph,add.edges) +importFrom(igraph,degree) +importFrom(igraph,delete.edges) +importFrom(igraph,delete.vertices) +importFrom(igraph,graph.empty) +importFrom(igraph,layout_with_fr) +importFrom(igraph,vcount) importFrom(stats,cor) importFrom(stats,dist) importFrom(stats,hclust) diff --git a/NEWS b/NEWS index de5f59a..25ce8c0 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -BacArena v1.0.1 (Release date: 2016-01-05) +BacArena v1.0.1 (Release date: 2016-01-06) ============= Changes: diff --git a/R/Arena.R b/R/Arena.R index 4cbf6b4..eb8a2c8 100644 --- a/R/Arena.R +++ b/R/Arena.R @@ -1496,16 +1496,18 @@ setMethod("statPheno", "Eval", function(object, type_nr=1, phenotype_nr, dict=NU #' @description The generic function \code{findFeeding} #' @export #' @rdname findFeeding -#' @import igraph +#' @importFrom igraph graph.empty add.edges delete.edges delete.vertices V E degree vcount layout_with_fr +#' +#' @param object An object of class Eval. #' @param tcut Integer giving the minimal mutual occurence ot be considered (dismiss very seldom feedings) #' @param scut List of substance names which should be ignored #' @param legendpos A character variable declaring the position of the legend #' @param dict List defining new substance names. List entries are intepreted as old names and the list names as the new ones. #' @return Graph (igraph) #' +setGeneric("findFeeding", function(object, dict=NULL, tcut=5, scut=list(), legendpos="topleft"){standardGeneric("findFeeding")}) #' @export #' @rdname findFeeding -setGeneric("findFeeding", function(object, dict=NULL, tcut=5, scut=list(), legendpos="topleft"){standardGeneric("findFeeding")}) setMethod("findFeeding", "Eval", function(object, dict=NULL, tcut=5, scut=list(), legendpos="topleft"){ # possible problem inactive phenotype is not mentioned in object@phenotypes... @@ -1554,8 +1556,8 @@ setMethod("findFeeding", "Eval", function(object, dict=NULL, tcut=5, scut=list() # graph pindex <- rownames(mat_phen)# phenotype index cindex <- colnames(res) # substance color index - g <-graph.empty(n=length(pindex), directed=TRUE) - V(g)$name <- gsub("pheno","",pindex) + g <-igraph::graph.empty(n=length(pindex), directed=TRUE) + igraph::V(g)$name <- gsub("pheno","",pindex) # 3) Combinatorics: check for all pairs of phenotypes if they @@ -1580,7 +1582,7 @@ setMethod("findFeeding", "Eval", function(object, dict=NULL, tcut=5, scut=list() new_edge <- c(which(pindex==combi[,i][1]), which(pindex==combi[,i][2])) }else new_edge <- c(which(pindex==combi[,i][2]), which(pindex==combi[,i][1])) col <- colpal3[which(cindex == colnames(feeding)[x])] - g <<- add.edges(g, new_edge, color=col, weight=length(co_occ)) + g <<- igraph::add.edges(g, new_edge, color=col, weight=length(co_occ)) }) } #cat("\npossible cross feeding at time steps\n") @@ -1590,11 +1592,11 @@ setMethod("findFeeding", "Eval", function(object, dict=NULL, tcut=5, scut=list() } } - g <- delete.edges(g, which(E(g)$weight= 2){ - plot(g, layout=layout_with_fr, vertex.size=5, + if(igraph::vcount(g) >= 2){ + plot(g, layout=igraph::layout_with_fr, vertex.size=5, edge.arrow.size=0.3, edge.width=E(g)$weight/10) legend(legendpos,legend=cindex, col=colpal3, pch=19, cex=0.7) } diff --git a/R/Stuff.R b/R/Stuff.R index e04a7f2..0eb1b75 100644 --- a/R/Stuff.R +++ b/R/Stuff.R @@ -120,13 +120,15 @@ estimate_lrw <- function(grid_n, grid_m){ #' #' @return Returns an object of class \code{Eval} which can be used for subsequent analysis steps. #' @examples +#' \donttest{ #' sim <- openArena() #' evalArena(sim, time=7, phencol = TRUE, #' plot_items=c("Population", "EX_o2(e)", "EX_for(e)", #' "EX_glc(e)", "EX_for(e)")) +#'} openArena <- function(){ data(Ec_core, envir = environment()) - bac = Bac(model=Ec_core, growtype="exponential") + bac = Bac(model=Ec_core, type="E. coli") arena = Arena(n=50, m=50, stir=F, Lx=0.0125, Ly=0.0125) addOrg(arena, bac, amount=50) addSubs(arena, smax=0, difspeed=6.7e-6) diff --git a/README.md b/README.md index 800e9a9..5b0679f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Existing genome-scale metabolic models can be used to simulate growth and intera In BacArena two well established methods are merged: a) Flux balance analysis to predict the activity of metabolic reactions and b) Agent based modelling in order to provide an environment. -It has been efficiently implemented in R language (with some C++ routines) and is freely available [CRAN](https://cran.r-project.org/web/packages/BacArena/index.html). +It has been efficiently implemented in R language (with some C++ routines) and is freely available [CRAN](https://cran.r-project.org/package=BacArena). Features: - Each organism is represented individually diff --git a/examples/pao_sim.R b/examples/pao_sim.R index e3b5614..9a121c8 100644 --- a/examples/pao_sim.R +++ b/examples/pao_sim.R @@ -7,7 +7,7 @@ library(RcppArmadillo) library(sybil) library(compiler) setwd("/Users/euba/GitRep/BacArena/") -#setwd("uni/bacarena") +#setwd("~/uni/bacarena") #setwd('P:/GitRep/BacArena') #setwd('P:/GitRep/BacArena')