https://github.com/mossmatters/HybPiper
Raw File
Tip revision: 5500bc99112f2f0e97dcb4ade3f7034e14166edf authored by rb-laura on 30 January 2017, 12:03:46 UTC
Delete test_HybPiper_Performance.py
Tip revision: 5500bc9
gene_recovery_heatmap.R
require(gplots)
require(heatmap.plus)


#Here, set the file name of the table generated by get_seq_lengths.py
sample.filename = "examples/plastids.txt"


#You should not need to change anything below this line!
#-------------------------------------------------------


sample.data= as.matrix(read.table(sample.filename,header=T,row.names=1))
sample.len = sample.data[2:nrow(sample.data),]
reference.len = as.numeric(sample.data[1,])

#Calculate the percentage length recovered relative to the reference.
percent.len=sweep(sample.len,2,as.numeric(reference.len),'/')
percent.len = ifelse(percent.len>1,1,percent.len)

#Plot the heatmap
heatmap.2(percent.len, Rowv=FALSE, Colv=FALSE, dendrogram= c('none'),
cexCol=100/dim(percent.len)[2], cexRow=20/dim(percent.len)[1],
density.info=c('none'), # options of different plots to be drawn in colour key
trace='none', # character string indicating whether a solid “trace” line should be drawn across ‘row’s or down ‘column’s, ‘both’ or ‘none’.
#margins=c(10,5),
#key=F,
key=T, keysize=1, # display colour key
key.title = NA,
key.xlab= 'Percent Reference Protein Length Recovered',

#The line below indicates where to display colour key, and the placement of four elements of the figure.
#However, we don't care about two of them (the dendrograms).
#This leves element 1 (the heatmap) and element 4 (the key).
#   lmat specifies coordinates for the four elements. 
#   with three rows, the (unplotted) dendrograms can be in the margins.
#Then we make the first row and first column, which contain the (unplotted) dendrograms, very small with lhei and lwid.
#The second and third values in lhei correspond to the relative height of the chart vs the key.

lmat=rbind( c(0,3), c(2,1), c(0,4) ), lhei=c(0.01, 10, 3), lwid=c(0.01,1),

#Specifies a grayscale color pallette 
col = gray.colors(10,start=0.9,end=0.3,gamma=2.2),
)
back to top