Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
update R package
- Loading branch information
Ghanbari
committed
Oct 5, 2017
1 parent
cffdbc9
commit 4077cc3
Showing
6 changed files
with
104 additions
and
102 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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#' Function to apply kmeans clustering on the score of links | ||
#' | ||
#' @param score_matrix score matrix obtained from DPM or reg.DPM. | ||
#' | ||
#' @return a list containing | ||
#' - the list of the links as a data frame. Each line of the data frame corresponds to a link. | ||
#' The first and second columns are the corresponding nodes of the link and the third column is the score of the link. | ||
#' - the threshold that all the links with scores more than it are considered as an edge. | ||
#' | ||
#' @examples | ||
#' ## Load DREAM4 data (insilico_size10_1_knockouts) | ||
#' data(dream4) | ||
#' | ||
#'## Run regularized DPM | ||
#' res <- reg.dpm(data) | ||
#' | ||
#' ## Get the list of the links based on kmeans clustering | ||
#' linklist <- kmeans_links(res)$LinkList | ||
#' | ||
#' ##Get the threshold at significance level alpha=0.05 | ||
#' kmeans_links(res)$threshold | ||
#' | ||
#' | ||
#' @export | ||
|
||
########################################################### | ||
### Function to compute fisher z transformation pvalues ### | ||
########################################################### | ||
kmeans_links <- function(score_matrix){ | ||
score_matrix <- abs(score_matrix) | ||
diag(score_matrix) <- NA | ||
score_matrix[upper.tri(score_matrix)] <- NA | ||
linkList <- reshape2::melt(score_matrix, na.rm=TRUE) | ||
colnames(linkList) <- c("Node1", "Node2", "Score") | ||
|
||
# do kmeans on scores | ||
res = kmeans(linkList$Score, centers=2) | ||
linkList <- linkList[res$cluster==which.max(res$centers),] | ||
|
||
# compute threshold | ||
threshold = mean(a$centers) | ||
|
||
return(list(LinkList=linkList,threshold=threshold)) | ||
} | ||
|
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.