Nothing
#' Extract the patients and genes from module
#'
#' Return the patients and genes from module under user defined setting
#'
#' @docType methods
#'
#' @name module.exact
#' @param res.module a 'seed.module' or 'cluster.module' object returned by \code{\link{seed.module}} or \code{\link{cluster.module}}
#' @param mod a module name to extract genes and patients
#' @param n.patients the patient number to return
#' @param n.genes the gene number to return
#'
#' @author Guofeng Meng
#'
#'
#'
#' @details This function is used to return the patients and genes at user defined breakpoints.
#'
#' Users can set `n.patients` or `n.genes` to define the break points of bi-clustering. But it is not allowed to set both value.
#'
#' @return A list for genes or patients.
#'
#' @examples
#' # extract the genes and patients when 200 patients are observed in M1.
#' page=module.extract(cluster.mod, 'M1', n.patients=100)
#' head(page$patients)
#' head(page$geness)
#' # find genes and patients in patient-seeded module
#' module.extract(seed.mod, names(seed.mod)[1], n.patients=50)
#' @export
module.extract <- function(res.module, mod, n.patients = NULL, n.genes = NULL) {
if (!is(res.module, "cluster.module") & !is(res.module, "seed.module") & !is(res.module,
"list"))
stop("Error: res.module: must the output of 'seed.module' or 'cluster.module'!")
if (is.null(mod))
stop("Error: mod: should be specified!")
if (!mod %in% names(res.module))
stop("Error: mod: cannot be recognized!")
if (is.null(n.patients) & is.null(n.genes)) {
return(list(genes = res.module[[mod]][["model"]][["genes"]], patients = res.module[[mod]][["model"]][["patients"]]))
}
n.pas = res.module[[mod]][["curve"]][["no.patient"]]
n.ges = res.module[[mod]][["curve"]][["no.gene"]]
if (!is.null(n.patients)) {
wh = which.min(abs(n.pas - n.patients))
n.patients = n.pas[wh]
n.genes = n.ges[wh]
}
if (!is.null(n.genes)) {
wh = which.min(abs(n.ges - n.genes))
n.patients = n.pas[wh]
n.genes = n.ges[wh]
}
seed = res.module[[mod]][["seed"]]
seed.genes = names(seed[seed != 0])
add.patients = res.module[[mod]][["patients.added"]]
remove.genes = res.module[[mod]][["genes.removed"]]
have.patients = add.patients[seq_len(n.patients)]
have.genes = seed.genes[!seed.genes %in% remove.genes[seq_len(length(seed.genes) -
n.genes)]]
return(list(genes = have.genes, patients = have.patients))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.