comparison scater-plot-pca.R @ 2:b834074a9aff draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
author iuc
date Thu, 09 Sep 2021 12:23:11 +0000
parents 2d455a7e8a3d
children
comparison
equal deleted inserted replaced
1:fd808de478b1 2:b834074a9aff
9 library(LoomExperiment) 9 library(LoomExperiment)
10 library(scater) 10 library(scater)
11 11
12 # parse options 12 # parse options
13 13
14 option_list = list( 14 option_list <- list(
15 make_option( 15 make_option(
16 c("-i", "--input-loom"), 16 c("-i", "--input-loom"),
17 action = "store", 17 action = "store",
18 default = NA, 18 default = NA,
19 type = 'character', 19 type = "character",
20 help = "A SingleCellExperiment object file in Loom format." 20 help = "A SingleCellExperiment object file in Loom format."
21 ), 21 ),
22 make_option( 22 make_option(
23 c("-c", "--colour-by"), 23 c("-c", "--colour-by"),
24 action = "store", 24 action = "store",
25 default = NULL, 25 default = NULL,
26 type = 'character', 26 type = "character",
27 help = "Feature (from annotation file) to colour PCA plot points by. The values represented in this options should be categorical" 27 help = "Feature (from annotation file) to colour PCA plot points by. The values represented in this options should be categorical"
28 ), 28 ),
29 make_option( 29 make_option(
30 c("-s", "--size-by"), 30 c("-s", "--size-by"),
31 action = "store", 31 action = "store",
32 default = NULL, 32 default = NULL,
33 type = 'character', 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" 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 ), 35 ),
36 make_option( 36 make_option(
37 c("-p", "--shape-by"), 37 c("-p", "--shape-by"),
38 action = "store", 38 action = "store",
39 default = NULL, 39 default = NULL,
40 type = 'character', 40 type = "character",
41 help = "Feature (from annotation file) to shape PCA plot points by. The values represented in this options should be categorical" 41 help = "Feature (from annotation file) to shape PCA plot points by. The values represented in this options should be categorical"
42 ), 42 ),
43 make_option( 43 make_option(
44 c("-o", "--output-plot-file"), 44 c("-o", "--output-plot-file"),
45 action = "store", 45 action = "store",
46 default = NA, 46 default = NA,
47 type = 'character', 47 type = "character",
48 help = "Path of the PDF output file to save plot to." 48 help = "Path of the PDF output file to save plot to."
49 ) 49 )
50 ) 50 )
51 51
52 opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file')) 52 opt <- wsc_parse_args(option_list, mandatory = c("input_loom", "output_plot_file"))
53
53 # Check parameter values 54 # Check parameter values
54 55
55 if ( ! file.exists(opt$input_loom)){ 56 if (! file.exists(opt$input_loom)) {
56 stop((paste('File', opt$input_loom, 'does not exist'))) 57 stop((paste("File", opt$input_loom, "does not exist")))
57 } 58 }
58 59
60 # Filter out unexpressed features
59 61
60 # Input from Loom format 62 sce <- import(opt$input_loom, format = "loom", type = "SingleCellLoomExperiment")
63 sce <- logNormCounts(sce)
64 sce <- runPCA(sce)
61 65
62 scle <- import(opt$input_loom, format='loom', type='SingleCellLoomExperiment') 66 plot <- plotReducedDim(sce, dimred = "PCA", colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by)
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 67
68 ggsave(opt$output_plot_file, plot, device="pdf") 68 ggsave(opt$output_plot_file, plot, device = "pdf")