tmuetze / Bioconductor_RCy3_the_new_RCytoscape

Update RCytoscape to work for Cytoscape 3.0 and higher using CyREST
16 stars 10 forks source link

several vizProp functions not working #21

Closed m-grimes closed 8 years ago

m-grimes commented 8 years ago

Tanja, Gerogi

I attach rcy2_ rcy3_

a direct comparison of RCy2 and RCy3 graphs.

sessionInfo() R version 3.2.2 (2015-08-14) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.10.5 (Yosemite)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] parallel stats4 grid stats graphics grDevices utils datasets [9] methods base

other attached packages: [1] RCy3_0.99.25 RJSONIO_1.3-0 rgl_0.95.1367
[4] RefNet_1.6.0 ...(same as my recent post).

The setNodeColorRule seems to set some but not all nodes to the yellow color intended (compare the larger nodes, which should be darker yellow). The functions, setNodeBorderWidthRule, edgeColorRule, setEdgeLineWidthRule , setEdgeSourceArrowColorRule, setEdgeTargetArrowColorRule don't work. In addition,

setNodeBorderWidthRule(windowobj, node.attribute.name="nodeType", attribute.values=c("deacetylase","acetyltransferase","demethylase","methyltransferase","membrane protein", "receptor tyrosine kinase", "G protein-coupled receptor"), line.widths=c(6,10,6,10,7,7,7), default.width=1.8) Error. Could not set rule...

undoes all the following vizprops from commands setNodeShapeDirect, setNodeBorderColorDirect (and maybe others).

Also, copyVisualStyle is broken.

copyVisualStyle (windowname, "default", add.style.name) Error in file(con, "r") : cannot open the connection

Hope this gives you enough information. Let me know if not.

Thanks,

Mark

Function to set node size and color:

intensityprops.2 function (windowname, cytoscape.file, plotcol="Total.Phosphorylation") { setVisualStyle (windowname, "default") print (getNodeAttributeNames (windowname)) node.sizes = c (135, 130, 108, 75, 35, 75, 108, 130, 135) Intensity.Values <- cytoscape.file[, plotcol] # set to intensity or normalized intensity maxint <- max(Intensity.Values, na.rm=TRUE) minint <- min(Intensity.Values, na.rm=TRUE) icolors <- c('0099FF', '#007FFF','#00BFFF', '#00CCFF', '00FFFF', '#FFFFFF', '#FFFF7E', '#FFFF00', 'FFE600', 'FFD700', 'FFCC00') displayGraph (windowname)

Some rules to set the color and size depending on the values of intensity

    if (maxint>abs(minint)) {
        setNodeColorRule (windowname, names(cytoscape.file[plotcol]), c (-(maxint+1), -(maxint/5), -(maxint/10), -(maxint_0.045), 0.0, (maxint_0.045), (maxint/10), (maxint/5), (maxint+1)), icolors, mode='interpolate') 
        icontrol.points = c (-(maxint+1), -(maxint_0.3), -(maxint/10), 0.0, (maxint/10), (maxint_0.3), (maxint+1))
        }
    if (maxint<abs(minint)) {
        setNodeColorRule (windowname, names(cytoscape.file[plotcol]), c ((minint-1), (minint/5), (minint/10), (minint_0.045), 0.0, -(minint_0.045), -(minint/10), -(minint/5), -(minint-1)), icolors, mode='interpolate') 
        icontrol.points = c ((minint-1), (minint_0.3), (minint/10), 0.0, -(minint/10), -(minint_0.3), abs(minint-1))
        }
    setNodeSizeRule (windowname, names(cytoscape.file[plotcol]), icontrol.points, node.sizes, mode='interpolate')
    setDefaultNodeSelectionColor (windowname,  "#CC00FF") 
    redraw (windowname)
    return(windowname)

}

Function to set correlation edges style:

