Skip to content

Commit

Permalink
update igraph deprecated function in trans_network
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiLiubio committed Dec 18, 2024
1 parent 6ee608d commit 31b9591
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/trans_network.R
Original file line number Diff line number Diff line change
Expand Up @@ -1376,12 +1376,12 @@ trans_network <- R6Class(classname = "trans_network",
nodes <- data.frame(cbind(V(network), V(network)$name))
edges <- get.edges(network, 1:ecount(network))
node_attr_name <- setdiff(list.vertex.attributes(network), "name")
node_attr <- data.frame(sapply(node_attr_name, function(attr) sub("&", "&", get.vertex.attribute(network, attr))))
node_attr <- data.frame(sapply(node_attr_name, function(attr) sub("&", "&", vertex_attr(network, attr))))
node_attr$RelativeAbundance %<>% as.numeric
edge_attr_name <- setdiff(list.edge.attributes(network), "weight")
edge_attr <- data.frame(sapply(edge_attr_name, function(attr) sub("&", "&", get.edge.attribute(network, attr))))
edge_attr <- data.frame(sapply(edge_attr_name, function(attr) sub("&", "&", edge_attr(network, attr))))
# combine all graph attributes into a meta-data
graphAtt <- sapply(list.graph.attributes(network), function(attr) sub("&", "&",get.graph.attribute(network, attr)))
graphAtt <- sapply(list.graph.attributes(network), function(attr) sub("&", "&", graph_attr(network, attr)))
output_gexf <- write.gexf(nodes, edges,
edgesLabel = as.data.frame(E(network)$label),
edgesWeight = E(network)$weight,
Expand Down Expand Up @@ -1429,7 +1429,7 @@ trans_network <- R6Class(classname = "trans_network",
},
#compute within-module degree
within_module_degree = function(comm_graph){
mods <- get.vertex.attribute(comm_graph, "module")
mods <- vertex_attr(comm_graph, "module")
if(is.null(mods)){
stop("No modules found! Please first calculate network modules using function cal_module !")
}
Expand Down Expand Up @@ -1463,7 +1463,7 @@ trans_network <- R6Class(classname = "trans_network",
},
#calculate the degree (links) of each node to nodes in other modules
among_module_connectivity = function(comm_graph){
modvs <- data.frame(taxon = V(comm_graph)$name, mod = get.vertex.attribute(comm_graph, "module"), stringsAsFactors = FALSE)
modvs <- data.frame(taxon = V(comm_graph)$name, mod = vertex_attr(comm_graph, "module"), stringsAsFactors = FALSE)
edges <- t(sapply(1:ecount(comm_graph), function(x) ends(comm_graph, x)))
res <- lapply(modvs$taxon, function(x){
sapply(unique(c(edges[edges[, 1] == x, 2], edges[edges[, 2] == x, 1])), function(y){
Expand Down

0 comments on commit 31b9591

Please sign in to comment.