Skip to content

Commit

Permalink
latest files
Browse files Browse the repository at this point in the history
  • Loading branch information
xlucpu committed Nov 11, 2020
1 parent 90fa2d5 commit 7b9d388
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
Binary file modified MOVICS.pdf
Binary file not shown.
9 changes: 3 additions & 6 deletions R/getIntNMF.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#' @description This function wraps the IntNMF (Integrative Clustering via Non-negative Matrix Factorization) algorithm and provides standard output for `getMoHeatmap()` and `getConsensusMOIC()`.
#' @param data List of matrices.
#' @param N.clust Number of clusters.
#' @param is.binary A logical vector to indicate if the input for a subset is binary of 0 and 1.
#' @param type Data type corresponding to the list of matrics, which can be gaussian, binomial or possion.
#' @return A list with the following components:
#'
Expand All @@ -19,8 +18,7 @@
#' @references Chalise P, Fridley BL (2017). Integrative clustering of multi-level omic data based on non-negative matrix factorization algorithm. PLoS One, 12(5):e0176278.
getIntNMF <- function(data = NULL,
N.clust = NULL,
type = rep("gaussian", length(data)),
is.binary = rep(FALSE, length(data))){
type = rep("gaussian", length(data))){

# check data
n_dat <- length(data)
Expand All @@ -31,10 +29,9 @@ getIntNMF <- function(data = NULL,
stop('current verision of MOVICS needs at least 2 omics data.')
}

useless.argument <- type
# remove features that made of categories not equal to 2 otherwise Error in svd(X) : a dimension is zero
if(!all(!is.binary)) {
bindex <- which(is.binary == TRUE)
if(is.element("binomial",type)) {
bindex <- which(type == "binomial")
for (i in bindex) {
a <- which(rowSums(data[[i]]) == 0)
b <- which(rowSums(data[[i]]) == ncol(data[[i]]))
Expand Down
22 changes: 12 additions & 10 deletions R/getiClusterBayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,20 @@ getiClusterBayes <- function(data = NULL,
# remove features that made of categories not equal to 2
if(is.element("binomial",type)) {
bindex <- which(type == "binomial")
a <- which(rowSums(data[[bindex]]) == 0)
b <- which(rowSums(data[[bindex]]) == ncol(data[[bindex]]))
if(length(a) > 0) {
data[[bindex]] <- data[[bindex]][which(rowSums(data[[bindex]]) != 0),] # remove all zero
}
for (i in bindex) {
a <- which(rowSums(data[[i]]) == 0)
b <- which(rowSums(data[[i]]) == ncol(data[[i]]))
if(length(a) > 0) {
data[[i]] <- data[[i]][which(rowSums(data[[i]]) != 0),] # remove all zero
}

if(length(b) > 0) {
data[[bindex]] <- data[[bindex]][which(rowSums(data[[bindex]]) != ncol(data[[bindex]])),] # remove all one
}
if(length(b) > 0) {
data[[i]] <- data[[i]][which(rowSums(data[[i]]) != ncol(data[[i]])),] # remove all one
}

if(length(a) + length(b) > 0) {
message(paste0("remove a total of ",length(a) + length(b), " features because their categories are not equal to 2!"))
if(length(a) + length(b) > 0) {
message(paste0("--", names(data)[i],": a total of ",length(a) + length(b), " features were removed due to the categories were not equal to 2!"))
}
}
}

Expand Down
9 changes: 1 addition & 8 deletions man/getIntNMF.Rd

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

0 comments on commit 7b9d388

Please sign in to comment.