#' Initializer for mikado
#'
#' Add description here
#'
#' @param object a mikadoDataSet
#' @param initializer the output of the function initializer
#' @param control list of control arguments from controlEM()
#'
#' @return
#' Add return here
#'
#' @author Pedro L. Baldoni, \email{pedrobaldoni@gmail.com}
#' @references
#' \url{https://github.com/plbaldoni/epigraHMM}
#'
#' @import data.table
#' @importFrom stats rbinom dbinom glm quasibinomial
#' @rawNamespace import(SummarizedExperiment, except = shift)
#' @rawNamespace import(S4Vectors, except = c(first,second))
#' @importFrom foreach %dopar%
#' @importFrom magrittr %<>%
#'
#' @export
assignClusters <- function(object,initializer,control){
# Creating control elements
for(i in seq_along(control)){assign(names(control)[i],control[[i]])}
# Running heatmaps
if(is.null(clusters)){
# Plotting without assignments
pheatmap::pheatmap(as.matrix(initializer$dist),
color=viridis::magma(255),
cluster_rows=initializer$hclust,
cluster_cols=initializer$hclust,
border_color = NA,
show_rownames=FALSE, show_colnames=FALSE)
# Getting input from the user
clusters <- utils::menu(1:10, title="How many clusters you want to asssign?")
}
# Updating assignments
SummarizedExperiment::colData(object) <- cbind(SummarizedExperiment::colData(object),
assignedClusters = as.factor(stats::cutree(tree = initializer$hclust,k = clusters)))
SummarizedExperiment::colData(object)$assignedClusters[which(unlist(lapply(initializer$par,function(x){all(is.na(x$pi))})))] <- NA
# Plotting with assignments
colClusters <- Polychrome::kelly.colors()[-c(1,2)][seq_len(clusters)]
names(colClusters) <- seq_len(clusters)
pheatmap::pheatmap(as.matrix(initializer$dist),
color=viridis::magma(255),
cluster_rows=initializer$hclust,
cluster_cols=initializer$hclust,
border_color = NA,
annotation_colors = list(Clusters = colClusters),
annotation_col=data.frame(Clusters = SummarizedExperiment::colData(object)[['assignedClusters']]),
show_rownames=FALSE, show_colnames=FALSE)
return(object)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.