R/make_loadings_gctfile.R

Defines functions make_loadings_gctfile

Documented in make_loadings_gctfile

#'Format PCA loadings for IGV
#'
#'Outputs gct file in format for IGV
#'
#'@param file loadings file (output of PCA_from_file)
#'@param ncomps number of components
#'
#'
#'@export

make_loadings_gctfile = function(file, ncomps = 5){
  loadings = read.delim(file, header =T)
  loadings = loadings[, c(0:ncomps+1)]
  loadings = cbind ("Loading" = loadings[,1], loadings)
  name=sub(".txt","",file)
  out_file = paste0(name, "_PC1-5.gct")
  
  cat("#1.2\n1\t1\n", file=out_file)
  write.table(loadings, out_file,sep = "\t", row.names =F, quote = F, append = T)
}
KSheu/ksheu.lib documentation built on Oct. 14, 2020, 11:55 p.m.