cytoscape / RCy3

New version of RCy3, redesigned and collaboratively maintained by Cytoscape developer community
MIT License
49 stars 20 forks source link

Missing edge attributes in networks with multiple edges #203

Closed jd690764 closed 1 year ago

jd690764 commented 1 year ago

I have a similar issue as in #41. I repeated the first example and some of the attributes are not shown in the edge table (see attached screenshot).

RCy3 - 2.18.0 iGraph - 1.4.2 Cytoscape - 3.9.1 R - 4.2.2

Screenshot 2023-05-09 at 6 28 11 PM

Any help would be much appreciated. Thanks, Janos

AlexanderPico commented 1 year ago

Indeed. We fixed this in March of 2021 (#115), but then broke it again 7 months later trying to fix #139. We need to try again and thoroughly test all the various edge cases.

@jd690764 As a immediate fix, you can run this code to replace the function with the older version that works for your use case:

.edgeNameToEdgeSUID<-function(edge.names, network=NULL, base.url=.defaultBaseUrl) {
        dict <- getTableColumns('edge',c('SUID','name'),'default',network, base.url)
        test <- vapply(edge.names, function(x){x %in% dict[,'SUID']}, logical(1))
        if(all(test))  #provided SUIDs already!
            return(edge.names)
        sorted.dict <- NULL
        if(length(edge.names) == length(unique(edge.names))){ #unique edge names
            sorted.dict <- dict[match(edge.names, dict$name), ] 
        } else { #multigraph: multiple edges with the same name
            message("Finding unique SUIDs for edges with the same name...\n")
            match_list <- list()
            for(i in seq_along(edge.names)){ #perform match with removal
                name_match <- dict[match(edge.names[[i]], dict$name),]
                match_list[[i]] <- name_match
                dict <- subset(dict, SUID != name_match$SUID)
            }
            sorted.dict <- do.call(rbind, match_list)
        }
        edge.SUIDs <- sorted.dict$SUID
        return(edge.SUIDs)
}
yihangx commented 1 year ago

@jd690764 Hi, this bug is fixed. To use the latest RCy3, you can either clone the RCy3 repo and build devel branch locally by running devtools::document(), or you can download development version 2.21.1 from https://bioconductor.org/packages/devel/bioc/html/RCy3.html, it take few days to see update in the bioconductor website.

AlexanderPico commented 1 year ago

@jd690764 No need to clone and build. You can install R packages directly from GitHub with these steps from our README:

install.packages("devtools")
library(devtools)
install_github('cytoscape/RCy3', build_vignettes=FALSE)
library(RCy3)
jd690764 commented 1 year ago

Thank you! Janos

On Fri, May 19, 2023 at 11:59 AM Alexander Pico @.***> wrote:

@jd690764 https://github.com/jd690764 No need to clone and build. You can install R packages directly from GitHub with these steps from our README:

install.packages("devtools") library(devtools) install_github('cytoscape/RCy3', build_vignettes=FALSE) library(RCy3)

— Reply to this email directly, view it on GitHub https://github.com/cytoscape/RCy3/issues/203#issuecomment-1555101315, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP7QY263HEG3EFFQCJUFRTXG67JNANCNFSM6AAAAAAX4BQ72U . You are receiving this because you were mentioned.Message ID: @.***>