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
1 parent
e5d69cc
commit dc73515
Showing
38 changed files
with
1,294 additions
and
1,008 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
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
This file was deleted.
Oops, something went wrong.
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,29 +1,41 @@ | ||
#' @title Compute and rank TFs in network | ||
#' | ||
#' @param weightDT The weight data table of network | ||
#' @param directedGraph If GRN is directed or not | ||
#' @param weight_table The weight data table of network | ||
#' @param directed If GRN is directed or not | ||
#' | ||
#' @return A data.table with three columns | ||
#' @export | ||
#' | ||
#' @examples | ||
#' library(inferCSN) | ||
#' data("exampleMatrix") | ||
#' weightDT <- inferCSN(exampleMatrix) | ||
#' ranks <- compute.gene.rank(weightDT) | ||
#' data("example_matrix") | ||
#' weight_table <- inferCSN(example_matrix) | ||
#' ranks <- compute.gene.rank(weight_table) | ||
#' head(ranks) | ||
#' | ||
compute.gene.rank <- function(weightDT, | ||
directedGraph = FALSE) { | ||
colnames(weightDT) <- c("regulatory", "target", "weight") | ||
weightDT$weight <- abs(weightDT$weight) | ||
tfnet <- igraph::graph_from_data_frame(weightDT, directed = directedGraph) | ||
pageRank <- data.frame(igraph::page_rank(tfnet, directed = directedGraph)$vector) | ||
colnames(pageRank) <- c("pageRank") | ||
pageRank$gene <- rownames(pageRank) | ||
pageRank <- pageRank[, c("gene", "pageRank")] | ||
pageRank <- pageRank[order(pageRank$pageRank, decreasing = TRUE), ] | ||
pageRank$isRegulator <- FALSE | ||
pageRank$isRegulator[pageRank$gene %in% unique(weightDT$regulatory)] <- TRUE | ||
return(pageRank) | ||
compute.gene.rank <- function( | ||
weight_table, | ||
directed = FALSE) { | ||
colnames(weight_table) <- c("regulatory", "target", "weight") | ||
weight_table$weight <- abs(weight_table$weight) | ||
tfnet <- igraph::graph_from_data_frame( | ||
weight_table, | ||
directed = directed | ||
) | ||
page_rank_res <- data.frame( | ||
igraph::page_rank(tfnet, directed = directed)$vector | ||
) | ||
colnames(page_rank_res) <- c("pageRank") | ||
page_rank_res$gene <- rownames(page_rank_res) | ||
page_rank_res <- page_rank_res[, c("gene", "pageRank")] | ||
page_rank_res <- page_rank_res[order( | ||
page_rank_res$pageRank, | ||
decreasing = TRUE | ||
), ] | ||
page_rank_res$isRegulator <- FALSE | ||
page_rank_res$isRegulator[ | ||
page_rank_res$gene %in% unique( | ||
weight_table$regulatory | ||
) | ||
] <- TRUE | ||
return(page_rank_res) | ||
} |
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
Oops, something went wrong.