Skip to content

Commit

Permalink
Merge pull request #58 from federicomarini/new_igraph
Browse files Browse the repository at this point in the history
New igraph changes - brought in for GeneTonic
  • Loading branch information
federicomarini authored Feb 16, 2024
2 parents 2689eb0 + 35bb58e commit 3456d1b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 23 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: GeneTonic
Title: Enjoy Analyzing And Integrating The Results From Differential Expression
Analysis And Functional Enrichment Analysis
Version: 2.7.1
Date: 2024-01-10
Version: 2.7.2
Date: 2024-02-16
Authors@R:
c(
person(
Expand Down Expand Up @@ -84,7 +84,7 @@ Encoding: UTF-8
VignetteBuilder: knitr
URL: https://github.com/federicomarini/GeneTonic
BugReports: https://github.com/federicomarini/GeneTonic/issues
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
biocViews:
GUI, GeneExpression, Software, Transcription, Transcriptomics, Visualization,
Expand Down
8 changes: 4 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ importFrom(igraph,V)
importFrom(igraph,add_edges)
importFrom(igraph,as_adjacency_matrix)
importFrom(igraph,as_biadjacency_matrix)
importFrom(igraph,as_edgelist)
importFrom(igraph,degree)
importFrom(igraph,delete.edges)
importFrom(igraph,delete_edges)
importFrom(igraph,delete_vertices)
importFrom(igraph,get.edgelist)
importFrom(igraph,graph.data.frame)
importFrom(igraph,graph_from_data_frame)
importFrom(igraph,induced_subgraph)
importFrom(igraph,make_full_graph)
importFrom(igraph,permute.vertices)
importFrom(igraph,permute)
importFrom(igraph,strength)
importFrom(igraph,vcount)
importFrom(matrixStats,rowSds)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Other notes

* Updated functions used from other packages to reflect changes in their API/nomenclature
* Adapted the internal code of functions to the latest version of `igraph` - no changes happening
for the end user

# GeneTonic 2.6.0

Expand Down
2 changes: 1 addition & 1 deletion R/GeneTonic-extras.R
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ export_to_sif <- function(g, sif_file = "", edge_label = "relates_to") {
sif_file <- normalizePath(sif_file, mustWork = FALSE)
stopifnot(is.character(edge_label) && length(edge_label) == 1)

el <- get.edgelist(g)
el <- as_edgelist(g)
sif_df <- data.frame(
n1 = el[, 1],
edge_label = edge_label,
Expand Down
10 changes: 4 additions & 6 deletions R/GeneTonic-pkg.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#' the live session, and creating an HTML report as an artifact where text,
#' code, and output coexist.
#'
#' @author Federico Marini \email{marinif@@uni-mainz.de}
#'
#' @importFrom AnnotationDbi Definition GOID Ontology Secondary Synonym Term
#' @importFrom backbone backbone.extract fdsm fixedrow sdsm
#' @importFrom bs4Dash bs4Card bs4DashBody bs4DashControlbar
Expand Down Expand Up @@ -43,8 +41,8 @@
#' @importFrom grDevices colorRampPalette rgb col2rgb
#' @importFrom grid gpar
#' @importFrom igraph add_edges as_adjacency_matrix as_biadjacency_matrix degree
#' delete.edges delete_vertices "%du%" E "E<-" graph.data.frame induced_subgraph
#' make_full_graph permute.vertices strength V "V<-" vcount get.edgelist
#' delete_edges delete_vertices "%du%" E "E<-" graph_from_data_frame induced_subgraph
#' make_full_graph permute strength V "V<-" vcount as_edgelist
#' @importFrom matrixStats rowSds
#' @importFrom methods is
#' @importFrom plotly ggplotly plotlyOutput renderPlotly plot_ly layout add_trace
Expand All @@ -71,5 +69,5 @@
#' @importFrom viridis viridis
#'
#' @name GeneTonic-pkg
#' @docType package
NULL
#' @keywords internal
"_PACKAGE"
4 changes: 2 additions & 2 deletions R/GeneTonic.R
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ GeneTonic <- function(dds = NULL,
# rank_gs <- rank(V(g)$name[V(g)$nodetype == "GeneSet"])
# rank_feats <- rank(V(g)$name[V(g)$nodetype == "Feature"]) +
# length(rank_gs) # to keep the GeneSets first
# g <- permute.vertices(g, c(rank_gs, rank_feats))
# g <- permute(g, c(rank_gs, rank_feats))
# return(g)
})

Expand Down Expand Up @@ -1288,7 +1288,7 @@ GeneTonic <- function(dds = NULL,
color_by = input$emap_colorby
)
# rank_gs <- rank(V(emg)$name)
# emg <- permute.vertices(emg, rank_gs)
# emg <- permute(emg, rank_gs)
return(emg)
})

Expand Down
6 changes: 3 additions & 3 deletions R/enrichment_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ enrichment_map <- function(res_enrich,
# omm <- omm[!is.na(omm$value), ]

# use this to construct the graph
emg <- graph.data.frame(omm[, c(1, 2)], directed = FALSE)
emg <- graph_from_data_frame(omm[, c(1, 2)], directed = FALSE)

E(emg)$width <- sqrt(omm$value * scale_edges_width)
emg <- delete.edges(emg, E(emg)[omm$value < overlap_threshold])
emg <- delete_edges(emg, E(emg)[omm$value < overlap_threshold])

idx <- match(V(emg)$name, res_enrich$gs_description)

Expand Down Expand Up @@ -237,7 +237,7 @@ enrichment_map <- function(res_enrich,

# re-sorting the vertices alphabetically
rank_gs <- rank(V(emg)$name)
emg <- permute.vertices(emg, rank_gs)
emg <- permute(emg, rank_gs)

return(emg)
}
4 changes: 2 additions & 2 deletions R/ggs_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ ggs_graph <- function(res_enrich,
})
list2df <- do.call("rbind", list2df)

g <- graph.data.frame(list2df, directed = FALSE)
g <- graph_from_data_frame(list2df, directed = FALSE)

nodeIDs_gs <- which(names(V(g)) %in% enriched_gsnames)
nodeIDs_genes <- which(!(names(V(g)) %in% enriched_gsnames))
Expand Down Expand Up @@ -212,7 +212,7 @@ ggs_graph <- function(res_enrich,
rank_gs <- rank(V(g)$name[V(g)$nodetype == "GeneSet"])
rank_feats <- rank(V(g)$name[V(g)$nodetype == "Feature"]) +
length(rank_gs) # to keep the GeneSets first
g <- permute.vertices(g, c(rank_gs, rank_feats))
g <- permute(g, c(rank_gs, rank_feats))

return(g)
}
Expand Down
18 changes: 17 additions & 1 deletion man/GeneTonic-pkg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-gs_dendro.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_that("Gene set dendrogram is created", {
expect_is(my_dend_pval, "dendrogram")

re_subset <- res_enrich_withscores[res_enrich_withscores[1:12, ]$z_score >= 0, ]
my_dend_subset <- gs_dendro(re_subset, n_gs = 12, color_leaves_by = "z_score")
my_dend_subset <- gs_dendro(re_subset, n_gs = 18, color_leaves_by = "z_score")
expect_is(my_dend_subset, "dendrogram")

expect_warning(gs_dendro(res_enrich_withscores,
Expand Down

0 comments on commit 3456d1b

Please sign in to comment.