#################################################################################################### #################################################################################################### ## function to convert an instance of class "Factorization" from ## package fabia to an instance of class "biclust" from package biclust ## ## minr: define the minimum number of row cluster members, clusters with less members will not be extracted ## (minr=30 was used in the Hochreiter et al. 2010) ## minc: define the minimum number of column cluster members, clusters with less members will not be extracted ## (minc=5 was used in the Hochreiter et al. 2010) ## resFab: results of a fabia run -> instance of class "Factorization" ## thresZ: threshold for sample belonging to bicluster; default 0.5. ## thresL: threshold for loading belonging to bicluster (if not given it is estimated). ## For additional information on thresZ and thresL please see the extractBic man-page via "? extractBic" ## ## example: ## dat <- makeFabiDataBlocks(n = 100,l= 50,p = 3,f1 = 5,f2 = 5, ## of1 = 5,of2 = 10,sd_noise = 3.0,sd_z_noise = 0.2,mean_z = 2.0, ## sd_z = 1.0,sd_l_noise = 0.2,mean_l = 3.0,sd_l = 1.0) ## ## X <- dat[[1]] ## Y <- dat[[2]] ## ## resEx <- fabia(X,3,0.1,20,1.0,1.0) ## ## res_biclust <- convertFABIA2biclust(resEx,minc=2, minr=2,thresZ=0.5,thresL=NULL) ## ## for previous fabia versions please use "convertFABIA2biclust_previousVersions" ## ## res_biclust <- convertFABIA2biclust_previousVersions(resEx,minc=2, minr=2,thresZ=0.5,thresL=NULL) ## ## ## ## ======NEW VERSION====== ## ## Users reported an issue with the recent biclust package, which could be reproduced with version biclust_1.0.1: ## ## res_biclust <- convertFABIA2biclust(resEx,minc=2, minr=2,thresZ=0.5,thresL=NULL) ## Error in initialize(value, ...) : ## argument "d" is missing, with no default ## ## The new function convertFABIA2biclustNewVersion solves this issue: ## ## res_biclust <- convertFABIA2biclustNewVersion(resEx,minc=2, minr=2,thresZ=0.5,thresL=NULL) ## ## ## ## ## ## #################################################################################################### #################################################################################################### library(fabia) convertFABIA2biclust <- function(resFab, minc=2, minr=2,thresZ=0.5,thresL=NULL){ require(biclust) method <- resFab@parameters[[1]] cyc <- resFab@parameters[[2]] alpha <- resFab@parameters[[3]] spl <- resFab@parameters[[4]] spz <- resFab@parameters[[5]] p <- resFab@parameters[[6]] sL <- resFab@parameters[[7]] sZ <- resFab@parameters[[8]] n <- resFab@n l <- resFab@l La <- NULL Za <- NULL lapla <- NULL Psi <- NULL rFab <- extractBic(resFab,thresZ=thresZ,thresL=thresL) p <- length(rFab$bic[,1]) pp <- 0 for (i in 1:p) { if (rFab$bic[i,1]$binp[1]>=minr) { if (rFab$bic[i,1]$binp[2]>=minc) { pp <- pp + 1 } } } if ((p==0)||(pp==0)) { L <- matrix(0,n,1) Z <- matrix(0,1,l) pp <- 0 } else { L <- matrix(0,n,pp) Z <- matrix(0,pp,l) j <- 0 for (i in 1:p) { if (rFab$bic[i,1]$binp[1]>=minr) { if (rFab$bic[i,1]$binp[2]>=minc) { j <- j + 1 for (k in 1:rFab$bic[i,1]$binp[2]) { Z[j,rFab$numn[i,2]$numnp[k]] <- 1 } for (k in 1:rFab$bic[i,1]$binp[1]) { L[rFab$numn[i,1]$numng[k],j] <- 1 } } } } } lp<- list() lp[[1]]=method lp[[2]]=cyc lp[[3]]=alpha lp[[4]]=spl lp[[5]]=spz lp[[6]]=p lp[[7]]=sL lp[[8]]=sZ lp[[9]]=La lp[[10]]=Za lp[[11]]=lapla lp[[12]]=Psi bicB <- BiclustResult(lp,L,Z,pp) return(bicB) } convertFABIA2biclust_previousVersions <- function(resFab, minc=2, minr=2,thresZ=0.5,thresL=NULL){ require(biclust) method <- resFab@parameters[[1]] cyc <- resFab@parameters[[2]] alpha <- resFab@parameters[[3]] spl <- resFab@parameters[[4]] spz <- resFab@parameters[[5]] p <- resFab@parameters[[6]] sL <- resFab@parameters[[7]] sZ <- resFab@parameters[[8]] n <- resFab@n l <- resFab@l La <- NULL Za <- NULL lapla <- NULL Psi <- NULL rFab <- extract_bic(resFab,thresZ=thresZ,thresL=thresL) p <- length(rFab$bic[,1]) pp <- 0 for (i in 1:p) { if (rFab$bic[i,1]$binp[1]>=minr) { if (rFab$bic[i,1]$binp[2]>=minc) { pp <- pp + 1 } } } if ((p==0)||(pp==0)) { L <- matrix(0,n,1) Z <- matrix(0,1,l) pp <- 0 } else { L <- matrix(0,n,pp) Z <- matrix(0,pp,l) j <- 0 for (i in 1:p) { if (rFab$bic[i,1]$binp[1]>=minr) { if (rFab$bic[i,1]$binp[2]>=minc) { j <- j + 1 for (k in 1:rFab$bic[i,1]$binp[2]) { Z[j,rFab$numn[i,2]$numnp[k]] <- 1 } for (k in 1:rFab$bic[i,1]$binp[1]) { L[rFab$numn[i,1]$numng[k],j] <- 1 } } } } } lp<- list() lp[[1]]=method lp[[2]]=cyc lp[[3]]=alpha lp[[4]]=spl lp[[5]]=spz lp[[6]]=p lp[[7]]=sL lp[[8]]=sZ lp[[9]]=La lp[[10]]=Za lp[[11]]=lapla lp[[12]]=Psi bicB <- BiclustResult(lp,L,Z,pp) return(bicB) } convertFABIA2biclustNewVersion <- function(resFab, minc=2, minr=2,thresZ=0.5,thresL=NULL){ require(biclust) method <- resFab@parameters[[1]] cyc <- resFab@parameters[[2]] alpha <- resFab@parameters[[3]] spl <- resFab@parameters[[4]] spz <- resFab@parameters[[5]] p <- resFab@parameters[[6]] sL <- resFab@parameters[[7]] sZ <- resFab@parameters[[8]] n <- resFab@n l <- resFab@l La <- NULL Za <- NULL lapla <- NULL Psi <- NULL rFab <- extractBic(resFab,thresZ=thresZ,thresL=thresL) p <- length(rFab$bic[,1]) pp <- 0 for (i in 1:p) { if (rFab$bic[i,1]$binp[1]>=minr) { if (rFab$bic[i,1]$binp[2]>=minc) { pp <- pp + 1 } } } if ((p==0)||(pp==0)) { L <- matrix(0,n,1) Z <- matrix(0,1,l) pp <- 0 } else { L <- matrix(0,n,pp) Z <- matrix(0,pp,l) j <- 0 for (i in 1:p) { if (rFab$bic[i,1]$binp[1]>=minr) { if (rFab$bic[i,1]$binp[2]>=minc) { j <- j + 1 for (k in 1:rFab$bic[i,1]$binp[2]) { Z[j,rFab$numn[i,2]$numnp[k]] <- 1 } for (k in 1:rFab$bic[i,1]$binp[1]) { L[rFab$numn[i,1]$numng[k],j] <- 1 } } } } } lp<- list() lp[[1]]=method lp[[2]]=cyc lp[[3]]=alpha lp[[4]]=spl lp[[5]]=spz lp[[6]]=p lp[[7]]=sL lp[[8]]=sZ lp[[9]]=La lp[[10]]=Za lp[[11]]=lapla lp[[12]]=Psi bicB <- BiclustResult(lp,L,Z,pp, d=list(info="fabia biclusters")) return(bicB) }