corr.edges.style function(windowname, edgefile) {

Set up Cytoscape to make positive correlation yellow, negative blue

    edgeTypes <- c("negative correlation", "positive correlation", "Protein")
    corredgecolors = c('#0000FF', "#FCD116", '#888888') 
        #   blue; sign yellow; gray; 
    myarrows <- c ('No Arrow', 'No Arrow', "No Arrow")
    setDefaultBackgroundColor(cy,'#888888', 'default' )
    # set up (have to make a graph first)
    setEdgeTargetArrowRule(windowname, 'edgeType', edgeTypes, myarrows, default='No Arrow')  
    setEdgeTargetArrowColorRule(windowname, "edgeType",  edgeTypes, corredgecolors, default.color='#FF0000')  
    setEdgeColorRule(windowname, 'edgeType', edgeTypes, corredgecolors, mode='lookup', default.color='#FDF8FF')     # defalult zinc white
    line.widths <- 4.5*abs(as.numeric(edgefile$Weight))
    setEdgeLineWidthRule(windowname, "Weight", attribute.values=as.character(edgefile$Weight), line.widths, default.width=1.2)
    redraw(windowname)
    add.style.name <- paste("Corr Edges Style",length(getWindowList(cy)))
    if (!(add.style.name %in% getVisualStyleNames(cy))) { copyVisualStyle (windowname, "default", add.style.name) }
    hidePanel(cy, "Results")

}

Functions to set node and edge default properties:

nodeDprops.new function (windowobj, cf) { setDefaultBackgroundColor (windowobj, 'E0E0E0') # grey 88 setDefaultNodeShape(windowobj, "ELLIPSE") setDefaultNodeColor (windowobj, '#C9C9C9') # gray 79 setDefaultNodeSize (windowobj, 30) # for grey non-data nodes setDefaultNodeFontSize(windowobj, 20) setDefaultNodeLabelColor(windowobj, '#000000') setDefaultNodeBorderWidth (windowobj, 1.8) setDefaultNodeBorderColor (windowobj, '#888888') # gray setDefaultNodeSelectionColor(windowobj, "#FF3388") molclasses <- c("unknown", "receptor tyrosine kinase", "SH2 protein", "SH3 protein", "tyrosine kinase", "SRC-family kinase", "kinase", "transcription factor", "RNA binding protein")

NOTE getNodeShapes(cy) returns node shapes in random order! Define manually

 #  *12 for RCy2; 9 for RCy3
 # there are now 24 nodeType classes
nodeshapes <- c("ELLIPSE","ROUND_RECTANGLE", "RECTANGLE", "TRIANGLE", "HEXAGON", "DIAMOND", "OCTAGON", "PARALLELOGRAM", "VEE")
if(length(sessionInfo()$otherPkgs$RCy3)==0) {
    nodeshapes <- c("ellipse", "round_rect", "rect", "triangle", "hexagon", "diamond", "octagon", "parallelogram", "vee")}

setNodeShapeRule (windowobj, node.attribute.name="nodeType", attribute.values=molclasses, node.shapes=nodeshapes, default.shape="ELLIPSE") setNodeShapeDirect(windowobj, cf[grep("RNA", cf$nodeType), 1], nodeshapes[9]) setNodeShapeDirect(windowobj, cf[grep("transcription", cf$nodeType), 1], nodeshapes[8]) setNodeBorderColorDirect(windowobj, cf[grep("acetyl", cf$nodeType), 1], "#FF0000") # red setNodeBorderColorDirect(windowobj, cf[grep("methyl", cf$nodeType), 1], "#005CE6") # blue setNodeBorderColorDirect(windowobj, cf[grep("membrane", cf$nodeType), 1], "#6600CC") # purple setNodeBorderColorDirect(windowobj, cf[grep("receptor", cf$nodeType), 1], "#6600CC") # purple setNodeBorderColorDirect(windowobj, cf[grep("TM", cf$Domains), 1], "#6600CC") # purple setNodeBorderWidthRule(windowobj, node.attribute.name="nodeType", attribute.values=c("deacetylase","acetyltransferase","demethylase","methyltransferase","membrane protein", "receptor tyrosine kinase", "G protein-coupled receptor"), line.widths=c(6,10,6,10,7,7,7), default.width=1.8) setDefaultNodeSelectionColor (windowobj, "#CC00FF")

setNodeLabelRule(windowobj, node.attribute.name)

redraw(windowobj)

} edgeDprops function(windowname) { setDefaultEdgeLineWidth (windowname, 3) setDefaultEdgeColor (windowname, '#888888') # gray setDefaultEdgeSelectionColor(windowname, "#FF6600") edgecolors = c('#FF0000', '#FF0000', '#33FFCC', '#008000', '#EE00EE', '#0000FF', '#CC00FF', '#008000', '#006666', '#000000', '#888888', '#00C78C', '#0000FF', "#FCD116", '#0000FF', '#000000', "FF6699")

red; turquois; green; magenta; blue; violet; green; bluegreen; black; gray; turquoiseblue

edgeTypes <- c("pp", "controls-phosphorylation-of", 'homology', 'knowledge', 'experimental', 'combined_score',  "Physical interactions","Pathway", "Predicted", "Genetic interactions", "merged" , "Shared protein domains", "negative correlation", "positive correlation", "intersect", "peptide", "controls-state-change-of")  
myarrows <- c ('Arrow', 'Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', "Arrow")
setEdgeTargetArrowRule(windowname, 'edgeType', edgeTypes, myarrows, default='No Arrow')  
setEdgeTargetArrowColorRule(windowname, "edgeType",  edgeTypes, edgecolors, default.color='#FF0000')  
setEdgeSourceArrowColorRule(windowname, "edgeType",  edgeTypes, myarrows, default.color='#FF0000')  
setEdgeColorRule(windowname, 'edgeType', edgeTypes, edgecolors, mode='lookup', default.color='#33CC33')    # formerly #888888
}

