R/002_vtable.ON.nodeDegree.R

Defines functions vtable.ON.nodeDegree

Documented in vtable.ON.nodeDegree

#' Provide a table with nodes, extracted from a given graph objects based on node degree
#'
#' This funtion allows to extract a graph object and create a table with nodes, based on node degree. Table also include taxonomic information
#' as well as network attributes such as node degree (nd) or size (frequence of observation). Output table is ordered from highest to lowest node degree
#' @param net.grph is a graph object
#' @param sel.tax is a file containing taxonomic information or metafile that describe nodes attributes
#' @keywords mothur, shared, igraph
#' @export
#' @examples
#' nodes_info_basedon_nodedegree <- vtable.ON.nodeDegree(net.grph, sel.tax)


# funtion allows one to make a table using a graph object based on the node degree --ordered from higherest node degree to teh lowest
vtable.ON.nodeDegree <- function(graph_object = net.grph, selected_taxonomy = sel.tax){
  aa <- data.frame(node = V(net.grph)$name, nd = degree(net.grph))
  bb <- aa[order(aa$nd, decreasing = T), ]
  test<-sel.tax[rownames(sel.tax) %in% rownames(bb),]
  kkk <-test[rownames(bb),,drop=FALSE]
  ddd <- cbind(bb,kkk)
  return(ddd)
}
ravinpoudel/myFunctions documentation built on May 9, 2020, 7:39 a.m.