Closed m-grimes closed 6 years ago
Note that a workaround is possible using setEdgeLineWidthBypass() as in the following function.
setEdgeWidths.RCy32 <<- function (edgefile, factor=1.2, log=TRUE) {
if (log==FALSE) {
line.widths <- factor*abs(as.numeric(edgefile$Weight))
}
if (log==TRUE) {
line.widths <- log(abs(edgefile$Weight)) + factor - min(log(abs(edgefile$Weight)))
}
edgevalues <- getTableColumns('edge',c('name','Weight'))
edgevalues['Weight'] <- line.widths
setEdgeLineWidthBypass(edgevalues[['name']], edgevalues[['Weight']])
# setEdgeLineWidthMapping("Weight", table.column.values=edgefile$Weight, mapping.type = "c", widths=line.widths, default.width=1.2)
# for testing:
# return(data.frame(edgefile$Weight, line.widths))
} --Mark
Alex
Here is the command and error message:
setEdgeLineWidthMapping("Weight", table.column.values=edgefile$Weight, mapping.type = "d", widths=line.widths, default.width=1.2) RCy3::cyrestPUT, HTTP Error Code: 500 url=http://localhost:1234/v1/styles/default/mappings/EDGE_WIDTH body=[ { "mappingType": "discrete", "mappingColumn": "Weight", "mappingColumnType": "Double", "visualProperty": "EDGE_WIDTH", "map": [ { "key": 1, "value": "8.10775527898214" }, { "key": 0.1, "value": "5.80517018598809" }, { "key": 0.01, "value": "3.50258509299405" }, { "key": 0.001, "value": "1.2" }, { "key": 1, "value": "8.10775527898214" }, { "key": 4, "value": "9.49404964010203" }, { "key": 7, "value": "10.0536654280374" }, { "key": 10, "value": "10.4103403719762" }, { "key": 1, "value": "8.10775527898214" }, { "key": 0.1, "value": "5.80517018598809" }, { "key": 0.01, "value": "3.50258509299405" }, { "key": 0.001, "value": "1.2" }, { "key": 1, "value": "8.10775527898214" }, { "key": 0.75, "value": "7.82007320653036" }, { "key": -0.5, "value": "7.41460809842219" }, { "key": 0.5, "value": "7.41460809842219" }, { "key": 0.6, "value": "7.59692965521615" }, { "key": 0.7, "value": "7.7510803350434" }, { "key": 0.8, "value": "7.88461172766793" }, { "key": 100, "value": "12.7129254649702" }, { "key": 1, "value": "8.10775527898214" }, { "key": 2, "value": "8.80090245954208" } ] } ] Error in cyrestPUT(paste("styles", style.name, "mappings", visual.prop.name, :
Note that using continuous ("c") or passthrough ("p") does not give an error but the continuous function does not have the desired affect on edge width.
Here is my test case:
Edge key
interaction <- 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")
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"))
myarrows <- c ('Arrow', 'Arrow', 'Arrow', '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', 'No Arrow', 'No Arrow', 'No Arrow')
edge_key.tbl <- data.frame(interaction, colors=c("red", "red", "magenta", "violet", "purple", "green", "green2", "green3", "aquamarine2", "cyan", "turquoise2", "cyan2", "lightseagreen", "gold", "blue", "yellow", "slategrey", "darkslategrey", "grey", "black", "orange", "orange2"), myarrows, Weight=c(10^-seq(0, 3, length.out = 4), seq(1, 11, 3), 10^-seq(0, 3, length.out = 4), 1, 0.75, -0.5, seq(0.5, 0.8, 0.1), 100, 1:2))
edgefile <- data.frame(source=LETTERS[1:22], target=paste(LETTERS[1:22], 1, sep="")) edgefile <- cbind(edgefile, edge_key.tbl) edgefile[20, 2] <- "T1 p 100"
The alternate weight attemps to drive negative correlations far away in certain layouts (force-directed; spring-embedded)
negs <- edgefile[edgefile $Weight<0,'Weight'] frnegs <- exp (negs*20)
plot (negs,frnegs)
nodefile <- data.frame(id=c(edgefile$source, edgefile$target), nodeType="unknown") edgekey.suid <- createNetworkFromDataFrames(nodefile, edgefile, title=paste("Edge Key", 1+length(getNetworkList())), collection = "Keys")
factor=1.2 line.widths <- log(abs(edgefile$Weight)) + factor - min(log(abs(edgefile$Weight)))
data.frame(edgefile$Weight, line.widths) setEdgeLineWidthMapping("Weight", table.column.values=edgefile$Weight, mapping.type = "d", widths=line.widths, default.width=1.2) [[[ERROR ABOVE]]]
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] igraph_1.2.1 gplots_3.0.1 dplyr_0.7.5 plyr_1.8.4 RCy3_2.0.1
loaded via a namespace (and not attached): [1] Rcpp_0.12.17 pillar_1.2.3 compiler_3.5.0 bindr_0.1.1 bitops_1.0-6
[6] base64enc_0.1-3 tools_3.5.0 digest_0.6.15 jsonlite_1.5 evaluate_0.10.1
[11] tibble_1.4.2 pkgconfig_2.0.1 rlang_0.2.1 graph_1.58.0 curl_3.2
[16] yaml_2.1.19 parallel_3.5.0 bindrcpp_0.2.2 httr_1.3.1 stringr_1.3.1
[21] knitr_1.20 gtools_3.5.0 caTools_1.17.1 stats4_3.5.0 rprojroot_1.3-2
[26] tidyselect_0.2.4 glue_1.2.0 R6_2.2.2 XML_3.98-1.11 rmarkdown_1.10
[31] RJSONIO_1.3-0 gdata_2.18.0 purrr_0.2.5 magrittr_1.5 backports_1.1.2
[36] htmltools_0.3.6 BiocGenerics_0.26.0 assertthat_0.2.0 KernSmooth_2.23-15 stringi_1.2.3
Mark