Dissection of individual commands in edgeDprops:

  edgeDprops(group1.w)

Successfully set rule. RCy3::setEdgeTargetArrowColorRule, no 'below' or 'above' colors specified. Inferred from supplied colors. Error. Could not set rule... RCy3::setEdgeSourceArrowColorRule, no 'below' or 'above' colors specified. Inferred from supplied colors. Error. Could not set rule... Successfully set rule. setEdgeTargetArrowRule(windowname, 'edgeType', edgeTypes, myarrows, default='No Arrow')
Successfully set rule.

setEdgeTargetArrowColorRule(windowname, "edgeType",  edgeTypes, edgecolors, default.color='#FF0000')      

Error in setEdgeTargetArrowColorRule(windowname, "edgeType", edgeTypes, : object 'edgecolors' not found

edgecolors = c('#FF0000', '#FF0000', '#33FFCC', '#008000', '#EE00EE', '#0000FF', '#CC00FF', '#008000',  '#006666', '#000000', '#888888', '#00C78C', '#0000FF', "#FCD116", '#0000FF', '#000000', "FF6699") 
#  red; turquois; green; magenta; blue; violet; green;  bluegreen; black; gray; turquoiseblue 
edgeTypes <- c("pp", "controls-phosphorylation-of", 'homology', 'knowledge', 'experimental', 'combined_score',  "Physical interactions","Pathway", "Predicted", "Genetic interactions", "merged" , "Shared protein domains", "negative correlation", "positive correlation", "intersect", "peptide", "controls-state-change-of")             
myarrows <- c ('Arrow', 'Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', 'No Arrow', "Arrow")

setEdgeTargetArrowRule(windowname, 'edgeType', edgeTypes, myarrows, default='No Arrow')
Successfully set rule. setEdgeTargetArrowColorRule(windowname, "edgeType", edgeTypes, edgecolors, default.color='#FF0000')
RCy3::setEdgeTargetArrowColorRule, no 'below' or 'above' colors specified. Inferred from supplied colors. Error. Could not set rule... setEdgeSourceArrowColorRule(windowname, "edgeType", edgeTypes, myarrows, default.color='#FF0000')
RCy3::setEdgeSourceArrowColorRule, no 'below' or 'above' colors specified. Inferred from supplied colors. Error. Could not set rule... setEdgeColorRule(windowname, 'edgeType', edgeTypes, edgecolors, mode='lookup', default.color='#33CC33') # formerly #888888 Successfully set rule.

tmuetze commented 8 years ago

Fixed

tmuetze commented 8 years ago

Until a new CyREST update, please first set all rule-based functions and then the direct ones.