-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcomplexHeatmap.R
executable file
·1194 lines (1154 loc) · 48 KB
/
complexHeatmap.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/env Rscript
args <- commandArgs()
scriptPath = strsplit(args[4], '=', fixed = T)[[1]][2]
scriptName = basename(scriptPath)
scriptDir = dirname(scriptPath)
args = args[-(1:5)]
source(paste0(scriptDir, '/common.R'))
suppressMessages(library(ComplexHeatmap))
suppressMessages(library(circlize))
usage = function(){
cat(paste0("Usage: ", scriptName) )
cat(" -p=outputName.pdf input.tsv[ input2.tsv ...]
Tsv file must include column and row names, e.g:
C1 C2 C3
R1 -0.5 1.2 -1.0
R2 -0.2 0.3 -0.2
R3 1.55 0.4 -1.0
Option:
-p|pdf FILE The output figure in pdf[complexHeatmap.pdf]
-w|width INT The figure width
-height INT The figure height
NOTE: The following options are for the first heatmap (if there are multiple heatmaps)
-colTitle STR Column title
-colTitleSide STR Put column title on which side([top],bottom)
-colTitleSize DOU The font size of column title[15]
-colTitleFace STR The font face of column title(bold)
-colTitleRot INT Rotation for column title(0,90,180,270)
-colTitleCol STR Column title color[black]
-colTitleFill STR Color to fill the background of column title
-colTitleBorder STR Color of background border of column title
-colNoName Don't show column name
-colNameSide STR Put column name on which side([top],bottom)
-colNameSize DOU The font size of column name
-colNameCol STR Column name color[black]
-colNameCenter Align column name centered
-colNameRot DOU Rotation for column name
-colNotCluster Don't do column cluster
-colNoDend Don't show column dendrogram
-colDendSide STR Put column dendrogram on which side([top],bottom)
-colDendHeight DOU Height of column dendrogram in cm unit[1]
-colClusterDis STR Distance method for column cluster(pearson,spearman,kendall)
-colDendCol STR Color of column dendrogram line
-colDendNotReorder Don't reorder column dendrogram
-colSplitKmeans INT Split column cluster to INT group by k-means
-colSplitCutree INT Split column cluster to INT group by cutree
-colSplitGap DOU Gap between column slices in mm unit
-colBlock STR Add column block annotation with the specified STR as name.
Block number is specified by -colSplitKmeans
-colBox STR Add column boxplot annotation with the specified STR as name
-colBoxNoOutlier Don't show outlier for column boxplot annotation
-colHist STR Add column histogram annotation with the specified STR as name
-colHistBreak INT Set column histogram annotation with INT breaks[11]
-colDensity STR Add column density annotation with the specified STR as name
-colDensityType STR Draw column density annotation as specified type(violin, heatmap)
-colJoy STR Add column joyplot annotation with the specified STR as name
-colSimpleAnnoSize DOU Height of each column simple annotation in cm unit(not work currently, don't know why)
-colAnnoNameSide STR Put the column mean simple annotation name on which side(left, [right])
-colMeanSimple STR Add column mean simple annotation with the specified STR as name
-colMeanSimpleHeight DOU Column mean simple annotation height in cm unit[0.5]
-colMeanSimpleLegendTitle STR Column mean simple annotation legend title[-colMeanSimple]
-colMeanSimpleLegendAt INTs Column mean simple annotation legend tick values
-colMeanSimpleLegendLabel INTs Column mean simple annotation legend labels
-colMeanSimpleLegendDir STR Column mean simple annotation legend direction(horizontal,[vertical])
-colMeanPoint STR Add column mean point annotation with the specified STR as name
-colMeanLine STR Add column mean line annotation with the specified STR as name
-colMeanLineSmooth Draw column mean line annotation with loess smooth(May interupt the process with error in predLoess())
-colMeanBar STR Add column mean barplot annotation with the specified STR as name
-colMeanText Add column mean text annotation
NOTE: for all annotations, their names must be different
-rowTitle STR Row title
-rowTitleSide STR Put row title on which side([left],right)
-rowTitleSize DOU The font size of row title[15]
-rowTitleFace STR The font face of row title(bold)
-rowTitleRot INT Rotation for row title(0,90,180,270)
-rowTitleCol STR Row title color[black]
-rowTitleFill STR Color to fill the background of row title
-rowTitleBorder STR Color of background border of row title
-rowNoName Don't show row name
-rowNameSide STR Put row name on which side([left],right)
-rowNameSize DOU The font size of row name
-rowNameCol STR Column name color[black]
-rowNameCenter Align row name centered
-rowNameRot DOU Rotation for row name
-rowNotCluster Don't do row cluster
-rowNoDend Don't show row dendrogram
-rowDendSide STR Put row dendrogram on which side([left],right)
-rowDendWidth DOU Width of row dendrogram in cm unit[1]
-rowClusterDis STR Distance method for row cluster(pearson,spearman,kendall)
-rowDendCol STR Color of row dendrogram line
-rowDendNotReorder Don't reorder row dendrogram
-rowSplitKmeans INT Split row cluster to INT group by k-means
-rowSplitCutree INT Split row cluster to INT group by cutree
-rowSplitGap DOU Gap between row slices in mm unit
-rowBlock STR Add row block annotation with the specified STR as name.
Block number is specified by -rowSplitKmeans
-rowBox STR Add row boxplot annotation with the specified STR as name
-rowBoxNoOutlier Don't show outlier for row boxplot annotation
-rowHist STR Add row histogram annotation with the specified STR as name
-rowHistBreak INT Set row histogram annotation with INT breaks[11]
-rowDensity STR Add row density annotation with the specified STR as name
-rowDensityType STR Draw row density annotation as specified type(violin, heatmap)
-rowJoy STR Add row joyplot annotation with the specified STR as name
-rowSimpleAnnoSize DOU Width of each row simple annotation in cm unit(not work currently, don't know why)
-rowAnnoNameSide STR Put the row mean simple annotation name on which side(top, [bottom])
-rowMeanSimple STR Add row mean simple annotation with the specified STR as name
-rowMeanSimpleWidth DOU Row mean simple annotation width in cm unit[0.5]
-rowMeanPoint STR Add row mean point annotation with the specified STR as name
-rowMeanLine STR Add row mean line annotation with the specified STR as name
-rowMeanLineSmooth Draw row mean line annotation with loess smooth(May interupt the process with error in predLoess())
-rowMeanBar STR Add row mean barplot annotation with the specified STR as name
-rowMeanText Add row mean text annotation
NOTE: for all annotations, their names must be different
-htLegendTitle STR Heatmap legend title[matrix_1]
-htLegendAt INTs Heatmap legend tick values
-htLegendLabel STRs Heatmap legend tick labels
-htLegendHeight DOU Heatmap legend height in cm unit
-htLegendTitlePos STR Heatmap legend title position(topleft,topcenter,lefttop-rot,leftcenter-rot)
-htLegendColorBar Discrete color mapping legend
-htLegendDir STR Heatmap legend direction(horizontal,[vertical])
-htLegendSide STR Put heatmap legend on which side(left,[right],top,bottom)
-annoLegendSide STR Put annotation legends on which side(left,[right],top,bottom)
-NAcol STR Color for NA value in cell
-border STR Color of heatmap body border
-rectGp STR Color of the border of the grids in the heatmap
-showValueInCell Show each value of the input data in each cell
-densityHt Draw heatmap as density heatmap
-ylim DOUs Y limit for density heatmap
-ylab STR Y label for density heatmap[Value]
-mcCore INT Calculate the pairwise Kolmogorov-Smirnov distance in INT cores parallelly
NOTE: The following options are for the heatmap list
-verticalConcat Concatenate each heatmap vertically
-mainHeatmap INT Take which heatmap as main[1]
-figureColTitle STR The column name for the whole heatmap list
-figureRowTitle STR The row name for the whole heatmap list
-heatmapGap DOU The space between heatmaps in cm unit
-figureRowDendSide STR Put row dendrogram on which side([left],right)
-figureRowSubTitleSide STR Put row subtitle on which side(left,right)
-noAutoAdjust Show row/column names of all heatmaps
-h|help Show help
")
q(save = 'no')
}
myPdf = 'complexHeatmap.pdf'
colTitleCol = 'black'
colNameCol = 'black'
colNotCluster = FALSE
rowTitleCol = 'black'
rowNameCol = 'black'
ylab = 'Value'
if(length(args) >= 1){
for(i in 1:length(args)){
arg = args[i]
if(arg == '-h' || arg == '-help') usage()
tmp = parseArg(arg, 'p(df)?', 'p')
if(!is.null(tmp)){
myPdf = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'w(idth)?', 'w')
if(!is.null(tmp)){
width = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'height', 'height')
if(!is.null(tmp)){
height = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colTitle', 'colTitle')
if(!is.null(tmp)){
colTitle = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colTitleSide', 'colTitleSide')
if(!is.null(tmp)){
colTitleSide = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colTitleSize', 'colTitleSize')
if(!is.null(tmp)){
colTitleSize = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colTitleFace', 'colTitleFace')
if(!is.null(tmp)){
colTitleFace = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colTitleRot', 'colTitleRot')
if(!is.null(tmp)){
colTitleRot = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colTitleCol', 'colTitleCol')
if(!is.null(tmp)){
colTitleCol = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colTitleFill', 'colTitleFill')
if(!is.null(tmp)){
colTitleFill = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colTitleBorder', 'colTitleBorder')
if(!is.null(tmp)){
colTitleBorder = tmp
args[i] = NA
next
}
if(arg == '-colNoName'){
colNoName = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'colNameSide', 'colNameSide')
if(!is.null(tmp)){
colNameSide = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colNameSize', 'colNameSize')
if(!is.null(tmp)){
colNameSize = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colNameCol', 'colNameCol')
if(!is.null(tmp)){
colNameCol = tmp
args[i] = NA
next
}
if(arg == '-colNameCenter'){
colNameCenter = TRUE
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colNameRot', 'colNameRot')
if(!is.null(tmp)){
colNameRot = tmp
args[i] = NA
next
}
if(arg == '-colNotCluster'){
colNotCluster = TRUE
args[i] = NA
next
}
if(arg == '-colNoDend'){
colNoDend = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'colDendSide', 'colDendSide')
if(!is.null(tmp)){
colDendSide = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colDendHeight', 'colDendHeight')
if(!is.null(tmp)){
colDendHeight = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colClusterDis', 'colClusterDis')
if(!is.null(tmp)){
colClusterDis = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colDendCol', 'colDendCol')
if(!is.null(tmp)){
colDendCol = tmp
args[i] = NA
next
}
if(arg == '-colDendNotReorder'){
colDendNotReorder = TRUE
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colSplitKmeans', 'colSplitKmeans')
if(!is.null(tmp)){
colSplitKmeans = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colSplitCutree', 'colSplitCutree')
if(!is.null(tmp)){
colSplitCutree = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colSplitGap', 'colSplitGap')
if(!is.null(tmp)){
colSplitGap = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colBlock', 'colBlock')
if(!is.null(tmp)){
colBlock = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colBox', 'colBox')
if(!is.null(tmp)){
colBox = tmp
args[i] = NA
next
}
if(arg == '-colBoxNoOutlier'){
colBoxNoOutlier = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'colHist', 'colHist')
if(!is.null(tmp)){
colHist = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colHistBreak', 'colHistBreak')
if(!is.null(tmp)){
colHistBreak = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colDensity', 'colDensity')
if(!is.null(tmp)){
colDensity = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colDensityType', 'colDensityType')
if(!is.null(tmp)){
colDensityType = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colJoy', 'colJoy')
if(!is.null(tmp)){
colJoy = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colSimpleAnnoSize', 'colSimpleAnnoSize')
if(!is.null(tmp)){
colSimpleAnnoSize = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colMeanSimple', 'colMeanSimple')
if(!is.null(tmp)){
colMeanSimple = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'colMeanSimpleHeight', 'colMeanSimpleHeight')
if(!is.null(tmp)){
colMeanSimpleHeight = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colMeanSimpleLegendTitle', 'colMeanSimpleLegendTitle')
if(!is.null(tmp)){
colMeanSimpleLegendTitle = tmp
args[i] = NA
next
}
tmp = parseArgNums(arg, 'colMeanSimpleLegendAt', 'colMeanSimpleLegendAt')
if(!is.null(tmp)){
colMeanSimpleLegendAt = tmp
args[i] = NA
next
}
tmp = parseArgStrs(arg, 'colMeanSimpleLegendLabel', 'colMeanSimpleLegendLabel')
if(!is.null(tmp)){
colMeanSimpleLegendLabel = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colMeanSimpleLegendDir', 'colMeanSimpleLegendDir')
if(!is.null(tmp)){
colMeanSimpleLegendDir = tmp
args[i] = NA
next
}
if(arg == '-colMeanSimpleValue'){
colMeanSimpleValue = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'colMeanPoint', 'colMeanPoint')
if(!is.null(tmp)){
colMeanPoint = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'colMeanLine', 'colMeanLine')
if(!is.null(tmp)){
colMeanLine = tmp
args[i] = NA
next
}
if(arg == '-colMeanLineSmooth'){
colMeanLineSmooth = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'colMeanBar', 'colMeanBar')
if(!is.null(tmp)){
colMeanBar = tmp
args[i] = NA
next
}
if(arg == '-colMeanText'){
colMeanText = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'rowTitle', 'rowTitle')
if(!is.null(tmp)){
rowTitle = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowTitleSide', 'rowTitleSide')
if(!is.null(tmp)){
rowTitleSide = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowTitleSize', 'rowTitleSize')
if(!is.null(tmp)){
rowTitleSize = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowTitleFace', 'rowTitleFace')
if(!is.null(tmp)){
rowTitleFace = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowTitleRot', 'rowTitleRot')
if(!is.null(tmp)){
rowTitleRot = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowTitleCol', 'rowTitleCol')
if(!is.null(tmp)){
rowTitleCol = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowTitleFill', 'rowTitleFill')
if(!is.null(tmp)){
rowTitleFill = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowTitleBorder', 'rowTitleBorder')
if(!is.null(tmp)){
rowTitleBorder = tmp
args[i] = NA
next
}
if(arg == '-rowNoName'){
rowNoName = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'rowNameSide', 'rowNameSide')
if(!is.null(tmp)){
rowNameSide = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowNameSize', 'rowNameSize')
if(!is.null(tmp)){
rowNameSize = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowNameCol', 'rowNameCol')
if(!is.null(tmp)){
rowNameCol = tmp
args[i] = NA
next
}
if(arg == '-rowNameCenter'){
rowNameCenter = TRUE
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowNameRot', 'rowNameRot')
if(!is.null(tmp)){
rowNameRot = tmp
args[i] = NA
next
}
if(arg == '-rowNotCluster'){
rowNotCluster = TRUE
args[i] = NA
next
}
if(arg == '-rowNoDend'){
rowNoDend = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'rowDendSide', 'rowDendSide')
if(!is.null(tmp)){
rowDendSide = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowDendWidth', 'rowDendWidth')
if(!is.null(tmp)){
rowDendWidth = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowClusterDis', 'rowClusterDis')
if(!is.null(tmp)){
rowClusterDis = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowDendCol', 'rowDendCol')
if(!is.null(tmp)){
rowDendCol = tmp
args[i] = NA
next
}
if(arg == '-rowDendNotReorder'){
rowDendNotReorder = TRUE
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowSplitKmeans', 'rowSplitKmeans')
if(!is.null(tmp)){
rowSplitKmeans = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowSplitCutree', 'rowSplitCutree')
if(!is.null(tmp)){
rowSplitCutree = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowSplitGap', 'rowSplitGap')
if(!is.null(tmp)){
rowSplitGap = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowBlock', 'rowBlock')
if(!is.null(tmp)){
rowBlock = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowBox', 'rowBox')
if(!is.null(tmp)){
rowBox = tmp
args[i] = NA
next
}
if(arg == '-rowBoxNoOutlier'){
rowBoxNoOutlier = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'rowHist', 'rowHist')
if(!is.null(tmp)){
rowHist = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowHistBreak', 'rowHistBreak')
if(!is.null(tmp)){
rowHistBreak = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowDensity', 'rowDensity')
if(!is.null(tmp)){
rowDensity = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowDensityType', 'rowDensityType')
if(!is.null(tmp)){
rowDensityType = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowJoy', 'rowJoy')
if(!is.null(tmp)){
rowJoy = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowSimpleAnnoSize', 'rowSimpleAnnoSize')
if(!is.null(tmp)){
rowSimpleAnnoSize = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowMeanSimple', 'rowMeanSimple')
if(!is.null(tmp)){
rowMeanSimple = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'rowMeanSimpleWidth', 'rowMeanSimpleWidth')
if(!is.null(tmp)){
rowMeanSimpleWidth = tmp
args[i] = NA
next
}
if(arg == '-rowMeanSimpleValue'){
rowMeanSimpleValue = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'rowMeanPoint', 'rowMeanPoint')
if(!is.null(tmp)){
rowMeanPoint = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rowMeanLine', 'rowMeanLine')
if(!is.null(tmp)){
rowMeanLine = tmp
args[i] = NA
next
}
if(arg == '-rowMeanLineSmooth'){
rowMeanLineSmooth = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'rowMeanBar', 'rowMeanBar')
if(!is.null(tmp)){
rowMeanBar = tmp
args[i] = NA
next
}
if(arg == '-rowMeanText'){
rowMeanText = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'htLegendTitle', 'htLegendTitle')
if(!is.null(tmp)){
htLegendTitle = tmp
args[i] = NA
next
}
tmp = parseArgNums(arg, 'htLegendAt', 'htLegendAt')
if(!is.null(tmp)){
htLegendAt = tmp
args[i] = NA
next
}
tmp = parseArgStrs(arg, 'htLegendLabel', 'htLegendLabel')
if(!is.null(tmp)){
htLegendLabel = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'htLegendHeight', 'htLegendHeight')
if(!is.null(tmp)){
htLegendHeight = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'htLegendTitlePos', 'htLegendTitlePos')
if(!is.null(tmp)){
htLegendTitlePos = tmp
args[i] = NA
next
}
if(arg == '-htLegendColorBar'){
htLegendColorBar = TRUE
args[i] = NA
next
}
tmp = parseArg(arg, 'htLegendDir', 'htLegendDir')
if(!is.null(tmp)){
htLegendDir = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'htLegendSide', 'htLegendSide')
if(!is.null(tmp)){
htLegendSide = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'annoLegendSide', 'annoLegendSide')
if(!is.null(tmp)){
annoLegendSide = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'NAcol', 'NAcol')
if(!is.null(tmp)){
NAcol = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'border', 'border')
if(!is.null(tmp)){
border = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'rectGp', 'rectGp')
if(!is.null(tmp)){
rectGp = tmp
args[i] = NA
next
}
if(arg == '-showValueInCell'){
showValueInCell = TRUE
args[i] = NA
next
}
if(arg == '-densityHt'){
densityHt = TRUE
args[i] = NA
next
}
tmp = parseArgNums(arg, 'ylim', 'ylim')
if(!is.null(tmp)){
ylim = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'ylab', 'ylab')
if(!is.null(tmp)){
ylab = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'mcCore', 'mcCore')
if(!is.null(tmp)){
mcCore = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'concatDirection', 'concatDirection')
if(!is.null(tmp)){
concatDirection = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'mainHeatmap', 'mainHeatmap')
if(!is.null(tmp)){
mainHeatmap = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'figureColTitle', 'figureColTitle')
if(!is.null(tmp)){
figureColTitle = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'figureRowTitle', 'figureRowTitle')
if(!is.null(tmp)){
figureRowTitle = tmp
args[i] = NA
next
}
tmp = parseArgNum(arg, 'heatmapGap', 'heatmapGap')
if(!is.null(tmp)){
heatmapGap = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'figureRowDendSide', 'figureRowDendSide')
if(!is.null(tmp)){
figureRowDendSide = tmp
args[i] = NA
next
}
tmp = parseArg(arg, 'figureRowSubTitleSide', 'figureRowSubTitleSide')
if(!is.null(tmp)){
figureRowTitle = tmp
args[i] = NA
next
}
if(arg == '-noAutoAdjust'){
noAutoAdjust = TRUE
args[i] = NA
next
}
}
}
args = args[!is.na(args)]
if(length(args) == 0) stop('Please specify input file!')
cat(paste0('[DEBUG] ', Sys.time(), ' Check if the following variables are correct as expected:'))
cat('\npdf\t'); cat(myPdf)
cat('\nwidth\t'); if(exists('width')) cat(width)
cat('\nheight\t'); if(exists('height')) cat(height)
cat('\ncolTitle\t'); if(exists('colTitle')) cat(colTitle)
cat('\ncolTitleSide\t'); if(exists('colTitleSide')) cat(colTitleSide)
cat('\ncolTitleSize\t'); if(exists('colTitleSize')) cat(colTitleSize)
cat('\ncolTitleFace\t'); if(exists('colTitleFace')) cat(colTitleFace)
cat('\ncolTitleRot\t'); if(exists('colTitleRot')) cat(colTitleRot)
cat('\ncolTitleCol\t'); if(exists('colTitleCol')) cat(colTitleCol)
cat('\ncolTitleFill\t'); if(exists('colTitleFill')) cat(colTitleFill)
cat('\ncolTitleBorder\t'); if(exists('colTitleBorder')) cat(colTitleBorder)
cat('\ncolNoName\t'); if(exists('colNoName')) cat(colNoName)
cat('\ncolNameSide\t'); if(exists('colNameSide')) cat(colNameSide)
cat('\ncolNameSize\t'); if(exists('colNameSize')) cat(colNameSize)
cat('\ncolNameCol\t'); if(exists('colNameCol')) cat(colNameCol)
cat('\ncolNameCenter\t'); if(exists('colNameCenter')) cat(colNameCenter)
cat('\ncolNameRot\t'); if(exists('colNameRot')) cat(colNameRot)
cat('\ncolNotCluster\t'); cat(colNotCluster)
cat('\ncolNoDend\t'); if(exists('colNoDend')) cat(colNoDend)
cat('\ncolDendSide\t'); if(exists('colDendSide')) cat(colDendSide)
cat('\ncolDendHeight\t'); if(exists('colDendHeight')) cat(colDendHeight)
cat('\ncolClusterDis\t'); if(exists('colClusterDis')) cat(colClusterDis)
cat('\ncolDendCol\t'); if(exists('colDendCol')) cat(colDendCol)
cat('\ncolDendNotReorder\t'); if(exists('colDendNotReorder')) cat(colDendNotReorder)
cat('\ncolSplitKmeans\t'); if(exists('colSplitKmeans')) cat(colSplitKmeans)
cat('\ncolSplitCutree\t'); if(exists('colSplitCutree')) cat(colSplitCutree)
cat('\ncolSplitGap\t'); if(exists('colSplitGap')) cat(colSplitGap)
cat('\ncolBlock\t'); if(exists('colBlock')) cat(colBlock)
cat('\ncolBox\t'); if(exists('colBox')) cat(colBox)
cat('\ncolBoxNoOutlier\t'); if(exists('colBoxNoOutlier')) cat(colBoxNoOutlier)
cat('\ncolHist\t'); if(exists('colHist')) cat(colHist)
cat('\ncolHistBreak\t'); if(exists('colHistBreak')) cat(colHistBreak)
cat('\ncolDensity\t'); if(exists('colDensity')) cat(colDensity)
cat('\ncolDensityType\t'); if(exists('colDensityType')) cat(colDensityType)
cat('\ncolJoy\t'); if(exists('colJoy')) cat(colJoy)
cat('\ncolSimpleAnnoSize\t'); if(exists('colSimpleAnnoSize')) cat(colSimpleAnnoSize)
cat('\ncolAnnoNameSide\t'); if(exists('colAnnoNameSide')) cat(colAnnoNameSide)
cat('\ncolMeanSimple\t'); if(exists('colMeanSimple')) cat(colMeanSimple)
cat('\ncolMeanSimpleHeight\t'); if(exists('colMeanSimpleHeight')) cat(colMeanSimpleHeight)
cat('\ncolMeanSimpleLegendTitle\t'); if(exists('colMeanSimpleLegendTitle')) cat(colMeanSimpleLegendTitle)
cat('\ncolMeanSimpleLegendAt\t'); if(exists('colMeanSimpleLegendAt')) cat(colMeanSimpleLegendAt)
cat('\ncolMeanSimpleLegendLabel\t'); if(exists('colMeanSimpleLegendLabel')) cat(colMeanSimpleLegendLabel)
cat('\ncolMeanSimpleLegendDir\t'); if(exists('colMeanSimpleLegendDir')) cat(colMeanSimpleLegendDir)
cat('\ncolMeanPoint\t'); if(exists('colMeanPoint')) cat(colMeanPoint)
cat('\ncolMeanLine\t'); if(exists('colMeanLine')) cat(colMeanLine)
cat('\ncolMeanLineSmooth\t'); if(exists('colMeanLineSmooth')) cat(colMeanLineSmooth)
cat('\ncolMeanBar\t'); if(exists('colMeanBar')) cat(colMeanBar)
cat('\ncolMeanText\t'); if(exists('colMeanText')) cat(colMeanText)
cat('\nrowTitle\t'); if(exists('rowTitle')) cat(rowTitle)
cat('\nrowTitleSide\t'); if(exists('rowTitleSide')) cat(rowTitleSide)
cat('\nrowTitleSize\t'); if(exists('rowTitleSize')) cat(rowTitleSize)
cat('\nrowTitleFace\t'); if(exists('rowTitleFace')) cat(rowTitleFace)
cat('\nrowTitleRot\t'); if(exists('rowTitleRot')) cat(rowTitleRot)
cat('\nrowTitleCol\t'); if(exists('rowTitleCol')) cat(rowTitleCol)
cat('\nrowTitleFill\t'); if(exists('rowTitleFill')) cat(rowTitleFill)
cat('\nrowTitleBorder\t'); if(exists('rowTitleBorder')) cat(rowTitleBorder)
cat('\nrowNoName\t'); if(exists('rowNoName')) cat(rowNoName)
cat('\nrowNameSide\t'); if(exists('rowNameSide')) cat(rowNameSide)
cat('\nrowNameSize\t'); if(exists('rowNameSize')) cat(rowNameSize)
cat('\nrowNameCol\t'); if(exists('rowNameCol')) cat(rowNameCol)
cat('\nrowNameCenter\t'); if(exists('rowNameCenter')) cat(rowNameCenter)
cat('\nrowNameRot\t'); if(exists('rowNameRot')) cat(rowNameRot)
cat('\nrowNotCluster\t'); if(exists('rowNotCluster')) cat(rowNotCluster)
cat('\nrowNoDend\t'); if(exists('rowNoDend')) cat(rowNoDend)
cat('\nrowDendSide\t'); if(exists('rowDendSide')) cat(rowDendSide)
cat('\nrowDendWidth\t'); if(exists('rowDendWidth')) cat(rowDendWidth)
cat('\nrowClusterDis\t'); if(exists('rowClusterDis')) cat(rowClusterDis)
cat('\nrowDendCol\t'); if(exists('rowDendCol')) cat(rowDendCol)
cat('\nrowDendNotReorder\t'); if(exists('rowDendNotReorder')) cat(rowDendNotReorder)
cat('\nrowSplitKmeans\t'); if(exists('rowSplitKmeans')) cat(rowSplitKmeans)
cat('\nrowSplitCutree\t'); if(exists('rowSplitCutree')) cat(rowSplitCutree)
cat('\nrowSplitGap\t'); if(exists('rowSplitGap')) cat(rowSplitGap)
cat('\nrowBlock\t'); if(exists('rowBlock')) cat(rowBlock)
cat('\nrowBox\t'); if(exists('rowBox')) cat(rowBox)
cat('\nrowBoxNoOutlier\t'); if(exists('rowBoxNoOutlier')) cat(rowBoxNoOutlier)
cat('\nrowHist\t'); if(exists('rowHist')) cat(rowHist)
cat('\nrowHistBreak\t'); if(exists('rowHistBreak')) cat(rowHistBreak)
cat('\nrowDensity\t'); if(exists('rowDensity')) cat(rowDensity)
cat('\nrowDensityType\t'); if(exists('rowDensityType')) cat(rowDensityType)
cat('\nrowJoy\t'); if(exists('rowJoy')) cat(rowJoy)
cat('\nrowSimpleAnnoSize\t'); if(exists('rowSimpleAnnoSize')) cat(rowSimpleAnnoSize)
cat('\nrowAnnoNameSide\t'); if(exists('rowAnnoNameSide')) cat(rowAnnoNameSide)
cat('\nrowMeanSimple\t'); if(exists('rowMeanSimple')) cat(rowMeanSimple)
cat('\nrowMeanSimpleWidth\t'); if(exists('rowMeanSimpleWidth')) cat(rowMeanSimpleWidth)
cat('\nrowMeanPoint\t'); if(exists('rowMeanPoint')) cat(rowMeanPoint)
cat('\nrowMeanLine\t'); if(exists('rowMeanLine')) cat(rowMeanLine)
cat('\nrowMeanLineSmooth\t'); if(exists('rowMeanLineSmooth')) cat(rowMeanLineSmooth)
cat('\nrowMeanBar\t'); if(exists('rowMeanBar')) cat(rowMeanBar)
cat('\nrowMeanText\t'); if(exists('rowMeanText')) cat(rowMeanText)
cat('\nhtLegendName\t'); if(exists('htLegendName')) cat(htLegendName)
cat('\nhtLegendAt\t'); if(exists('htLegendAt')) cat(htLegendAt)
cat('\nhtLegendLabel\t'); if(exists('htLegendLabel')) cat(htLegendLabel)
cat('\nhtLegendHeight\t'); if(exists('htLegendHeight')) cat(htLegendHeight)
cat('\nhtLegendTitlePos\t'); if(exists('htLegendTitlePos')) cat(htLegendTitlePos)
cat('\nhtLegendColorBar\t'); if(exists('htLegendColorBar')) cat(htLegendColorBar)
cat('\nhtLegendDir\t'); if(exists('htLegendDir')) cat(htLegendDir)
cat('\nhtLegendSide\t'); if(exists('htLegendSide')) cat(htLegendSide)
cat('\nannoLegendSide\t'); if(exists('annoLegendSide')) cat(annoLegendSide)
cat('\nNAcol\t'); if(exists('NAcol')) cat(NAcol)
cat('\nborder\t'); if(exists('border')) cat(border)
cat('\nrectGp\t'); if(exists('rectGp')) cat(rectGp)
cat('\nshowValueInCell\t'); if(exists('showValueInCell')) cat(showValueInCell)
cat('\ndensityHt\t'); if(exists('densityHt')) cat(densityHt)
cat('\nylim\t'); if(exists('ylim')) cat(ylim)
cat('\nylab\t'); cat(ylab)
cat('\nmcCore\t'); if(exists('mcCore')) cat(mcCore)
cat('\nverticalConcat\t'); if(exists('verticalConcat')) cat(verticalConcat)
cat('\nmainHeatmap\t'); if(exists('mainHeatmap')) cat(mainHeatmap)
cat('\nfigureColTitle\t'); if(exists('figureColTitle')) cat(figureColTitle)
cat('\nfigureRowTitle\t'); if(exists('figureRowTitle')) cat(figureRowTitle)
cat('\nheatmapGap\t'); if(exists('heatmapGap')) cat(heatmapGap)
cat('\nfigureRowDendSide\t'); if(exists('figureRowDendSide')) cat(figureRowDendSide)
cat('\nfigureRowSubTitleSide\t'); if(exists('figureRowSubTitleSide')) cat(figureRowSubTitleSide)
cat('\nnoAutoAdjust\t'); if(exists('noAutoAdjust')) cat(noAutoAdjust)
cat('\n')
myCmd = 'pdf(myPdf'
if(exists('width')) myCmd = paste0(myCmd, ', width = width')
if(exists('height')) myCmd = paste0(myCmd, ', height = height')
myCmd = paste0(myCmd, ')')
eval(parse(text = myCmd))
data = as.matrix(read.delim(args[1]))
if(exists('densityHt')){
myCmd = 'densityHeatmap(data, ylab = ylab, clustering_distance_columns = "ks"'
if(exists('ylim')) myCmd = paste0(myCmd, ', ylim = ylim')
if(exists('mcCore')) myCmd = paste0(myCmd, ', mc.cores = mcCore')
}else{
myCmd = 'Heatmap(data'
}
# For column title
if(exists('colTitle')) myCmd = paste0(myCmd, ', column_title = colTitle')
if(exists('colTitleSide')) myCmd = paste0(myCmd, ', column_title_side = colTitleSide')
if(exists('colTitleRot')) myCmd = paste0(myCmd, ', col_title_rot = colTitleRot')
if(!exists('densityHt')){
gpar = 'gpar(col = colTitleCol'
if(exists('colTitleFace')) gpar = paste0(gpar, ', fontface = colTitleFace')
if(exists('colTitleSize')) gpar = paste0(gpar, ', fontsize = colTitleSize')
if(exists('colTitleFill')) gpar = paste0(gpar, ', fill = colTitleFill')
if(exists('colTitleBorder')) gpar = paste0(gpar, ', border = colTitleBorder')
gpar = paste0(gpar, ')')
myCmd = paste0(myCmd, ', column_title_gp = ', gpar)
}
# For column name
if(exists('colNoName')) myCmd = paste0(myCmd, ', show_column_names = FALSE')
if(exists('colNameSide')) myCmd = paste0(myCmd, ', column_names_side = colNameSide')
gpar = 'gpar(col = colNameCol'
if(exists('colNameSize')) gpar = paste0(gpar, ', fontsize = colNameSize')
gpar = paste0(gpar, ')')
myCmd = paste0(myCmd, ', column_names_gp = ', gpar)
if(exists('colNameCenter')) myCmd = paste0(myCmd, ', column_names_centered = TRUE')
if(exists('colNameRot')) myCmd = paste0(myCmd, ', column_names_rot = colNameRot')
# For column cluster
myCmd = paste0(myCmd, ', cluster_columns = !colNotCluster')
if(exists('colNoDend')) myCmd = paste0(myCmd, ', show_column_dend = FALSE')
if(exists('colDendSide')) myCmd = paste0(myCmd, ', column_dend_side = colDendSide')
if(exists('colDendHeight')) myCmd = paste0(myCmd, ', column_dend_height = unit(colDendHeight, "cm")')