Default
Get
Set
Direct
Rule
Get
Set
Change style by attribute
In this section, you can learn how to apply default style or your original style. And you can also understand how to apply descrete or continuous mapping.
In [ ]:
In [2]:
# import library
library(RCy3)
library(igraph)
# import utility
source("../../utility/import.R")
# first, delete existing windows to save memory:
deleteAllWindows(CytoscapeConnection())
# create graph class
g <- new ('graphNEL', edgemode='directed')
edgeDataDefaults(g, attr = "edgeType") <- "undefined"
attr(edgeDataDefaults(g, attr = "edgeType"), "class") <- "STRING"
# Load Data
gal.matrix <- sifDataToMatrix('../sampleData/galFiltered.sif')
# Get NodesVec
gal.table.nodevec <- unique(c(gal.matrix[,1], gal.matrix[,3]))
# add nodes to graph
for(node in gal.table.nodevec){
g <- graph::addNode(node, g)
}
# get EdgeList and type
gal.table.fromvec <- gal.matrix[,1]
gal.table.type <- gal.matrix[,2]
gal.table.tovec <- gal.matrix[,3]
for (index in 1:length(gal.table.fromvec)){
g <- graph::addEdge (gal.table.fromvec[[index]] ,gal.table.tovec[[index]], g)
edgeData(g, gal.table.fromvec[[index]] ,gal.table.tovec[[index]], "edgeType") <- gal.table.type[[index]]
}
# show it in cytescape
cw <- CytoscapeWindow('vignette', graph=g, overwrite=TRUE)
displayGraph (cw)
layoutNetwork (cw, layout.name='degree-circle')
In [3]:
getVisualStyleNames(cw)
In [4]:
# apply 'Minimal' style
setVisualStyle(cw, 'Minimal')
# Show it
# TODO : I don't know why this method is not available. So I have to find it.
# print(saveImage(cw, 'sampleImage', 'pdf', 2.0))
# The following code is available
file.name <- paste (getwd (), 'resultImage' ,'applyMinimalStyle' , sep= '/' )
image.type <- 'png'
resource.uri <- paste(cw@uri,
pluginVersion(cw), "networks", as.character(cw@window.id),
paste0("views/first.", image.type),
sep="/")
request.res <- GET(resource.uri, write_disk(paste0(file.name,".", image.type), overwrite = TRUE))
In [5]:
# apply 'Gradient1' style
setVisualStyle(cw, 'Gradient1')
# Show it
# TODO : I don't know why this method is not available. So I have to find it.
# print(saveImage(cw, 'sampleImage', 'pdf', 2.0))
# The following code is available
file.name <- paste (getwd (), 'resultImage' ,'applyGradient1Style' , sep= '/' )
image.type <- 'png'
resource.uri <- paste(cw@uri,
pluginVersion(cw), "networks", as.character(cw@window.id),
paste0("views/first.", image.type),
sep="/")
request.res <- GET(resource.uri, write_disk(paste0(file.name,".", image.type), overwrite = TRUE))
In [6]:
# Get all visual propeties
print(getDirectlyModifiableVisualProperties(cw))
In [7]:
# Get node visual propeties
all_visual_propeties = getDirectlyModifiableVisualProperties(cw)
# Show it
print(all_visual_propeties[grep("^NODE.*", all_visual_propeties)])
In [10]:
# Get edge visual propeties
all_visual_propeties = getDirectlyModifiableVisualProperties(cw)
# Show it
print(all_visual_propeties[grep("^EDGE.*", all_visual_propeties)])
In [11]:
# Get network visual propeties
all_visual_propeties = getDirectlyModifiableVisualProperties(cw)
# Show it
print(all_visual_propeties[grep("^NETWORK.*", all_visual_propeties)])
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: