R/write.hclust.R

Defines functions write.hclust

Documented in write.hclust

write.hclust <- function(x, file, prefix, h = NULL, k = NULL, append = FALSE,
                         dec = ","){
    grp <- cutree(x, h=h, k=k)
    grp.lab <- formatC(grp, digits = 0, width = max(nchar(as.character(grp))), 
                       format = "f", flag = "0")
    res <- data.frame("Sample" = names(grp),
                      "Cluster" = grp, 
                      "Cluster ID" = paste(prefix, "_H", h, "_", grp.lab, sep = ""),
                      check.names = FALSE)
    if(append){
        write.table(res, file = file, append = append, dec = dec, 
                    sep ="\t", row.names = FALSE, col.names = FALSE)
    }else{
        write.table(res, file = file, append = append, dec = dec, 
                    sep ="\t", row.names = FALSE)
    }
}

Try the RFLPtools package in your browser

Any scripts or data that you put into this service are public.

RFLPtools documentation built on Feb. 8, 2022, 5:06 p.m.