Closed m-grimes closed 6 years ago
Hi Mark. I was unable to test beyond line 373. See the note about about extract.peptides
missing. I get this error before I can get to the error you are reporting:
Error in match.fun(FUN) : object 'extract.peptides' not found
Alex,
Yes, I noted that and put the function in the code in the file I sent.
There was another issue (#5) with the class in the thread. I don't know if they are related. I tried to use as.character() as a fix but that didn't work, not sure why.
Mark
University of Montana
On 12 Jun 2018, at 17:44, Alexander Pico wrote:
Hi Mark. I was unable to test beyond line 373. See the note about about
extract.peptides
missing. I get this error before I can get to the error you are reporting:Error in match.fun(FUN) : object 'extract.peptides' not found
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/25#issuecomment-396768740
Alex
I got it to work. I think the problem at the end is that 'edgeType' was still in the edge file and this created problems. The attached script works! I set
options(stringsAsFactors=FALSE)
at the outset. Interestingly, I was able to plot multiple edges between proteins, which we couldn't do before with the older methods that required graph objects.
Now that we have this working I can get to work fixing up my working environment (functions, etc.). It will be useful to explore would be collapsing nodes (meta nodes) and edges. My function mergeEdges may be useful for collapsing edges, but I dimly recall you have a better way.
Mark
mergeEdges <- function(edgefile) {
# First sort/order the nodes
undir.edges <- edgefile
undir.edges[, 1:2] <- t(apply(undir.edges[,1:2], 1, function (x)
sort(x)))
undir.merged <- ddply(undir.edges, .(Gene.1, Gene.2),
numcolwise(sum), na.rm=TRUE)
undir.merged$edgeType <- dlply(undir.edges, .(Gene.1, Gene.2),
function(x) paste0(x[, "edgeType"]))
undir.merged$edgeType <- sapply(undir.merged$edgeType, function(x)
paste(c(x), collapse=", "))
undir.merged$Directed <- FALSE
# Remove auto-phosphorylation loops
edgefile.merged <- remove.autophos(undir.merged)
# edgefile.merged <- edgefile.merged[, c(1:2,5,3,4,6)]
return(edgefile.merged)
}
Mark Grimes Division of Biological Sciences University of Montana Missoula, Montana 59812-4824 Grimes lab website Office Telephone: (406) 243-4977 Fax Number: (406) 243-4184 E-mail: Mark.Grimes@mso.umt.edu
On 12 Jun 2018, at 17:44, Alexander Pico wrote:
Hi Mark. I was unable to test beyond line 373. See the note about about
extract.peptides
missing. I get this error before I can get to the error you are reporting:Error in match.fun(FUN) : object 'extract.peptides' not found
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/25#issuecomment-396768740
title: "Vizualization and Exploration of a Cluster-Filtered Network (CFN) and a Co-Cluster Correlation Network (CCCN)" output: html_notebook
options(stringsAsFactors=FALSE)
library(plyr)
library(dplyr)
library(RCy3)
cytoscapePing()
library(gplots)
library(igraph)
#localpath = "/Users/Mark_Grimes/Dropbox/_Work/R_/_LINCS/_Export_for_Paper"
#localpath = "/Users/MGrimes/Dropbox/_Work/R_/_LINCS/_Export_for_Paper"
localpath = getwd()
objectkey = read.table(paste(localpath, "DataObjectKey.txt", sep="/"), sep="\t", stringsAsFactors=FALSE)
objectkey = objectkey[,c(1,3)]
names(objectkey) = c("data.object", "description")
load(file=paste(localpath, "LC_TMT_Nets.RData", sep="/"))
load(file=paste(localpath, "LC_TMT_Functions.RData", sep="/"))
load(file=paste(localpath, "protein_families.RData", sep="/"))
print(objectkey)
Acetyl-lysine binding bromodomain and extraterminal (BET) domain family proteins are epigenetic modulators involved in the reading of acetylated lysine residues (Filippakopoulos, P., and Knapp, S. (2014). Targeting bromodomains: epigenetic readers of lysine acetylation. Nat Rev Drug Discov 13, 337–356). The list of bromo- and BET-domain-containing proteins from Harmonizome and hprd.org is shown below (Prasad, T. S. K. et al. (2009) Human Protein Reference Database - 2009 Update. Nucleic Acids Research. 37, D767-72; Rouillard AD, Gundersen GW, Fernandez NF, Wang Z, Monteiro CD, McDermott MG, Ma'ayan A. The harmonizome: a collection of processed datasets gathered to serve and mine knowledge about genes and proteins. Database (Oxford). 2016 Jul 3;2016. pii: baw100.) The R data frame func.key summarizes results from several sources.
bromodomainPs <- c("ASH1L", "ATAD2", "ATAD2B", "BAZ1A", "BAZ1B", "BAZ2A", "BAZ2B", "BPTF", "BRD1", "BRD2", "BRD3", "BRD4", "BRD7", "BRD8", "BRD9", "BRDT", "BRPF1", "BRPF3", "BRWD1", "BRWD3", "CECR2", "CREBBP", "EP300", "KAT2A", "KAT2B", "KIAA2026", "KMT2A", "PBRM1", "PHIP", "SMARCA2", "SMARCA4", "SP110", "SP140", "SP140L", "TAF1", "TAF1L", "TRIM24", "TRIM28", "TRIM33", "TRIM66", "ZMYND11", "ZMYND8")
bromos <- func.key[grep("BROMO", func.key$Domains), "Gene.Name"]
bromoPs <- sort(unique(c(bromos, bromodomainPs)))
Next, we identify CFN interactions between kinases, phosphatases, acetyl-binding proteins, phosphoprotein-binding proteins, and proteins that have negative correlations between acetylation and phosphorylation (dualpack.neg.genes).
# Identify interactions between dually modified proteins and acetyl-binding proteins
dualbromo.net <- filter.edges.between(bromoPs, dualpack.neg.genes, essl.cfn)
# Identify interactions between dually modified proteins and kinases, phosphatases
dualkin.net <- filter.edges.between(c(kins, phosphatases), dualpack.neg.genes, essl.cfn)
# Identify interactions between dually modified proteins and acetyltransferases, deacetylases
dualacetyl.net <- filter.edges.between(c(acetyltransferases, deacetylases), dualpack.neg.genes, essl.cfn)
# Identify interactions between dually modified and proteins that bind phosphorylated tyrosine, serine, threonine
dualp_binding.net <- filter.edges.between(c(ptbPs, sh2list, pSbindingPs), dualpack.neg.genes, essl.cfn)
# This latter one is 312 edges. We will keep it simpler by not including these edges initially.
# Put the first three together to test the hypothesis that ki all these to look at nodes that interact
dual.net <- unique(rbind(dualbromo.net, dualacetyl.net, dualkin.net)) # 271 edges
# Simplify edges using mergeEdges
dual.net2 <- mergeEdges.dir(dual.net) # now 198 edges
# Option: simplify further by removing interactions that are only genetic interactions, which may be indirect
dual.net3 <- dual.net2[-which(dual.net2$edgeType=="Genetic interactions"),] # now 146 edges
# Note: we could have started with the CFN without genetic interactions (essl.cfn.nogen) but this way the genetic interactions are shown only along with other evidence for interactions.
# How many nodes are in this network?
# extract.gene.names(dual.net2) #$ 161
# extract.gene.names(dual.net3) #$ 122
#
Let's plot dual.net2. This network of dually acetylated phosphorylated proteins' interactions with acetyltransferases, deacetylases, kinases and bromodomain-containing proteins contains 161 proteins and 194 edges.
dualbromkin.cf <- make.anynetcf(edge.df=dual.net2, data.file=ldgene.fc, geneatts=essl.netatts, ptmcccnatts=essl.cccn.edges, func.key=func.key)
#set data frame colnames for translation/import into Cytoscape
colnames(dual.net2)<-c("source","target","Weight","interaction")
colnames(dualbromkin.cf)[1]<-'id'
dualbromkin.net.suid <- createNetworkFromDataFrames(dualbromkin.cf, dual.net2, title=paste("Bromodomain Interactions ", 1+length(getNetworkList())), collection = "Bromodomain Interactions")
Now let's set the edge visual styles.
setEdgeLineWidthDefault (3)
setEdgeColorDefault ( "#FFFFFF") # white
setEdgeSelectionColorDefault ( "#FF69B4") # hotpink
edgecolors <- col2hex(c("red", "red", "magenta", "violet", "purple", "green", "green2", "green3", "aquamarine2", "cyan", "turquoise2", "cyan2", "lightseagreen", "gold", "blue", "yellow", "slategrey", "darkslategrey", "grey", "black", "orange", "orange2"))
edgecolorsplus <- col2hex(c("deeppink", "red", "red", "magenta", "violet", "purple", "green", "green2", "green3", "aquamarine2", "cyan", "turquoise2", "cyan2", "lightseagreen", "gold", "blue", "yellow", "slategrey", "darkslategrey", "grey", "black", "orange", "orange2", "orangered2"))
# red; turquois; green; magenta; blue; violet; green; bluegreen; black; gray; turquoiseblue; orange
edgeTypes <- c("pp", "controls-phosphorylation-of", "controls-expression-of", "controls-transport-of", "controls-state-change-of", "Physical interactions", "BioPlex", "in-complex-with", 'experiments', 'database', "Pathway", "Predicted", "Genetic interactions", "correlation", "negative correlation", "positive correlation", 'combined_score', "merged" , "intersect", "peptide", 'homology', "Shared protein domains")
# 22 edgeTypes
myarrows <- c ('Arrow', 'Arrow', 'Arrow', 'Arrow', "Arrow", 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None')
setEdgeTargetArrowMapping( 'interaction', edgeTypes, myarrows, default.shape='None')
matchArrowColorToEdge('TRUE')
setEdgeColorMapping( 'interaction', edgeTypes, edgecolors, 'd', default.color="#FFFFFF")
And now some node visual styles.
plotcol <- "Total"
if(!(plotcol %in% getTableColumnNames('node'))){
print (getTableColumnNames('node'))
cat("\n","\n","\t", "Which attribute will set node size and color?")
plotcol <- as.character(readLines(con = stdin(), n = 1))
}
limits <- range(dualbromkin.cf[, plotcol])
node.sizes = c (135, 130, 108, 75, 35, 75, 108, 130, 135)
# RATIO is plotted
# Blue is negative: Yellow positive, Green in middle
#
size.control.points = c (-100.0, -15.0, -5.0, 0.0, 5.0, 15.0, 100.0)
color.control.points = c (-100.0, -10.0, -5.0, -2.25, 0.0, 2.25, 5.0, 10.0, 100.0)
if(limits[1] < min(size.control.points)) {
size.control.points = c (limits[1], -15.0, -5.0, 0.0, 5.0, 15.0, 100.0)
color.control.points = c (limits[1]-1, -10.0, -5.0, -2.25, 0.0, 2.25, 5.0, 10.0, 100.0)
}
if(limits[2] > max(size.control.points)) {
size.control.points = c (limits[1], -15.0, -5.0, 0.0, 5.0, 15.0, limits[2])
color.control.points = c (limits[1]-1, -10.0, -5.0, -2.25, 0.0, 2.25, 5.0, 10.0, limits[2]+1)
}
ratio.colors = c ('#0099FF', '#007FFF','#00BFFF', '#00CCFF', '#00FFFF', '#00EE00', '#FFFF7E', '#FFFF00', '#FFE600', '#FFD700', '#FFCC00')
setNodeColorMapping (names(dualbromkin.cf[plotcol]), color.control.points, ratio.colors, 'c')
lockNodeDimensions('TRUE')
setNodeSizeMapping (names(dualbromkin.cf[plotcol]), size.control.points, node.sizes, 'c')
setNodeSelectionColorDefault ( "#CC00FF")
#netattProps3(dualbromkin.cf, use="ppi")
And a few more node visual styles.
setBackgroundColorDefault("#949494") # grey 58
setNodeShapeDefault( "ELLIPSE")
setNodeColorDefault( '#F0FFFF') # azure1
setNodeSizeDefault( 100) # for grey non-data nodes
setNodeFontSizeDefault( 22)
setNodeLabelColorDefault( '#000000') # black
setNodeBorderWidthDefault( 1.8)
setNodeBorderColorDefault( '#888888') # gray
molclasses <- c("unknown", "receptor tyrosine kinase", "SH2 protein", "SH2-SH3 protein", "SH3 protein", "tyrosine kinase", "SRC-family kinase", "kinase", "phosphatase", "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", "VEE", "VEE", "TRIANGLE", "HEXAGON", "DIAMOND", "OCTAGON", "OCTAGON", "PARALLELOGRAM", "RECTANGLE")
setNodeSelectionColorDefault( "#CC00FF")
setNodeShapeMapping ("nodeType", molclasses, nodeshapes, default.shape="ELLIPSE")
setNodeBorderWidthMapping("nodeType", c("deacetylase","acetyltransferase","demethylase","methyltransferase","membrane protein", "receptor tyrosine kinase", "G protein-coupled receptor", "SRC-family kinase", "tyrosine kinase", "kinase", "phosphatase"), widths=c(4,12,4,12,8,16,16,12,12,12,14), 'd',default.width=4)
cf<-dualbromkin.cf
if (length(cf[grep("SH2", cf$Domains), 1])>0 & !all(grep("SH2", cf$Domains) %in% which(cf$nodeType %in% molclasses))) {
setNodeShapeBypass(cf[grep("SH2", cf$Domains) %w/o% which(cf$nodeType %in% molclasses), 1], nodeshapes[3])}
if (length(cf[grep("RNA", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("RNA", cf$nodeType), 1], nodeshapes[11])}
if (length(cf[grep("transcription", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("transcription", cf$nodeType), 1], nodeshapes[10])}
if (length(cf[grep("acetyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("acetyl", cf$nodeType), 1], "#FF8C00")} # darkorange
if (length(cf[grep("methyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("methyl", cf$nodeType), 1], "#005CE6")} # blue
if (length(cf[grep("membrane", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("membrane", cf$nodeType), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("membrane", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("kinase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("kinase", cf$nodeType), 1], "#EE0000")} # red2
if (length(cf[grep("phosphatase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("phosphatase", cf$nodeType), 1], "#FFEC8B")} # lightgoldenrod1
if (length(cf[grep("receptor", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("receptor", cf$nodeType), 1], "#BF3EFF") # darkorchid1
setNodeShapeBypass(cf[grep("receptor", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("TM", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("TM", cf$Domains), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("TM", cf$Domains), 1], nodeshapes[2])}
Let's set edge widths to the absolute value of the edge weight itmes a factor of 5
edgevalues <- getTableColumns('edge',c('name','Weight'))
edgevalues['Weight']<-abs(edgevalues['Weight'])
edgevalues['Weight']<-lapply(edgevalues['Weight'], function(x) x * 5)
setEdgeLineWidthBypass(edgevalues[['name']], edgevalues[['Weight']])
And let's copy the style to name it for future reference
style.name = 'Total Style'
copyVisualStyle('default', style.name)
setVisualStyle(style.name)
On Cytoscape, the nodes appear too crowded, so we tweak the layout parameters to spread the graph out so the nodes are all visible.
# The following parameters were determined by experimentation.
layoutNetwork('force-directed defaultSpringCoefficient=0.00001 defaultSpringLength=50 defaultNodeMass=5')
# This looks better.
# Highlight bromodomain-containing protiens and other protein classes
sn<-selectNodes(bromodomainPs[bromodomainPs %in% getAllNodes()],'name', preserve.current.selection = F)
Sys.sleep(.5)
# all kinases
sn<-selectNodes(kins[kins %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# tyrosine kinases
sn<-selectNodes(ykinases[ykinases %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# receptor tyrosine kinases
sn<-selectNodes(rtklist[rtklist %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# phosphatases
sn<-selectNodes(phosphatases[phosphatases %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# proteins associated with the cytoskeleton
sn<-selectNodes(cytoskeletonPs[cytoskeletonPs %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# acetyltransferasees
sn<-selectNodes(acetyltransferases[acetyltransferases %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# deacetylases
sn<-selectNodes(deacetylases[deacetylases %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
# proteins associated with the endo-lysosomal system
sn<-selectNodes(endps.hi[endps.hi %in% getAllNodes()], 'name', preserve.current.selection = F)
Sys.sleep(.5)
Let's focus in on a subset of these for a simpler graph. Choose a subset of nodes. This can be done manually by selecting nodes, or in code. You can try it either way by skipping either the first or second and third lines in the next code chunk. We will also remove edges that are only "genetic interactions" so as to focus on direct interactions.
# For manual selection from window:
look1 <- getSelectedNodes()
look <- filter.edges.0(look1, dual.net3)
# Selection in R:
# Get first neighbors of EGFR and MET, ecluding edges with only genetic interactions (dual.net3)
look1 <- filter.edges.1(c("EGFR", "MET", "SMARCA4"), dual.net3)
# Get first neighbors of these for degree 2 connected network.
look <- filter.edges.1(extract.gene.names(look1), dual.net3)
# Plot a new network from these nodes
dualbromkin.cf2 <- make.anynetcf(edge.df=look, data.file=ldgene.fc, geneatts=essl.netatts, ptmcccnatts=essl.cccn.edges, func.key=func.key)
#set data frame colnames for translation/import into Cytoscape
colnames(look)<-c("source","target","Weight","interaction")
colnames(dualbromkin.cf2)[1]<-'id'
dualbromkin2.net.suid <- createNetworkFromDataFrames(dualbromkin.cf2, look, title=paste("Bromodomain Interactions ", 1+length(getNetworkList())), collection = "Bromodomain Interactions")
setVisualStyle(style.name)
Redo node bypasses
molclasses <- c("unknown", "receptor tyrosine kinase", "SH2 protein", "SH2-SH3 protein", "SH3 protein", "tyrosine kinase", "SRC-family kinase", "kinase", "phosphatase", "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", "VEE", "VEE", "TRIANGLE", "HEXAGON", "DIAMOND", "OCTAGON", "OCTAGON", "PARALLELOGRAM", "RECTANGLE")
cf<-dualbromkin.cf2
if (length(cf[grep("SH2", cf$Domains), 1])>0 & !all(grep("SH2", cf$Domains) %in% which(cf$nodeType %in% molclasses))) {
setNodeShapeBypass(cf[grep("SH2", cf$Domains) %w/o% which(cf$nodeType %in% molclasses), 1], nodeshapes[3])}
if (length(cf[grep("RNA", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("RNA", cf$nodeType), 1], nodeshapes[11])}
if (length(cf[grep("transcription", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("transcription", cf$nodeType), 1], nodeshapes[10])}
if (length(cf[grep("acetyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("acetyl", cf$nodeType), 1], "#FF8C00")} # darkorange
if (length(cf[grep("methyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("methyl", cf$nodeType), 1], "#005CE6")} # blue
if (length(cf[grep("membrane", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("membrane", cf$nodeType), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("membrane", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("kinase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("kinase", cf$nodeType), 1], "#EE0000")} # red2
if (length(cf[grep("phosphatase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("phosphatase", cf$nodeType), 1], "#FFEC8B")} # lightgoldenrod1
if (length(cf[grep("receptor", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("receptor", cf$nodeType), 1], "#BF3EFF") # darkorchid1
setNodeShapeBypass(cf[grep("receptor", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("TM", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("TM", cf$Domains), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("TM", cf$Domains), 1], nodeshapes[2])}
Redo edge bypasses
edgevalues <- getTableColumns('edge',c('name','Weight'))
edgevalues['Weight']<-abs(edgevalues['Weight'])
edgevalues['Weight']<-lapply(edgevalues['Weight'], function(x) x * 5)
setEdgeLineWidthBypass(edgevalues[['name']], edgevalues[['Weight']])
Let's examine what it looks like to make node size and color dependent on data from treatments with drugs. First, rearrange the nodes by hand to make the network as readable as possible. Then, keep track of node position so identical layouts may be obtained. Then make new node attribute file from geldanamycin-treated samples and plot the network.
#dualbromkin.w.pos <- RCy3::getNodePosition(getAllNodes())
#x = as.integer (sapply (dualbromkin.w.pos, function (node.loc) return (node.loc$x)))
#y = as.integer (sapply (dualbromkin.w.pos, function (node.loc) return (node.loc$y)))
#
dualbromkingeld.cf <- make.anynetcf(edge.df=dual.net2, data.file=ldgene.fc[,geldexpts.nc], geneatts=essl.netatts, ptmcccnatts=essl.cccn.edges, func.key=func.key)
#set data frame colnames for translation/import into Cytoscape
#colnames(dual.net2)<-c("source","target","Weight","interaction")
colnames(dualbromkingeld.cf)[1]<-'id'
dualbromkingeld.net.suid <- createNetworkFromDataFrames(dualbromkingeld.cf, dual.net2, title=paste("Bromodomain Interactions ", 1+length(getNetworkList())), collection = "Bromodomain Interactions")
setVisualStyle(style.name)
Redo node bypasses
molclasses <- c("unknown", "receptor tyrosine kinase", "SH2 protein", "SH2-SH3 protein", "SH3 protein", "tyrosine kinase", "SRC-family kinase", "kinase", "phosphatase", "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", "VEE", "VEE", "TRIANGLE", "HEXAGON", "DIAMOND", "OCTAGON", "OCTAGON", "PARALLELOGRAM", "RECTANGLE")
cf<-dualbromkingeld.cf
if (length(cf[grep("SH2", cf$Domains), 1])>0 & !all(grep("SH2", cf$Domains) %in% which(cf$nodeType %in% molclasses))) {
setNodeShapeBypass(cf[grep("SH2", cf$Domains) %w/o% which(cf$nodeType %in% molclasses), 1], nodeshapes[3])}
if (length(cf[grep("RNA", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("RNA", cf$nodeType), 1], nodeshapes[11])}
if (length(cf[grep("transcription", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("transcription", cf$nodeType), 1], nodeshapes[10])}
if (length(cf[grep("acetyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("acetyl", cf$nodeType), 1], "#FF8C00")} # darkorange
if (length(cf[grep("methyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("methyl", cf$nodeType), 1], "#005CE6")} # blue
if (length(cf[grep("membrane", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("membrane", cf$nodeType), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("membrane", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("kinase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("kinase", cf$nodeType), 1], "#EE0000")} # red2
if (length(cf[grep("phosphatase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("phosphatase", cf$nodeType), 1], "#FFEC8B")} # lightgoldenrod1
if (length(cf[grep("receptor", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("receptor", cf$nodeType), 1], "#BF3EFF") # darkorchid1
setNodeShapeBypass(cf[grep("receptor", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("TM", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("TM", cf$Domains), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("TM", cf$Domains), 1], nodeshapes[2])}
Redo edge bypasses
edgevalues <- getTableColumns('edge',c('name','Weight'))
edgevalues['Weight']<-abs(edgevalues['Weight'])
edgevalues['Weight']<-lapply(edgevalues['Weight'], function(x) x * 5)
setEdgeLineWidthBypass(edgevalues[['name']], edgevalues[['Weight']])
For the figure, perhaps it would be clearer with a white background, and bigger node labels. Then it is necessary to make white edges a visible color (grey, here).
new.style <- "Geldanamycin Style"
copyVisualStyle(style.name, new.style)
setVisualStyle(new.style)
setNodeFontSizeDefault(28, new.style)
setBackgroundColorDefault("#FFFFFF", new.style) # white, transparent
setEdgeColorDefault ("#888888", new.style) # grey
Okay.
# Now set the node positions to be identical for easy comparison
layoutCopycat(dualbromkin.net.suid, dualbromkingeld.net.suid)
Let's pick two nodes and graph a CNF-CCCN pathway that links them. We'll use the essl.cccnplus.edges to include negative correlations between PTM on the same protein.
# Note: To make the igraph object from the network
essl.cccnplus.ig <- graph_from_data_frame(essl.cccnplus.edges, directed=FALSE)
# First pick two nodes. For the website, this could be user-defined. (For a simple network, try ALK and LYN)
node1 <- as.character(readLines(con = stdin(), n = 1))
if(!(node1 %in% rownames(ldgene.fc))) cat("That gene is not in the curent data set.")
node2 <- as.character(readLines(con = stdin(), n = 1))
if(!(node2 %in% rownames(ldgene.fc))) cat("That gene is not in the curent data set.")
nodenames=c(node1, node2)
connected.path <- connectNodes.all(nodenames, essl.cfn.ig, essl.cfn)
path.nodes <- unique(c(as.character(connected.path$Gene.1), as.character(connected.path$Gene.2)))
# Get peptides from this network
extract.peptides <- function(nodename, edgefile=pepnet.edges) {
peps.1 <- edgefile$Gene.1[grep(nodename, edgefile$Gene.1, fixed=TRUE)]
peps.2 <- edgefile$Gene.2[grep(nodename, edgefile$Gene.2, fixed=TRUE)]
return(as.character(unique(c(peps.1, peps.2))))
}
netpeps <- as.character(unlist(sapply(path.nodes, extract.peptides, essl.cccn.edges)))
# extract.peptides defined above
pepnodes.df <- data.frame(netpeps, pep.nodes=(sapply(netpeps, function(x) unlist(strsplit(x, " "))[1])))
netpeps <- as.character(pepnodes.df[pepnodes.df$pep.nodes %in% path.nodes, 1])
ptm.cccn <- filter.edges.0(netpeps, essl.cccnplus.edges)
net.full <- mergeEdges(connected.path)
net.full$Alt.Weight <- net.full$Weight
net.gene.cf <- make.anynetcf(edge.df=net.full, data.file=ldgene.fc[, crizexpts.nc], geneatts=essl.netatts, ptmcccnatts=essl.ptmcccnatts, func.key=func.key, use=c("total", "mean", "median", "max"))
net.pep.cf <- make.anynetcf(edge.df=ptm.cccn, data.file=ld.fc[, crizexpts.nc], geneatts=essl.netatts, ptmcccnatts=essl.ptmcccnatts, func.key=func.key, use=c("total", "mean", "median"))
# combine node attribute cytoscape file
net.cf <- harmonize_cfs3(pepcf=net.pep.cf, genecf=net.gene.cf)
# make gene-peptide edges
net.gpe <- data.frame(Gene.1=net.pep.cf$Gene.Name, Gene.2=net.pep.cf$Peptide.Name, edgeType="peptide", Weight=100, Alt.Weight=1)
# net.gpe <- genepep.edges(ptm.cccn)
# combine edge files
net.full <- net.full[, c("Gene.1", "Gene.2", "Weight", "edgeType", "Alt.Weight")]
net.edges <- rbind(net.gpe, ptm.cccn, net.full)
# Note: to change "edgeType" to "interaction" according to new requirements for createNetworkFromDataFrames, use edgeType.to.interaction() or
# names(net.edges)[grep("edgeType", names(net.edges))] <- "interaction"
# Graph in RCy3
#set data frame colnames for translation/import into Cytoscape
colnames(net.edges)[1:3]<-c("source", "target", "interaction")
# Note: can use Alt.Weight for edge visualization because peptide edges are set to 100 for layouts that cluster them next to nodes. If so:
# net.edges$Weight <- net.edges$Alt.Weight
colnames(net.cf)[1]<-'id'
net.suid <- createNetworkFromDataFrames(net.cf, net.edges, title=paste(paste(nodenames, collapse=" to "), 1+length(getNetworkList())), collection = "Bromodomain Interactions")
# RCy3::cyrestPOST, HTTP Error Code: 412?
setVisualStyle(new.style)
# return(list(net.cf, net.edges))
# Try plotting with all the edges using the new methods
connected.path$Alt.Weight <- connected.path$Weight
net2.edges <- rbind(net.gpe, ptm.cccn, connected.path)
colnames(net2.edges)[1:3]<-c("source", "target", "interaction")
net.suid <- createNetworkFromDataFrames(net.cf, net2.edges, title=paste(paste(nodenames, collapse=" to "), 1+length(getNetworkList())), collection = "Bromodomain Interactions")
This shows all the edges between interacting proteins when there are multiple interactions.
Redo node bypasses
molclasses <- c("unknown", "receptor tyrosine kinase", "SH2 protein", "SH2-SH3 protein", "SH3 protein", "tyrosine kinase", "SRC-family kinase", "kinase", "phosphatase", "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", "VEE", "VEE", "TRIANGLE", "HEXAGON", "DIAMOND", "OCTAGON", "OCTAGON", "PARALLELOGRAM", "RECTANGLE")
cf<-net.cf
if (length(cf[grep("SH2", cf$Domains), 1])>0 & !all(grep("SH2", cf$Domains) %in% which(cf$nodeType %in% molclasses))) {
setNodeShapeBypass(cf[grep("SH2", cf$Domains) %w/o% which(cf$nodeType %in% molclasses), 1], nodeshapes[3])}
if (length(cf[grep("RNA", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("RNA", cf$nodeType), 1], nodeshapes[11])}
if (length(cf[grep("transcription", cf$nodeType), 1])>0) {
setNodeShapeBypass(cf[grep("transcription", cf$nodeType), 1], nodeshapes[10])}
if (length(cf[grep("acetyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("acetyl", cf$nodeType), 1], "#FF8C00")} # darkorange
if (length(cf[grep("methyl", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("methyl", cf$nodeType), 1], "#005CE6")} # blue
if (length(cf[grep("membrane", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("membrane", cf$nodeType), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("membrane", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("kinase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("kinase", cf$nodeType), 1], "#EE0000")} # red2
if (length(cf[grep("phosphatase", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("phosphatase", cf$nodeType), 1], "#FFEC8B")} # lightgoldenrod1
if (length(cf[grep("receptor", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("receptor", cf$nodeType), 1], "#BF3EFF") # darkorchid1
setNodeShapeBypass(cf[grep("receptor", cf$nodeType), 1], nodeshapes[2])}
if (length(cf[grep("TM", cf$nodeType), 1])>0) {
setNodeBorderColorBypass(cf[grep("TM", cf$Domains), 1], "#6600CC") # purple
setNodeShapeBypass(cf[grep("TM", cf$Domains), 1], nodeshapes[2])}
Redo edge bypasses
edgevalues <- getTableColumns('edge',c('name','Weight'))
edgevalues['Weight']<-abs(edgevalues['Weight'])
edgevalues['Weight']<-lapply(edgevalues['Weight'], function(x) x * 5)
setEdgeLineWidthBypass(edgevalues[['name']], edgevalues[['Weight']])
Change the appearance of protein-PTM edges
allwedges <- getAllEdges()
prpepedges <- allwedges[grep("peptide", allwedges)]
setEdgeColorBypass(prpepedges, new.colors="#808080")
setEdgeLineWidthBypass(prpepedges, new.widths = 2)
Ah, got it! I was working with the older version. Ok. Now I'm able to reproduce the error. Working on it...
Ah (again)! I just read your latest reply. Great! Glad you got it working.
Regarding your question about meta nodes: yes, there are grouping functions. Start by looking through the Swagger docs for 'group' functions: Help>Automation>CyREST Commands API (screenshot).
Groups! This sounds good; I will investigate. - M
Dear Alex and Mark,
I stumbled upon this thread while googling for an explanation for the same error that you seemed to have had (see below). I would be very grateful if you could kindly share your solution for this problem? I tried options(stringsAsFactors = F) as well as using as.character(), but neither work for me. I am using the same version of cytoscape as you.
Many thanks in advance.
Andrija Sente
This is the error I get:
'RCy3::cyrestPOST, HTTP Error Code: 412 url=http://localhost:1234/v1/networks/1544/tables/defaultedge/columns body={ "name": "weight", "type": "Integer" } Error in cyrestPOST(paste("networks", net.suid, "tables", tbl, "columns", :
@sentementalan Hi, the issue is very likely the same: the dataframe of edges that you are passing into loadDataTable() has levels. You can check this by str(your.edges.df)
. The easiest way to avoid these is to add this arg to the line where you first create the df "stringsAsFactors=F". Using options
is another option (if you remember to do this before creating the df). You can also do something like this:
cols.with.factors <- sapply(your.edges.df, is.factor)
your.edges.df[cols.with.factors]<- lapply(your.edges.df[cols.with.factors], as.character)
In the dev release of RCy3, this is done for you for all cases :) You can use that now via github:
install.packages("devtools")
library(devtools)
install_github('cytoscape/RCy3', build_vignettes=TRUE)
Or wait for the next bioconductor release in mid-October.
Alex
Creating the last network (about Line 401) in the CFN_CCCN_FigureVignette_updated.Rmd file that you sent me gives the error:
I don't know what this means, but I notice that the class of data in input files is mapped in this way:
Class "factor" has given me fits in the past; maybe it's something like that?
Thanks,
Mark
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
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] stats graphics grDevices utils datasets methods base
other attached packages: [1] gplots_3.0.1 igraph_1.2.1 RColorBrewer_1.1-2 dplyr_0.7.5
[5] plyr_1.8.4 RCy3_2.0.1 BiocInstaller_1.30.0 devtools_1.13.5
loaded via a namespace (and not attached): [1] graph_1.58.0 Rcpp_0.12.17 bindr_0.1.1 magrittr_1.5
[5] BiocGenerics_0.26.0 tidyselect_0.2.4 R6_2.2.2 rlang_0.2.1
[9] httr_1.3.1 caTools_1.17.1 tools_3.5.0 parallel_3.5.0
[13] KernSmooth_2.23-15 withr_2.1.2 gtools_3.5.0 digest_0.6.15
[17] assertthat_0.2.0 tibble_1.4.2 RJSONIO_1.3-0 bindrcpp_0.2.2
[21] purrr_0.2.5 bitops_1.0-6 curl_3.2 memoise_1.1.0
[25] glue_1.2.0 gdata_2.18.0 compiler_3.5.0 pillar_1.2.3
[29] stats4_3.5.0 XML_3.98-1.11 pkgconfig_2.0.1