library(componentSkeleton) library(biclust) # test <- matrix(rbinom(400, 50, 0.4), 20, 20) execute <- function( cf ) { # Input and parameters matr <- CSV.read(get.input(cf, 'in')) delta <- get.parameter(cf, 'delta', 'float') alpha <- get.parameter(cf, 'alpha', 'float') number <- get.parameter(cf, 'number', 'float') plot <- get.parameter(cf, 'plot', 'boolean') idColumn <- get.parameter(cf, 'idColumn', 'string') # Check input data if (idColumn != ""){ idx <- which(colnames(matr) == idColumn) tab <- as.matrix(matr[,-idx]) row.names(tab) <- matr[,idx] } else { tab <- as.matrix(matr) } bic <- biclust(tab, method=BCCC(), delta=delta, alpha=alpha, number=number) clustcols <- apply( t(bic@NumberxCol), 2, as.numeric) colnames(clustcols) <- paste0('B',1:ncol(clustcols)) rownames(clustcols) <- colnames(tab) clustrows <- apply( bic@RowxNumber, 2, as.numeric) colnames(clustrows) <- paste0('B',1:ncol(clustrows)) rownames(clustrows) <- row.names(tab) CSV.write( get.output( cf, 'rowClusts' ), clustrows ) CSV.write( get.output( cf, 'colClusts' ), clustcols ) # Default values #diagnosticTest(BCresult, data, number = 1:BCresult@Number, verbose = TRUE, statistics = c("F", "Tukey"), sampling = TRUE, samplingtypes = NULL, nSim = 1000, alpha = 0.05, save_F = FALSE) stat <- diagnosticTest(BCresult=bic, data=tab, statistics="F",samplingtypes="Permutation") getResult <- function(x) { data.frame(test=paste0(x$table$Method, x$table$Type), pvalue=x$table$pVal) } pvals <- lapply(stat, FUN=getResult) statistics <- do.call(rbind,pvals) statistics$bicluster <- unlist(lapply(row.names(test3), function(x) substr(x,1, nchar(x)-2)) CSV.write( get.output( cf, 'statistics' ), statistics ) } main( execute ) ## Possible methods within biclust. For now choose BCCC() # ‘BCCC’: delta, alpha, number # ‘BCXmotifs’: ns, nd, sd, alpha, number # ‘BCPlaid’: cluster, fit.model, rs, background, background.layer, background.df, shuffle, iter.startup, iter.layer, back.fit, row.release, col.release, max.layers # ‘BCSpectral’: normalization, numberOfEigenvalues, minr, minc, withinVar, # ‘BCBimax’: minr, minc, number, maxc # ‘BCQuest’: ns, nd, sd, alpha, number, d, quant, vari