-
Notifications
You must be signed in to change notification settings - Fork 0
Event handler #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Event handler #98
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d5b8f34
feat(deletion): Add code to delete an edge programmatically
tonywu1999 75c147c
add a vignette for a scrappy version of shiny network viewer
tonywu1999 107e35c
Revert "add a vignette for a scrappy version of shiny network viewer"
tonywu1999 398b2dc
add edge deletion
tonywu1999 1446b4c
Update R/deleteEdgeFromNetwork.R
tonywu1999 9d2832e
fix formatting
tonywu1999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #' Delete an edge from a network edges data frame | ||
| #' | ||
| #' Removes the row(s) from an edges data frame that match the given | ||
| #' \code{source}, \code{target}, and \code{interaction} values. This is | ||
| #' the programmatic counterpart of the interactive Ctrl+click / right-click | ||
| #' edge deletion available in \code{\link{cytoscapeNetwork}}. | ||
| #' | ||
| #' @param edges Data frame with at minimum columns \code{source}, | ||
| #' \code{target}, and \code{interaction}. | ||
| #' @param source Character. The source node identifier of the edge to | ||
| #' remove. | ||
| #' @param target Character. The target node identifier of the edge to | ||
| #' remove. | ||
| #' @param interaction Character. The interaction type of the edge to remove. | ||
| #' | ||
| #' @return The \code{edges} data frame with the matching row(s) removed. | ||
| #' | ||
| #' @examples | ||
| #' edges <- data.frame( | ||
| #' source = c("TP53", "MDM2", "CDKN1A"), | ||
| #' target = c("MDM2", "TP53", "TP53"), | ||
| #' interaction = c("Activation", "Inhibition", "Activation"), | ||
| #' stringsAsFactors = FALSE | ||
| #' ) | ||
| #' deleteEdgeFromNetwork(edges, "MDM2", "TP53", "Inhibition") | ||
| #' | ||
| #' @export | ||
| deleteEdgeFromNetwork <- function(edges, source, target, interaction) { | ||
| if (!is.data.frame(edges)) { | ||
| stop("`edges` must be a data frame.") | ||
| } | ||
| if (!is.character(source) || length(source) != 1L || is.na(source)) { | ||
| stop("`source` must be a single, non-NA character value.") | ||
| } | ||
| if (!is.character(target) || length(target) != 1L || is.na(target)) { | ||
| stop("`target` must be a single, non-NA character value.") | ||
| } | ||
| if (!is.character(interaction) || length(interaction) != 1L || is.na(interaction)) { | ||
| stop("`interaction` must be a single, non-NA character value.") | ||
| } | ||
| required_cols <- c("source", "target", "interaction") | ||
| if (!all(required_cols %in% names(edges))) { | ||
| stop("`edges` must contain columns: source, target, interaction.") | ||
| } | ||
| match_row <- !is.na(edges$source) & | ||
| !is.na(edges$target) & | ||
| !is.na(edges$interaction) & | ||
| edges$source == source & | ||
| edges$target == target & | ||
| edges$interaction == interaction | ||
| keep <- !match_row | ||
| edges[keep, , drop = FALSE] | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.