Learn R Programming

RAM (version 1.2.1.3)

network_data: Creates Nodes and Edge-List For An OTU Table

Description

This function creates nodes and edge-list for an otu table, which can be used for network plotting

Usage

network_data(data, is.OTU=TRUE, metadata)

Arguments

data
an otu table of a species abundance matrix
is.OTU
whether or not data is an otu table
metadata
associated metadta of the otu table, should have same sampleIDs

Value

Return a list of network nodes and edges based on an otu table and the associated metadata

Examples

Run this code
data(ITS1, meta)
## Not run: 
# ITS1.01<-filter.OTU(data=list(ITS1=ITS1), percent=0.01)[[1]]
# # create nodes and edges lists
# b<-network_data(ITS1.01, is.OTU=TRUE, meta)
# b_node<-b[[1]]
# b_edge<-b[[2]]
# head(b_node)
# head(b_edge)
# library(igraph)
# b1<-graph.data.frame(b_edge, directed=F)
# lev <- levels(factor(E(b1)$Crop))
# # vertices size
# V(b1)$size<-degree(b1)
# # vertices color
# Crop1<-rownames(meta)[meta$Crop=="Crop1"]
# Crop2<-rownames(meta)[meta$Crop=="Crop2"]
# ## vertices representing samples from crop1 will be in red,
# ## vertices representing samples from crop2 will be in blue;
# ## vertices representing taxa will be in pink
# V(b1)$color<-ifelse((V(b1)$name 
#               ifelse((V(b1)$name 
# # edges color
# col<-c("red", "blue")
# for (i in 1:length(lev) ) { 
#   E(b1)$color[E(b1)$Crop==lev[i]] <- col[i]
# }
# # plot
# plot(b1, vertex.label.font=2,
#          vertex.label.cex=0.5,
#          layout=layout.kamada.kawai)
# ## End(Not run)

Run the code above in your browser using DataLab