# construct hetset object from matrix or data.frame ---------------------------
hetset <- function(D,S = NULL){
if(!class(D) %in% c("data.frame","matrix","SummarizedExperiment")){
stop("class of data should be one of data.frame, matrix or SE")
}
if(!class(S) %in% c("data.frame","matrix","logical","NULL")){
stop("class of sample information should be data.frame, matrix or logical")
}
if (class(D) != "SummarizedExperiment"){
if (is.null(S)){
dec.needed <- ceiling(log10(1+ncol(D)))
ID.all <- 10^dec.needed
ID.needed <- paste0("ID",substr(as.character((ID.all+1):(ID.all+ncol(D))),
start = 2,stop = dec.needed+1))
S <- data.frame("ID" = as.factor(ID.needed))
if (is.null(colnames(D))){
colnames(D) <- as.factor(ID.needed)
}
if (is.null(rownames(D))){
rownames(D) <- paste0("F",1:nrow(D))
}
}
sample_names <- colnames(D)
if(class(S) %in% c("data.frame","matrix")){
colData <- S
colData$prt <- NA
colData$col.names <- sample_names
} else {
colData <- DataFrame("prt" = NA,col.names = sample_names)
}
feature_names <- rownames(D)
rowData <- DataFrame(row.names = feature_names)
H <- SummarizedExperiment(assays = SimpleList("X" = as.matrix(D)),
rowData = rowData,colData = colData)
} else {
H <- D
}
H@metadata$slf <- NA
H@metadata$prm.full <- list("mean" = NA,"cov" = NA)
H@metadata$prm.A <- list("mean" = NA,"cov" = NA)
H@metadata$prm.B <- list("mean" = NA,"cov" = NA)
H@metadata$prp.A <- 0.5
H@metadata$color_type <- "raw"
H$prt <- NA
H
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.