/usr/lib/R/site-library/graph/Scripts/Graph.R is in r-bioc-graph 1.56.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ##some new things
library(methods)
library(graph)
library(GO)
library(hgu95a)
xx <- ls(env = hgu95aGO)
set.seed(1234)
myGenes <- sample(xx, 100)
mG <- mget(myGenes, env=hgu95aGO)
makeGoGraph <- function(x) {
library(GO)
newNodes <- get(x, env=hgu95aGO)
if( is.na(x) )
return(NULL)
oldEdges <- vector("list", length=0)
oldNodes <- vector("character", length=0)
done <- FALSE
while( !done ) {
newNodes <- newNodes[!(newNodes %in% oldNodes)]
if( length(newNodes) == 0 )
done <- TRUE
else {
oldNodes <- c(oldNodes, newNodes)
numE <- length(newNodes)
nedges <- vector("list", length=numE)
names(nedges) <- newNodes
nedges <- mget(newNodes, env=GOmolecularfunction)
nedges <- nedges[!is.na(nedges)]
oldEdges <- c(oldEdges, nedges)
newNodes <- sort(unique(unlist(nedges)))
}
}
rE <- vector("list", length=length(oldNodes))
names(rE) <- oldNodes
rE[names(oldEdges)] <- oldEdges
return(list(nodes=oldNodes, edges=rE))
}
Gmf1 <- makeGoGraph(myGenes[1])
##old examples
library(graph)
data(pmedu95aAffy)
pmG <- pmedu95aAffy
edgeL <- lapply(pmG@edges, function(x) list(edges=x))
pmG <- graphNEL(nodes=pmG@nodes, edgeL=edgeL)
xx1<-acc(pmG, "1025_g_at")
xx2<-acc2(pmG, "1025_g_at")
set.seed(12345)
myNodes <- sample(nodes(pmG), 500)
pmS <- makeSubGraph(pmG, myNodes)
xx<- acc(pmS, "35990_at")
xy <- dfs(pmS)
zz <- acc(pmS, "35990_at")
zz2 <- acc(pmS, "35990_at")
pm2 <- makeSubGraph(pmG, myNodes[1:100])
pm3<-isect(pm2, pmS)
##Sept 27 -- trying to test some graph code
#library(methods)
#setwd("c:\\cygwin/home/rgentlem\\Software\\graph\\R")
#source("graph.R")
#.initGraph(globalenv())
x<-1:100
rw <- rep("a", 100)
for(i in 1:100) rw[i] <- paste(sample(letters, 10, replace=TRUE),
sep="", collapse="")
set.seed(121)
##this is a directed graph -- the nodes are one way nodes
y<- vector("list", length=100)
for(i in 1:100) {
nnodes<- floor(runif(1)*20)
y[[i]] <- list(edges=sample(x, nnodes), weights=runif(nnodes))
}
sapply(y, function(x) length(x$weights))
names(y) <- rw
g1 <- graphNEL(nodes=rw, edgeL=y)
z<-lapply(y, function(x) {x$weights<-NULL; x})
g2 <- graphNEL(nodes=rw, edgeL=z)
#get the adjcency list for node number 10
vv<-adj(g1, 10)
#get the accessibility list for node number 10
vw <- acc(g1, 2)
##for an undirected graph we generate a node list for each node
set.seed(333)
y2<- vector("list", length=100)
for(i in 1:100) y2[[i]] <- list(edges=numeric(0), weights=numeric(0))
for(i in 1:100) {
nnodes<- floor(runif(1)*3)
jj<-sample(x, nnodes)
for (j in jj) {
wt <- 18*runif(1)
y2[[i]]$edges <- c(y2[[i]]$edges, j)
y2[[i]]$weights <- c(y2[[i]]$weights, wt)
y2[[j]]$edges <- c(y2[[j]]$edges, i)
y2[[j]]$weights <- c(y2[[j]]$weights, wt)
}
}
g3 <- graphNEL(nodes=rw, edgeL=y2)
b1 <- isect(g1, g3)
sN1 <- sample(1:100, 20)
g4 <- subGraph(g1, sN1)
E1 <- edgeL(g3)
E2 <- edgeL(g3, sN1)
|