forked from mj163163/ggcor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
90 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: ggcor | ||
Type: Package | ||
Title: Extended tools for correlation analysis and visualization | ||
Version: 0.9.4.2 | ||
Version: 0.9.4.3 | ||
Authors@R: c( | ||
person("Houyun", "Huang", email = "[email protected]", role = c("aut", "cre")), | ||
person("Lei", "Zhou", email = "[email protected]", role = "aut"), | ||
|
This file contains 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 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 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 |
---|---|---|
@@ -1,54 +1,58 @@ | ||
#' Corece to a igraph object | ||
#' @description Functions to coerce a object to igraph if possible. | ||
#' @param x \code{R} object. | ||
#' @param directed logical value, whether or not to create a directed graph. | ||
#' @param ... extra params. | ||
#' @return igraph object. | ||
#' @importFrom igraph graph_from_data_frame as.igraph | ||
#' @rdname as_igraph | ||
#' @examples | ||
#' fortify_cor(mtcars) %>% as.igraph() | ||
#' correlate(mtcars, cor.test = TRUE) %>% as.igraph() | ||
#' @author Houyun Huang, Lei Zhou, Jian Chen, Taiyun Wei | ||
#' @export | ||
as.igraph.cor_tbl <- function(x, ...) | ||
as.igraph.cor_tbl <- function(x, directed = FALSE, ...) | ||
{ | ||
x <- as_cor_network(x, ...) | ||
igraph::graph_from_data_frame(x$edges, directed = FALSE, | ||
igraph::graph_from_data_frame(x$edges, directed = directed, | ||
vertices = x$nodes) | ||
} | ||
|
||
#' @rdname as_igraph | ||
#' @export | ||
as.igraph.mantel_tbl <- function(x, ...) | ||
as.igraph.mantel_tbl <- function(x, directed = FALSE, ...) | ||
{ | ||
as.igraph(as_cor_tbl(x), ...) | ||
as.igraph(as_cor_tbl(x), directed = directed, ...) | ||
} | ||
|
||
#' @rdname as_igraph | ||
#' @importFrom tidygraph tbl_graph | ||
#' @export | ||
as.igraph.rcorr <- function(x, ...) | ||
as.igraph.rcorr <- function(x, directed = FALSE, ...) | ||
{ | ||
p.value <- x$P | ||
diag(p.value) <- 0 | ||
cor_network(x$r, p.value, ..., val.type = "igraph") | ||
cor_network(x$r, p.value, directed = directed, ..., val.type = "igraph") | ||
} | ||
|
||
#' @rdname as_igraph | ||
#' @export | ||
as.igraph.corr.test <- function(x, ...) | ||
as.igraph.corr.test <- function(x, directed = FALSE, ...) | ||
{ | ||
cor_network(x$r, x$p, ..., val.type = "igraph") | ||
cor_network(x$r, x$p, directed = directed, ..., val.type = "igraph") | ||
} | ||
|
||
#' @rdname as_igraph | ||
#' @export | ||
as.igraph.correlate <- function(x, ...) | ||
as.igraph.correlate <- function(x, directed = FALSE, ...) | ||
{ | ||
cor_network(x$r, x$p.value, ..., val.type = "igraph") | ||
cor_network(x$r, x$p.value, directed = directed, ..., val.type = "igraph") | ||
} | ||
|
||
#' @importFrom igraph graph_from_data_frame | ||
#' @rdname as_igraph | ||
#' @export | ||
as.igraph.cor_network <- function(x, ...) | ||
as.igraph.cor_network <- function(x, directed = FALSE, ...) | ||
{ | ||
igraph::graph_from_data_frame(x$edges, FALSE, x$nodes) | ||
igraph::graph_from_data_frame(x$edges, directed, x$nodes) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,54 +1,57 @@ | ||
#' Corece to a graph_tbl object | ||
#' @description Functions to coerce a object to graph_tbl if possible. | ||
#' @param x \code{R} object. | ||
#' @param directed logical value, whether or not to create a directed graph. | ||
#' @param ... extra params. | ||
#' @return tbl_graph object. | ||
#' @importFrom tidygraph tbl_graph as_tbl_graph | ||
#' @rdname as_tbl_graph | ||
#' @author Houyun Huang, Lei Zhou, Jian Chen, Taiyun Wei | ||
#' @export | ||
as_tbl_graph.cor_tbl <- function(x, ...) | ||
as_tbl_graph.cor_tbl <- function(x, directed = FALSE, ...) | ||
{ | ||
x <- as_cor_network(x, ...) | ||
tidygraph::tbl_graph(nodes = x$nodes, | ||
edges = x$edges, directed = FALSE) | ||
edges = x$edges, directed = directed) | ||
} | ||
|
||
|
||
#' @rdname as_tbl_graph | ||
#' @export | ||
as_tbl_graph.mantel_tbl <- function(x, ...) | ||
as_tbl_graph.mantel_tbl <- function(x, directed = FALSE, ...) | ||
{ | ||
as_tbl_graph(as_cor_tbl(x), ...) | ||
as_tbl_graph(as_cor_tbl(x), directed = directed, ...) | ||
} | ||
|
||
#' @rdname as_tbl_graph | ||
#' @export | ||
as_tbl_graph.rcorr <- function(x, ...) | ||
as_tbl_graph.rcorr <- function(x, directed = FALSE, ...) | ||
{ | ||
p.value <- x$P | ||
diag(p.value) <- 0 | ||
cor_network(x$r, p.value, ..., val.type = "tbl_graph") | ||
cor_network(x$r, p.value, directed = directed, ..., val.type = "tbl_graph") | ||
} | ||
|
||
#' @rdname as_tbl_graph | ||
#' @export | ||
as_tbl_graph.corr.test <- function(x, ...) | ||
as_tbl_graph.corr.test <- function(x, directed = FALSE, ...) | ||
{ | ||
cor_network(x$r, x$p, ..., val.type = "tbl_graph") | ||
cor_network(x$r, x$p, directed = directed, ..., val.type = "tbl_graph") | ||
} | ||
|
||
#' @rdname as_tbl_graph | ||
#' @export | ||
as_tbl_graph.correlate <- function(x, ...) | ||
as_tbl_graph.correlate <- function(x, directed = FALSE, ...) | ||
{ | ||
cor_network(x$r, x$p.value, ..., val.type = "tbl_graph") | ||
cor_network(x$r, x$p.value, directed = directed, ..., val.type = "tbl_graph") | ||
} | ||
|
||
#' @importFrom tidygraph tbl_graph | ||
#' @rdname as_tbl_graph | ||
#' @export | ||
as_tbl_graph.cor_network <- function(x, ...) | ||
{ | ||
tidygraph::tbl_graph(nodes = x$nodes, edges = x$edges, directed = FALSE) | ||
directed <- attr(x, "directed") | ||
tidygraph::tbl_graph(nodes = x$nodes, edges = x$edges, | ||
directed = directed %||% FALSE) | ||
} |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.