# create an object of class Onto, only given a matrix
adjM <- matrix(runif(25),nrow=5,ncol=5)
as(adjM, "Onto")
# create an object of class Onto, given a matrix plus information on nodes
# 1) create nodeI: an object of class InfoDataFrame
data <- data.frame(term_id=paste("Term", 1:5, sep="_"),
term_name=I(LETTERS[1:5]), term_namespace=rep("Namespace",5),
term_distance=1:5, row.names=paste("Term", 1:5, sep="_"))
nodeI <- new("InfoDataFrame", data=data)
nodeI
# 2) create an object of class Onto
# VERY IMPORTANT: make sure having consistent names between nodeInfo and adjMatrix
adjM <- matrix(runif(25),nrow=5,ncol=5)
colnames(adjM) <- rownames(adjM) <- rowNames(nodeI)
x <- new("Onto", adjMatrix=adjM, nodeInfo=nodeI)
x
# 3) look at various methods defined on class Onto
dim(x)
adjMatrix(x)
nodeInfo(x)
nInfo(x)
nodeNames(x)
term_id(x)
term_namespace(x)
term_distance(x)
# 4) get the subset
x[1:2]
Run the code above in your browser using DataLab