comparison scater-plot-pca.R @ 0:e6ca62ac65c6 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
author iuc
date Thu, 18 Jul 2019 11:13:41 -0400
parents
children 7a365ec81b52
comparison
equal deleted inserted replaced
-1:000000000000 0:e6ca62ac65c6
1 #!/usr/bin/env Rscript
2
3 # Creates a PCA plot of a normalised SingleCellExperiment object.
4
5 # Load optparse we need to check inputs
6
7 library(optparse)
8 library(workflowscriptscommon)
9 library(LoomExperiment)
10 library(scater)
11
12 # parse options
13
14 option_list = list(
15 make_option(
16 c("-i", "--input-loom"),
17 action = "store",
18 default = NA,
19 type = 'character',
20 help = "A SingleCellExperiment object file in Loom format."
21 ),
22 make_option(
23 c("-c", "--colour-by"),
24 action = "store",
25 default = NULL,
26 type = 'character',
27 help = "Feature (from annotation file) to colour PCA plot points by. The values represented in this options should be categorical"
28 ),
29 make_option(
30 c("-s", "--size-by"),
31 action = "store",
32 default = NULL,
33 type = 'character',
34 help = "Feature (from annotation file) to size PCA plot points by. The values represented in this options should be numerical and not categorical"
35 ),
36 make_option(
37 c("-p", "--shape-by"),
38 action = "store",
39 default = NULL,
40 type = 'character',
41 help = "Feature (from annotation file) to shape PCA plot points by. The values represented in this options should be categorical"
42 ),
43 make_option(
44 c("-o", "--output-plot-file"),
45 action = "store",
46 default = NA,
47 type = 'character',
48 help = "Path of the PDF output file to save plot to."
49 )
50 )
51
52 opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file'))
53 # Check parameter values
54
55 if ( ! file.exists(opt$input_loom)){
56 stop((paste('File', opt$input_loom, 'does not exist')))
57 }
58
59
60 # Input from Loom format
61
62 scle <- import(opt$input_loom, format='loom', type='SingleCellLoomExperiment')
63 scle <- normalize(scle, exprs_values = 1)
64 scle <- runPCA(scle)
65 plot <- plotReducedDim(scle, "PCA", colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by)
66 #do the scatter plot of reads vs genes
67
68 ggsave(opt$output_plot_file, plot, device="pdf")