Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
# Reusing this R script from an earlier project.
# R script to plot a heatmap of the l2-normed weight vector
#
# Input:
# Input filename, output folder (path), rank of the weight vector,
# and the oligomer length for ODH
#
# Output: Weight vector l2-norm matrix heatmap
#
# Author: snikumbh@mpi-inf.mpg.de
args <- commandArgs(TRUE)
# send inputFilename outputFolder rank and oligoLen
inputFilename <- args[1]
outputFolder <- args[2]
rank <- args[3]
oligoLen <- as.numeric(args[4])
# this project, we only use the heatmap functionality
plot_heatmap <- TRUE
if(plot_heatmap == TRUE){
library(lattice)
pdfname <- paste0(outputFolder, "/norms_mat_rank", rank, "_oligolen", oligoLen, ".pdf")
names <- seq(1,4^oligoLen, by=1)
x <- expand.grid(rep(list(c('A', 'C', 'G', 'T')), 2))
names <- do.call(paste0, rev(x))
new.palette <- colorRampPalette(c("white","blue"),space="rgb")
fname <- inputFilename
mat_data <- as.matrix(read.csv(fname, header = FALSE))
rownames(mat_data) <- names
colnames(mat_data) <- names
pdf(pdfname)
p <- levelplot(mat_data, col.regions=new.palette(20), scales=list(x=list(cex=.5, rot= 90),y=list(cex=.5)), xlab=list(label=paste0(oligoLen, "-mers"), cex=.9), ylab=list(label=paste0(oligoLen, "-mers"), cex=.9), region = TRUE, main="", title = paste0("_heatmaps"))
print(p)
dev.off()
}else{
pdf("barplot_max_weight_subvector.pdf")
weights <- as.matrix(read.table("max_weight_subvector.lsv", sep = ",", header = FALSE), ncol = 1)
barplot(weights[,1], main="", ylim = c(-0.1, 0.6), ylab="discriminant weights", cex.lab = 1.0)
text(50.0, -0.05, "Distances", cex=1.0, pos=4, col="black")
box()
dev.off()
}