9
9
# : OUTPUT: svg and pdf; png not implemented yet
10
10
11
11
progname=${0##*/ } # plot_matrix_heatmap.sh
12
- VERSION=' v0.5_18Aug17' # added options -d (max no. decimals) and -x (filter matrix with regex)
12
+ VERSION=' v0.6_14Oct17' # added options -X (charExp) and -a (label rotation angle)
13
+ # 'v0.5_18Aug17' # added options -d (max no. decimals) and -x (filter matrix with regex)
13
14
# 'v0.4_17Aug17' # added option -r to remove column names and cell contents, and -k
14
15
# 'v0.3_13Apr16' # added option -c to filter input matrix by a maximum similarity cut-off value
15
16
# to reduce excessive redundancy. Improved the help text printed with -M
@@ -41,16 +42,18 @@ function print_help()
41
42
-d <int> maximum number of decimals in matrix display [0-2; def: $decimals ]
42
43
43
44
II) tweak the graphical output:
44
- -t <string> text for plot title [def input_tab_file_name]
45
- -m <integer> margins_horizontal [def $margin_hor ]
46
- -v <integer> margins_vertical [def $margin_vert ]
47
- -o <string> output file format [def $outformat ]
48
- -p <integer> points for plotting device [def $points ]
49
- -H <integer> output device height [def $height ]
50
- -W <integer> output device width [def $width ]
51
- -C <flag> do not reorder clusters [def reorder clusters and plot dendrogram]
52
- -r <flag> remove column names and cell contents [def names and cell contents are printed]
53
- -k <string> text for scale X-axis [def "Value"]
45
+ -a <'integer,integer'> angle to rotate row,col labels [def $angle ]
46
+ -t <string> text for plot title [def input_tab_file_name]
47
+ -m <integer> margins_horizontal [def $margin_hor ]
48
+ -v <integer> margins_vertical [def $margin_vert ]
49
+ -o <string> output file format [def $outformat ]
50
+ -p <integer> points for plotting device [def $points ]
51
+ -H <integer> output device height [def $height ]
52
+ -W <integer> output device width [def $width ]
53
+ -C <flag> do not reorder clusters [def reorder clusters and plot dendrogram]
54
+ -r <flag> remove column names and cell contents [def names and cell contents are printed]
55
+ -k <string> text for scale X-axis [def "Value"]
56
+ -X <float> character expansion factor [def $charExp ]
54
57
55
58
RUN NJ ANALYSIS using ANI matrix (average identity matrix) generated by get_homologues.pl -A -t 0 -M|G
56
59
-N <flag> will compute a distance matrix from the input similarity matrix
@@ -64,7 +67,7 @@ function print_help()
64
67
-M <flag> prints gplot installation instructions and further usage information
65
68
66
69
EXAMPLE:
67
- $progname -i Avg_identity.tab -c 98.5 -t "Genus X ANIb (OMCL all clusters)" -N -o pdf -m 22 -v 22 -p 20 -H 20 -W 30 -x 'Smalt|Smc'
70
+ $progname -i Avg_identity.tab -c 99.1 -t "ANIb (OMCL core- clusters)" -N -o pdf -m 22 -v 22 -p 20 -H 20 -W 30 -x 'Smalt|Smc' -d 1 -a 'NULL,45' -X 0.9
68
71
69
72
#------------------------------------------------------------------------------------------------------------------
70
73
AIM: Plot ordered heatmaps with row and col. dendrogram, from squared numeric (distance or presence-absence) matrix,
@@ -179,14 +182,18 @@ reorder_clusters=1
179
182
remove_colnames=0
180
183
key_xaxis=" Value"
181
184
decimals=0
185
+ charExp=1.0
186
+ angle=' NULL,NULL'
182
187
183
188
subset_matrix=0
184
189
185
190
# See bash cookbook 13.1 and 13.2
186
- while getopts ' :c:i:d:t:m:o:p:v:x:H:W:k:hrMNC?:' OPTIONS
191
+ while getopts ' :a: c:i:d:t:m:o:p:v:x:X :H:W:k:hrMNC?:' OPTIONS
187
192
do
188
193
case $OPTIONS in
189
194
195
+ a) angle=$OPTARG
196
+ ;;
190
197
c) sim_cutoff=$OPTARG
191
198
;;
192
199
d) decimals=$OPTARG
217
224
;;
218
225
x) regex=$OPTARG
219
226
;;
227
+ X) charExp=$OPTARG
228
+ ;;
220
229
C) reorder_clusters=0
221
230
;;
222
231
\: ) printf " argument missing from -%s option\n" $OPTARG
@@ -270,6 +279,7 @@ cat << PARAMS
270
279
input tab_file = $tab_file | sim_cutoff = $sim_cutoff | max_decimals = $decimals
271
280
subset_matrix = $subset_matrix | regex = $regex
272
281
text=$text |margin_hor=$margin_hor |margin_vert=$margin_vert |points=$points
282
+ angle=$angle |charExp=$charExp
273
283
width=$width |height=$height |outformat=$outformat
274
284
reorder_clusters=$reorder_clusters |remove_colnames=$remove_colnames |key_xaxis=$key_xaxis |do_bioNJ=$do_nj
275
285
@@ -290,6 +300,11 @@ else
290
300
nj_tree=" ${tab_file% .* } _BioNJ.ph"
291
301
fi
292
302
303
+ aRow=$( echo " $angle " | cut -d, -f1)
304
+ aCol=$( echo " $angle " | cut -d, -f2)
305
+
306
+
307
+
293
308
# 2) call R using a heredoc and write the resulting script to file
294
309
R --no-save -q << RCMD > ${progname% .* } _script_run_at_${start_time} .R
295
310
library("gplots")
@@ -307,12 +322,8 @@ if($subset_matrix > 0 ){
307
322
include_list <- grep("$regex ", rownames(mat_dat))
308
323
mat_dat <- mat_dat[include_list, ]
309
324
mat_dat <- mat_dat[,include_list]
310
- #mat_dat <- f.mat2
311
- #rm(f.mat)
312
325
}
313
326
314
-
315
-
316
327
if($sim_cutoff < 100)
317
328
{
318
329
tmp_mat = mat_dat
@@ -325,26 +336,30 @@ if($reorder_clusters > 0){
325
336
if($remove_colnames > 0){
326
337
$outformat ("$heatmap_outfile ", width=$width , height=$height , pointsize=$pointsize )
327
338
heatmap.2(mat_dat, main="$text ", notecol="black", density.info="none", key.xlab="$key_xaxis ",
328
- trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5), labCol=F)
339
+ trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5), labCol=F,
340
+ cexRow=$charExp , cexCol=$charExp , srtRow=$aRow , srtCol=$aCol )
329
341
dev.off()
330
342
}
331
343
else {
332
344
$outformat ("$heatmap_outfile ", width=$width , height=$height , pointsize=$pointsize )
333
345
heatmap.2(mat_dat, cellnote=mat_dat, main="$text ", notecol="black", density.info="none", key.xlab="$key_xaxis ",
334
- trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5))
346
+ trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5),
347
+ cexRow=$charExp , cexCol=$charExp , srtRow=$aRow , srtCol=$aCol )
335
348
dev.off()
336
349
}
337
350
} else {
338
351
if($remove_colnames > 0){
339
352
$outformat ("$heatmap_outfile ", width=$width , height=$height , pointsize=$pointsize )
340
353
heatmap.2(mat_dat, main="$text ", notecol="black", density.info="none", labCol=F, key.xlab="$key_xaxis ",
341
- trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5), dendrogram = "row", Colv = FALSE)
354
+ trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5), dendrogram = "row", Colv = FALSE,
355
+ cexRow=$charExp , cexCol=$charExp , srtRow=$aRow , srtCol=$aCol )
342
356
dev.off()
343
357
}
344
358
else {
345
359
$outformat ("$heatmap_outfile ", width=$width , height=$height , pointsize=$pointsize )
346
360
heatmap.2(mat_dat, cellnote=mat_dat, main="$text ", notecol="black", density.info="none", key.xlab="$key_xaxis ",
347
- trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5), dendrogram = "row", Colv = FALSE)
361
+ trace="none", margins=c($margin_vert ,$margin_hor ), lhei = c(1,5), dendrogram = "row", Colv = FALSE,
362
+ cexRow=$charExp , cexCol=$charExp , srtRow=$aRow , srtCol=$aCol )
348
363
dev.off()
349
364
}
350
365
}
0 commit comments