Closed m-grimes closed 2 years ago
For passthrough scenarios, you don't have to provide values. The values are "passed through" from the column. So, this is the correct line:
setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2)
But this did expose a bug with the new automatic value generators (which should only be applied with continuous and discrete mappings). I will fix this bug.
In the meantime, you can trick the syntax to skip that bug and get passtrough to work with this line:
setEdgeLineWidthMapping("Weight", table.column.values="Weight", mapping.type = "p", widths=line.widths, default.width=1.2)
This simply supplied a fake value for table.column.values to workaround the bug.
Thanks Alex. setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2) still produced an error, but the second command worked.
Right. The first line is the "correct" one but will only work with the correct code, now in the github repo. We'll get this pushed to Bioconductor in a few days.
The second line is the workaround for the meantime. It is not technically correct (please replace it in your scripts in the future), but it solves your issue today :)
@yihangx Can you check if py4cy might have this same issue? Are automatic value generators triggered for passthrough and discrete cases (i.e., when they should not be)?
See fix in commit https://github.com/cytoscape/RCy3/commit/8889f55799f89e8133d0533cbd76a637191f0b74
py4cytoscape uses different logic here, and this issue is not existed.
setEdgeLineWidthMapping("Weight", table.column.values="Weight", mapping.type = "p", widths=line.widths, default.width=1.2)
setEdgeWidths.new <- function (factor=10, log=FALSE) {
edgevalues <- getTableColumns('edge',c('Weight'))
edgevalues['Weight']<-abs(edgevalues['Weight'])
if (log==FALSE) {
line.widths <- factor*abs(as.numeric(unlist(edgevalues$Weight)))
}
if (log==TRUE) {
line.widths <- log(abs(as.numeric(unlist(edgevalues$Weight)))) + factor - min(log(abs(as.numeric(unlist(edgevalues$Weight)))))
}
plot(line.widths ~ unlist(edgevalues$Weight), pch=19, col="blue")
edgevalues['Width']<-line.widths
loadTableData(edgevalues, table = 'edge', table.key.column = 'SUID')
setEdgeLineWidthMapping("Width", table.column.values="Width", mapping.type = "p",default.width=1.2)
}
A couple things to check:
setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2)
Thanks Alex! I did note that sometimes the value loaded in this way to "Width" differed in the Cytoscape edge table view, but when retrieved back to R it was actually correct. Not sure why, and if it affects anything.
I will update RCy3 and see if the following is fixed:
setEdgeLineWidthMapping("Width", mapping.type = "p",default.width=1.2) style.name not specified, so updating "default" style. Error in .autoTableColumnValues(table, table.column, mapping.type, network, : Automatic palette mapping doesn't work for passthrough mappings. setEdgeLineWidthMapping("Width", table.column.values="Width", mapping.type = "p",default.width=1.2) style.name not specified, so updating "default" style. style.name not specified, so updating "default" style. NULL
Alex
I still get the error with RCy3_2.14.1
setEdgeLineWidthMapping("Width", mapping.type = "p",default.width=1.2)
Error in .autoTableColumnValues(table, table.column, mapping.type,
network, : Automatic palette mapping doesn't work for passthrough mappings.
But not with setEdgeLineWidthMapping("Width", table.column.values="Width", mapping.type = "p",default.width=1.2).
Mark
sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Monterey 12.0.1
RCy3_2.14.1
On 16 Nov 2021, at 14:57, Alexander Pico wrote:
A couple things to check:
- When you perform a passthrough mapping you do not need to provide values. The idea behind passthrough is the the desired values are already in a Cytoscape table, so all you need to do is tell Cytoscape which column. That's it (default.width is optional).
setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2)
- There was a bug with passthrough mapping that this issue exposed last week, so I provided a temporary fix where you give a fake value, but I've since fixed the bug. It was immediately vai github and at bioconductor a couple days later. Use the latest version, 2.14.1
(https://bioconductor.org/packages/release/bioc/html/RCy3.html), and the syntax above.-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/164#issuecomment-970714921
Is your column called "Width" or "Weight"? Typo in ticket or in your code?
It is Width
setEdgeLineWidthMapping("Width", table.column.values="Width",
mapping.type = "p",default.width=1.2) Vs.
setEdgeLineWidthMapping("Width", mapping.type = "p",default.width=1.2)
In the wrapper function (alternatives above commented out to test):
setEdgeWidths.new <- function (factor=10, log=FALSE) {
edgevalues <- getTableColumns('edge',c('Weight'))
edgevalues['Weight']<-abs(edgevalues['Weight'])
if (log==FALSE) {
line.widths <- factor*abs(as.numeric(unlist(edgevalues$Weight)))
}
if (log==TRUE) {
line.widths <- log(abs(as.numeric(unlist(edgevalues$Weight)))) +
factor - min(log(abs(as.numeric(unlist(edgevalues$Weight))))) } plot(line.widths ~ unlist(edgevalues$Weight), pch=19, col="blue") edgevalues['Width']<-line.widths loadTableData(edgevalues, table = 'edge', table.key.column = 'SUID') setEdgeLineWidthMapping("Width", table.column.values="Width", mapping.type = "p",default.width=1.2)
#setEdgeLineWidthMapping("Width", mapping.type =
"p",default.width=1.2) }
On 18 Nov 2021, at 10:59, Alexander Pico wrote:
Is your column called "Width" or "Weight"? Typo in ticket or in your code?
-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/164#issuecomment-973119584
Going back to your original test case, this works for me:
test.edges <- data.frame(source=LETTERS[1:5], target=LETTERS[3:7], interaction="testing", Weight=c(0.0001, 0.001, 0.1, 1, 10))
test.df <- data.frame(id=unique(c(test.edges$source, test.edges$target)))
suid <- createNetworkFromDataFrames(test.df, test.edges, title="test network", collection = "Interactions")
line.widths <- log((test.edges$Weight)) + 2 - min(log((test.edges$Weight)))
edgevalues <- getTableColumns('edge',c('name','Weight'))
edgevalues['Weight'] <- abs(line.widths)
setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2)
Does this work for you?
Still got the error (pasting in the code below):
setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2) style.name not specified, so updating "default" style. Error in .autoTableColumnValues(table, table.column, mapping.type, network, : Automatic palette mapping doesn't work for passthrough mappings.
On 18 Nov 2021, at 16:56, Alexander Pico wrote:
Going back to your original test case, this works for me:
test.edges <- data.frame(source=LETTERS[1:5], target=LETTERS[3:7], interaction="testing", Weight=c(0.0001, 0.001, 0.1, 1, 10)) test.df <- data.frame(id=unique(c(test.edges$source, test.edges$target))) suid <- createNetworkFromDataFrames(test.df, test.edges, title="test network", collection = "Interactions") line.widths <- log((test.edges$Weight)) + 2 - min(log((test.edges$Weight))) edgevalues <- getTableColumns('edge',c('name','Weight')) edgevalues['Weight'] <- abs(line.widths) setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2)
Does this work for you?
-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/164#issuecomment-973482561
Huh. Somehow you are still running the old RCy3. Could try reinstalling or instaling the dev version from github... The latest code can't generate that error for mapping.type = "p"
.
The auto.map is only run when mapping.type = "c":
https://github.com/cytoscape/RCy3/blob/master/R/StyleMappings.R#L1674
Strange. This might be too big to send by email but I used terminal R CMD INSTALL with this: https://www.dropbox.com/s/q07dqc7ilkrb3em/RCy3_2.14.1.tar?dl=0 Downloaded from Bioconductor
On 19 Nov 2021, at 15:42, Alexander Pico wrote:
Huh. Somehow you are still running the old RCy3. Could try reinstalling or instaling the dev version from github... The latest code can't generate that error for
mapping.type = "p"
.-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/164#issuecomment-974520022
Strange indeed!
Curiouser and curiouser:
install_github('cytoscape/RCy3', build_vignettes=TRUE) Downloading GitHub repo @.*** ✓ checking for file ‘/private/var/folders/k5/l4w2ty9s7pj07jjczbc_yv3c0000gp/T/RtmpSq9DQD/remotes16a77b069e66/cytoscape-RCy3-dfd6fdc/DESCRIPTION’ ... ─ preparing ‘RCy3’: ✓ checking DESCRIPTION meta-information ... ─ installing the package to build vignettes (380ms) ✓ creating vignettes (21.6s) ─ checking for LF line-endings in source and make files and shell scripts ─ checking for empty or unneeded directories ─ building ‘RCy3_2.15.1.tar.gz’
library(RCy3) setEdgeLineWidthMapping("Weight", mapping.type = "p", default.width=1.2) style.name not specified, so updating "default" style. Error in .autoTableColumnValues(table, table.column, mapping.type, network, : Automatic palette mapping doesn't work for passthrough mappings.
SessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Monterey 12.0.1 RCy3_2.15.1
On 19 Nov 2021, at 15:50, Alexander Pico wrote:
Strange indeed!
-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/cytoscape/RCy3/issues/164#issuecomment-974523208
Alex & co. Either I'm not doing something correctly or setEdgeLineWidthMapping is not working correctly. I have the following test case to demonstrate the issue. I am trying to plot networks with a wide range of edge values and render the edge widths in a way such that some edges are not invisibly thin and other not too thick. Thanks for your help - Mark
R version 4.1.1 (2021-08-10) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 11.6 Cytoscape 3.9 RCy3_2.12.4
Test case
test.edges <- data.frame(source=LETTERS[1:5], target=LETTERS[3:7], interaction="testing", Weight=c(0.0001, 0.001, 0.1, 1, 10)) test.df <- data.frame(id=unique(c(test.edges$source, test.edges$target))) suid <- createNetworkFromDataFrames(test.df, test.edges, title="test network", collection = "Interactions") line.widths <- log((test.edges$Weight)) + 2 - min(log((test.edges$Weight))) edgevalues <- getTableColumns('edge',c('name','Weight')) edgevalues['Weight'] <- abs(line.widths) setEdgeLineWidthMapping("Weight", table.column.values=edgefile$Weight, mapping.type = "p", widths=line.widths, default.width=1.2)
Note: does not use line.widths as edge widths, uses test.edges$Weight
setEdgeLineWidthMapping("Weight", table.column.values=edgefile$Weight, mapping.type = "d", widths=line.widths, default.width=1.2)
Produces error:
style.name not specified, so updating "default" style.
style.name not specified, so updating "default" style.
Error: Not Found
Error in .cyFinally(res) : object 'res' not found
names(edgevalues)<-c('name', 'Width') loadTableData(edgevalues, table = 'edge', table.key.column = 'SUID') setEdgeLineWidthMapping('Width', mapping.type = 'p', style.name = 'default')
Error in .autoTableColumnValues(table, table.column, mapping.type, network, :
Automatic palette mapping doesn't work for passthrough mappings.
setEdgeLineWidthMapping('Width', mapping.type = 'd', style.name = 'default')
Edges are way too fat! Compare this, which produces the desired result:
setEdgeLineWidthBypass(edgevalues[['name']], edgevalues[['Width']])
But now subsequent commands have no effect:
setEdgeLineWidthMapping('Weight', mapping.type = 'd', style.name = 'default') # returns NULL setEdgeLineWidthMapping('Width', mapping.type = 'd', style.name = 'default') # returns NULL
FYI the following never work either. I'd like to set this to distinguish selected edges when I use red as an edge color.
setEdgeSelectionColorDefault ( "#FF69B4") # should be hotpink, is still red setEdgeSelectionColorDefault ( "#00FF00") # should be green, is still red