-
Notifications
You must be signed in to change notification settings - Fork 5
/
seurat-plot.R
executable file
·908 lines (817 loc) · 27.3 KB
/
seurat-plot.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
#!/usr/bin/env Rscript
# This script has been automatically generated through
#
# YAML2RScript.py -i ../r-seurat-scripts/cli-generated/manually_crafted_YAML/seurat-plot.yaml -o ../r-seurat-scripts/seurat-plot.R
#
# to change this file edit the input YAML and re-run the above command
suppressPackageStartupMessages(require(SeuratDisk))
suppressPackageStartupMessages(require(Seurat))
suppressPackageStartupMessages(require(scater))
suppressPackageStartupMessages(require(optparse))
suppressPackageStartupMessages(require(workflowscriptscommon))
suppressPackageStartupMessages(require(patchwork))
suppressPackageStartupMessages(require(ggplot2))
option_list <- list(
make_option(
c("-i", "--input-object-file"),
action = "store",
metavar = "Input file",
type = "character",
help = "Query file with Seurat object in either RDS-Seurat, Loom or SCE"
),
make_option(
c("--input-format"),
action = "store",
default = "seurat",
metavar = "Input format",
type = "character",
help = "Either loom, seurat, anndata or singlecellexperiment for the input format to read."
),
make_option(
c("--plot-type"),
action = "store",
default = "FeaturePlot",
type = "character",
help = "Either FeaturePlot, RidgePlot, DimPlot, VlnPlot or DotPlot."
),
make_option(
c("--dims"),
action = "store",
default = "1,2",
type = "character",
help = "Dimensions to plot, must be a two-length numeric vector specifying x- and y-dimensions"
),
make_option(
c("--cells"),
action = "store",
default = NULL,
type = "character",
help = "Vector of cells to plot (default is all cells)"
),
make_option(
c("--cols"),
action = "store",
default = NULL,
type = "character",
help = "Vector of colors, each color corresponds to an identity class. This may also be a single character or numeric value corresponding to a palette as specified by brewer.pal.info. By default, ggplot2 assigns colors. We also include a number of palettes from the pals package. See 'DiscretePalette' for details."
),
make_option(
c("--pt-size"),
action = "store",
default = NULL,
type = "integer",
help = "Adjust point size for plotting"
),
make_option(
c("--reduction"),
action = "store",
default = NULL,
type = "character",
help = "Which dimensionality reduction to use. If not specified, first searches for umap, then tsne, then pca"
),
make_option(
c("--group-by"),
action = "store",
default = NULL,
type = "character",
help = "Name of one or more metadata columns to group (color) cells by (for example, orig.ident); pass 'ident' to group by identity class"
),
make_option(
c("--split-by"),
action = "store",
default = NULL,
type = "character",
help = "Name of a metadata column to split plot by; see 'FetchData' for more details"
),
make_option(
c("--shape-by"),
action = "store",
default = NULL,
type = "character",
help = "If NULL, all points are circles (default). You can specify any cell attribute (that can be pulled with FetchData) allowing for both different colors and different shapes on cells. Only applicable if raster is FALSE."
),
make_option(
c("--order"),
action = "store",
default = NULL,
type = "character",
help = "Specify the order of plotting for the idents. This can be useful for crowded plots if points of interest are being buried. Provide either a full list of valid idents or a subset to be plotted last (on top)"
),
make_option(
c("--shuffle"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Whether to randomly shuffle the order of points. This can be useful for crowded plots if points of interest are being buried. (default is FALSE)"
),
make_option(
c("--seed"),
action = "store",
default = 1,
type = "integer",
help = "Sets the seed if randomly shuffling the order of points."
),
make_option(
c("--label"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Whether to label the clusters"
),
make_option(
c("--label-size"),
action = "store",
default = 4,
type = "integer",
help = "Sets size of labels"
),
make_option(
c("--label-color"),
action = "store",
default = "black",
type = "character",
help = "Sets the color of the label text"
),
make_option(
c("--label-box"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Whether to put a box around the label text (geom_text vs geom_label)"
),
make_option(
c("--repel"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Repel labels"
),
make_option(
c("--cells-highlight"),
action = "store",
default = NULL,
type = "character",
help = "A list of character or numeric vectors of cells to highlight. If only one group of cells desired, can simply pass a vector instead of a list. If set, colors selected cells to the color(s) in 'cols.highlight' and other cells black (white if dark.theme = TRUE); will also resize to the size(s) passed to 'sizes.highlight'."
),
make_option(
c("--cols-highlight"),
action = "store",
default = "#DE2D26",
type = "character",
help = "A vector of colors to highlight the cells as; will repeat to the length groups in cells.highlight. Comma separated."
),
make_option(
c("--sizes-highlight"),
action = "store",
default = 1,
type = "integer",
help = "Size of highlighted cells; will repeat to the length groups in cells.highlight"
),
make_option(
c("--na-value"),
action = "store",
default = "grey50",
type = "character",
help = "Color value for NA points when using custom scale"
),
make_option(
c("--ncol"),
action = "store",
default = NULL,
type = "integer",
help = "Number of columns for display when combining plots"
),
make_option(
c("--features"),
action = "store",
default = NULL,
type = "character",
help = "A vector of features to plot, defaults to VariableFeatures of the object."
),
make_option(
c("--do-not-group-bar"),
action = "store_false",
default = TRUE,
type = "logical",
help = "Add a color bar showing group status for cells"
),
make_option(
c("--group-colors"),
action = "store",
default = NULL,
type = "character",
help = "Colors to use for the color bar, comma separated."
),
make_option(
c("--disp-min"),
action = "store",
default = -2,
type = "integer",
help = "Minimum display value (all values below are clipped)"
),
make_option(
c("--disp-max"),
action = "store",
default = NULL,
type = "integer",
help = "Maximum display value (all values above are clipped); defaults to 2.5 if slot is 'scale.data', 6 otherwise"
),
make_option(
c("--slot"),
action = "store",
default = "scale.data",
type = "character",
help = "Data slot to use, choose from raw.data, data, or scale.data"
),
make_option(
c("--assay"),
action = "store",
default = NULL,
type = "character",
help = "Assay to pull from"
),
make_option(
c("--do-not-label"),
action = "store_false",
default = TRUE,
type = "logical",
help = "Label the cell identies above the color bar"
),
make_option(
c("--size"),
action = "store",
default = 5,
type = "integer",
help = "Size of text above color bar"
),
make_option(
c("--hjust"),
action = "store",
default = 0,
type = "integer",
help = "Horizontal justification of text above color bar"
),
make_option(
c("--angle"),
action = "store",
default = 45,
type = "integer",
help = "Angle of text above color bar"
),
make_option(
c("--do-not-raster"),
action = "store_false",
default = TRUE,
type = "logical",
help = "If true, plot with geom_raster, else use geom_tile. geom_raster may look blurry on some viewing applications such as Preview due to how the raster is interpolated. Set this to FALSE if you are encountering that issue (note that plots may take longer to produce/render)."
),
make_option(
c("--do-not-draw-lines"),
action = "store_false",
default = TRUE,
type = "logical",
help = "Include white lines to separate the groups"
),
make_option(
c("--lines-width"),
action = "store",
default = NULL,
type = "integer",
help = "Integer number to adjust the width of the separating white lines. Corresponds to the number of cells between each group."
),
make_option(
c("--group-bar-height"),
action = "store",
default = 0,
type = "integer",
help = "Scale the height of the color bar"
),
make_option(
c("--do-not-combine"),
action = "store_false",
default = TRUE,
type = "logical",
help = "Combine plots into a single patchwork or ed ggplot object. If FALSE return a list of ggplot objects."
),
make_option(
c("--cols-ridgeplot"),
action = "store",
default = NULL,
type = "character",
help = "Colors to use for plotting, comma separated"
),
make_option(
c("--idents"),
action = "store",
default = NULL,
type = "character",
help = "Which classes to include in the plot (default is all)"
),
make_option(
c("--sort"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Sort identity classes (on the x-axis) by the average expression of the attribute being potted, can also pass 'increasing' or 'decreasing' to change sort direction"
),
make_option(
c("--y-max"),
action = "store",
default = NULL,
type = "double",
help = "Maximum y axis value"
),
make_option(
c("--same-y-lims"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Set all the y-axis limits to the same values"
),
make_option(
c("--log"),
action = "store_true",
default = FALSE,
type = "logical",
help = "plot the feature axis on log scale"
),
make_option(
c("--stack"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Horizontally stack plots for each feature"
),
make_option(
c("--fill-by"),
action = "store",
default = "feature",
type = "character",
help = "Color violins/ridges based on either 'feature' or 'ident'"
),
make_option(
c("--cols-feature-plot"),
action = "store",
default = "lightgrey,blue",
type = "character",
help = "The two colors to form the gradient over. Provide as string vector with the first color corresponding to low values, the second to high. Also accepts a Brewer color scale or vector of colors."
),
make_option(
c("--min-cutoff"),
action = "store",
default = "NA",
type = "character",
help = "Vector of minimum cutoff values for each feature, may specify quantile in the form of 'q##' where '##' is the quantile (eg, 'q1', 'q10')"
),
make_option(
c("--max-cutoff"),
action = "store",
default = "NA",
type = "character",
help = "Vector of maximum cutoff values for each feature, may specify quantile in the form of 'q##' where '##' is the quantile (eg, 'q1', 'q10')"
),
make_option(
c("--keep-scale"),
action = "store",
default = "feature",
type = "character",
help = "How to handle the color scale across multiple plots."
),
make_option(
c("--blend"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Scale and blend expression values to visualize coexpression of two features"
),
make_option(
c("--blend-threshold"),
action = "store",
default = 0,
type = "integer",
help = "The color cutoff from weak signal to strong signal; ranges from 0 to 1."
),
make_option(
c("--coord-fixed"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Plot cartesian coordinates with fixed aspect ratio"
),
make_option(
c("--do-not-by-col"),
action = "store_false",
default = TRUE,
type = "logical",
help = "If splitting by a factor, plot the splits per column with the features as rows; ignored if blend = TRUE."
),
make_option(
c("--adjust"),
action = "store",
default = 1,
type = "integer",
help = "Adjust parameter for geom_violin"
),
make_option(
c("--split-plot"),
action = "store_true",
default = FALSE,
type = "logical",
help = "plot each group of the split violin plots by multiple or single violin shapes."
),
make_option(
c("--flip"),
action = "store_true",
default = FALSE,
type = "logical",
help = "flip plot orientation (identities on x-axis)"
),
make_option(
c("--cols-dot-plot"),
action = "store",
default = "yellow,lightgrey,blue",
type = "character",
help = "Colors to plot: the name of a palette from RColorBrewer::brewer.pal.info , a pair of colors defining a gradient, or 3+ colors defining multiple gradients (if split.by is set)"
),
make_option(
c("--col-min"),
action = "store",
default = -2,
type = "integer",
help = "Minimum scaled average expression threshold (everything smaller will be set to this)"
),
make_option(
c("--col-max"),
action = "store",
default = 2,
type = "integer",
help = "Maximum scaled average expression threshold (everything larger will be set to this)"
),
make_option(
c("--dot-min"),
action = "store",
default = 0,
type = "integer",
help = "The fraction of cells at which to draw the smallest dot (default is 0). All cell groups with less than this expressing the given gene will have no dot drawn."
),
make_option(
c("--dot-scale"),
action = "store",
default = 6,
type = "integer",
help = "Scale the size of the points, similar to cex"
),
make_option(
c("--cluster-idents"),
action = "store_true",
default = FALSE,
type = "logical",
help = "Whether to order identities by hierarchical clusters based on given features, default is FALSE"
),
make_option(
c("--do-not-scale"),
action = "store_false",
default = TRUE,
type = "logical",
help = "Determine whether the data is scaled, will be done by default"
),
make_option(
c("--scale-by"),
action = "store",
default = "radius",
type = "character",
help = "Scale the size of the points by 'size' or by 'radius'"
),
make_option(
c("--scale-min"),
action = "store",
default = "NA",
type = "double",
help = "Set lower limit for scaling, use NA for default"
),
make_option(
c("--scale-max"),
action = "store",
default = "NA",
type = "double",
help = "Set upper limit for scaling, use NA for default"
),
make_option(
c("--output-rds-file"),
action = "store",
default = NULL,
type = "character",
help = "Path to RDS to keep the plot object"
),
make_option(
c("--plot-out"),
action = "store",
type = "character",
help = "File name to create on disk."
),
make_option(
c("--plot-format"),
action = "store",
default = "png",
type = "character",
help = "Format to use, either PNG, EPS, PostScript, TeX, PDF, JPEG, TIFF or SVG"
),
make_option(
c("--scale-factor"),
action = "store",
default = 1,
type = "double",
help = "Multiplicative scaling factor."
),
make_option(
c("--width"),
action = "store",
default = 20,
type = "double",
help = "Width of the figure, in the selected units."
),
make_option(
c("--height"),
action = "store",
default = 20,
type = "double",
help = "Height of the figure, in the selected units."
),
make_option(
c("--units"),
action = "store",
default = "cm",
type = "character",
help = "Units for the plot dimensions."
),
make_option(
c("--dpi"),
action = "store",
default = 300,
type = "integer",
help = "Plot resolution. Also accepts a string input: retina (320), print (300), or screen (72). Applies only to raster output types."
),
make_option(
c("--do-not-limitsize"),
action = "store_false",
default = TRUE,
type = "logical",
help = "When TRUE (the default) ggsave() will not save images larger than 50x50 inches, to prevent the common error of specifying dimensions in pixels."
),
make_option(
c("--bg"),
action = "store",
default = NULL,
type = "character",
help = "Background colour. If NULL, uses the plot.background fill value from the plot theme."
)
)
opt <- wsc_parse_args(option_list,
mandatory = c("input_object_file", "plot_out"))
if (!file.exists(opt$input_object_file)) {
stop((paste("File", opt$input_object_file, "does not exist")))
}
dims <- opt$dims
if (!is.null(dims)) {
dims <- as.numeric(unlist(strsplit(opt$dims, split = ",")))
}
cells <- opt$cells
if (!is.null(cells)) {
cells <- unlist(strsplit(opt$cells, split = ","))
}
cols <- opt$cols
if (!is.null(cols)) {
cols <- unlist(strsplit(opt$cols, split = ","))
}
group_by <- opt$group_by
if (!is.null(group_by)) {
group_by <- unlist(strsplit(opt$group_by, split = ","))
}
order <- opt$order
if (!is.null(order)) {
order <- unlist(strsplit(opt$order, split = ","))
}
cells_highlight <- opt$cells_highlight
if (!is.null(cells_highlight)) {
cells_highlight <- unlist(strsplit(opt$cells_highlight, split = ","))
}
cols_highlight <- opt$cols_highlight
if (!is.null(cols_highlight)) {
cols_highlight <- unlist(strsplit(opt$cols_highlight, split = ","))
}
features <- opt$features
if (!is.null(features)) {
features <- unlist(strsplit(opt$features, split = ","))
}
cells <- opt$cells
if (!is.null(cells)) {
cells <- unlist(strsplit(opt$cells, split = ","))
}
group_colors <- opt$group_colors
if (!is.null(group_colors)) {
group_colors <- unlist(strsplit(opt$group_colors, split = ","))
}
features <- opt$features
if (!is.null(features)) {
features <- unlist(strsplit(opt$features, split = ","))
}
cols_ridgeplot <- opt$cols_ridgeplot
if (!is.null(cols_ridgeplot)) {
cols_ridgeplot <- unlist(strsplit(opt$cols_ridgeplot, split = ","))
}
idents <- opt$idents
if (!is.null(idents)) {
idents <- unlist(strsplit(opt$idents, split = ","))
}
group_by <- opt$group_by
if (!is.null(group_by)) {
group_by <- unlist(strsplit(opt$group_by, split = ","))
}
features <- opt$features
if (!is.null(features)) {
features <- unlist(strsplit(opt$features, split = ","))
}
dims <- opt$dims
if (!is.null(dims)) {
dims <- as.numeric(unlist(strsplit(opt$dims, split = ",")))
}
cells <- opt$cells
if (!is.null(cells)) {
cells <- unlist(strsplit(opt$cells, split = ","))
}
cols_feature_plot <- opt$cols_feature_plot
if (!is.null(cols_feature_plot)) {
cols_feature_plot <- unlist(strsplit(opt$cols_feature_plot, split = ","))
}
min_cutoff <- opt$min_cutoff
if (!is.null(min_cutoff)) {
min_cutoff <- unlist(strsplit(opt$min_cutoff, split = ","))
}
max_cutoff <- opt$max_cutoff
if (!is.null(max_cutoff)) {
max_cutoff <- unlist(strsplit(opt$max_cutoff, split = ","))
}
features <- opt$features
if (!is.null(features)) {
features <- unlist(strsplit(opt$features, split = ","))
}
cols <- opt$cols
if (!is.null(cols)) {
cols <- unlist(strsplit(opt$cols, split = ","))
}
group_by <- opt$group_by
if (!is.null(group_by)) {
group_by <- unlist(strsplit(opt$group_by, split = ","))
}
features <- opt$features
if (!is.null(features)) {
features <- unlist(strsplit(opt$features, split = ","))
}
cols_dot_plot <- opt$cols_dot_plot
if (!is.null(cols_dot_plot)) {
cols_dot_plot <- unlist(strsplit(opt$cols_dot_plot, split = ","))
}
idents <- opt$idents
if (!is.null(idents)) {
idents <- unlist(strsplit(opt$idents, split = ","))
}
group_by <- opt$group_by
if (!is.null(group_by)) {
group_by <- unlist(strsplit(opt$group_by, split = ","))
}
load_seurat4_packages_for_format(formats = c(opt$query_format, opt$anchors_format, opt$reference_format))
seurat_object <- read_seurat4_object(input_path = opt$input_object_file,
format = opt$input_format)
if ( opt$plot_type == 'DimPlot' ) {
plot_object <- DimPlot(object = seurat_object,
dims = dims,
cells = cells,
cols = cols,
pt.size = opt$pt_size,
reduction = opt$reduction,
group.by = group_by,
split.by = opt$split_by,
shape.by = opt$shape_by,
order = order,
shuffle = opt$shuffle,
seed = opt$seed,
label = opt$label,
label.size = opt$label_size,
label.color = opt$label_color,
label.box = opt$label_box,
repel = opt$repel,
cells.highlight = cells_highlight,
cols.highlight = cols_highlight,
sizes.highlight = opt$sizes_highlight,
na.value = opt$na_value,
ncol = opt$ncol)
} else if ( opt$plot_type == 'DoHeatmap' ) {
plot_object <- DoHeatmap(object = seurat_object,
features = features,
cells = cells,
group.by = opt$group_by,
group.bar = opt$do_not_group_bar,
group.colors = group_colors,
disp.min = opt$disp_min,
disp.max = opt$disp_max,
slot = opt$slot,
assay = opt$assay,
label = opt$do_not_label,
size = opt$size,
hjust = opt$hjust,
angle = opt$angle,
raster = opt$do_not_raster,
draw.lines = opt$do_not_draw_lines,
lines.width = opt$lines_width,
group.bar.height = opt$group_bar_height,
combine = opt$do_not_combine)
} else if ( opt$plot_type == 'RidgePlot' ) {
plot_object <- RidgePlot(object = seurat_object,
features = features,
cols = cols_ridgeplot,
idents = idents,
sort = opt$sort,
assay = opt$assay,
group.by = group_by,
y.max = opt$y_max,
same.y.lims = opt$same_y_lims,
log = opt$log,
ncol = opt$ncol,
slot = opt$slot,
stack = opt$stack,
fill.by = opt$fill_by)
} else if ( opt$plot_type == 'FeaturePlot' ) {
plot_object <- FeaturePlot(object = seurat_object,
features = features,
dims = dims,
cells = cells,
cols = cols_feature_plot,
pt.size = opt$pt_size,
order = opt$order,
min.cutoff = min_cutoff,
max.cutoff = max_cutoff,
reduction = opt$reduction,
split.by = opt$split_by,
keep.scale = opt$keep_scale,
shape.by = opt$shape_by,
slot = opt$slot,
blend = opt$blend,
blend.threshold = opt$blend_threshold,
label = opt$label,
label.size = opt$label_size,
repel = opt$repel,
ncol = opt$ncol,
coord.fixed = opt$coord_fixed,
by.col = opt$do_not_by_col)
} else if ( opt$plot_type == 'VlnPlot' ) {
plot_object <- VlnPlot(object = seurat_object,
features = features,
cols = cols,
pt.size = opt$pt_size,
idents = opt$idents,
sort = opt$sort,
assay = opt$assay,
group.by = group_by,
split.by = opt$split_by,
adjust = opt$adjust,
y.max = opt$y_max,
same.y.lims = opt$same_y_lims,
log = opt$log,
ncol = opt$ncol,
slot = opt$slot,
split.plot = opt$split_plot,
stack = opt$stack,
fill.by = opt$fill_by,
flip = opt$flip)
} else if ( opt$plot_type == 'DotPlot' ) {
plot_object <- DotPlot(object = seurat_object,
assay = opt$assay,
features = features,
cols = cols_dot_plot,
col.min = opt$col_min,
col.max = opt$col_max,
dot.min = opt$dot_min,
dot.scale = opt$dot_scale,
idents = idents,
group.by = group_by,
split.by = opt$split_by,
cluster.idents = opt$cluster_idents,
scale = opt$do_not_scale,
scale.by = opt$scale_by,
scale.min = opt$scale_min,
scale.max = opt$scale_max)
}
if (!is.null(opt$output_rds_file)) {
saveRDS(file = opt$output_rds_file,
object = plot_object)
}
ggsave(filename = opt$plot_out,
plot = plot_object,
device = opt$plot_format,
scale = opt$scale_factor,
width = opt$width,
height = opt$height,
units = opt$units,
dpi = opt$dpi,
limitsize = opt$do_not_limitsize,
bg = opt$bg)