diff scater-plot-tsne.R @ 2:7a365ec81b52 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:24:17 +0000
parents b7ea9f09c02f
children
line wrap: on
line diff
--- a/scater-plot-tsne.R	Tue Sep 03 14:27:39 2019 -0400
+++ b/scater-plot-tsne.R	Thu Sep 09 12:24:17 2021 +0000
@@ -12,58 +12,57 @@
 
 # parse options
 
-option_list = list(
+option_list <- list(
   make_option(
     c("-i", "--input-loom"),
     action = "store",
     default = NA,
-    type = 'character',
+    type = "character",
     help = "A SingleCellExperiment object file in Loom format."
   ),
   make_option(
     c("-c", "--colour-by"),
     action = "store",
     default = NULL,
-    type = 'character',
+    type = "character",
     help = "Feature (from annotation file) to colour t-SNE plot points by. The values represented in this options should be categorical"
   ),
   make_option(
     c("-s", "--size-by"),
     action = "store",
     default = NULL,
-    type = 'character',
+    type = "character",
     help = "Feature (from annotation file) to size t-SNE plot points by. The values represented in this options should be numerical and not categorical"
   ),
   make_option(
     c("-p", "--shape-by"),
     action = "store",
     default = NULL,
-    type = 'character',
+    type = "character",
     help = "Feature (from annotation file) to shape t-SNE plot points by. The values represented in this options should be categorical"
   ),
   make_option(
     c("-o", "--output-plot-file"),
     action = "store",
     default = NA,
-    type = 'character',
+    type = "character",
     help = "Path of the PDF output file to save plot to."
   )
 )
 
-opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file'))
+opt <- wsc_parse_args(option_list, mandatory = c("input_loom", "output_plot_file"))
+
 # Check parameter values
 
-if ( ! file.exists(opt$input_loom)){
-  stop((paste('File', opt$input_loom, 'does not exist')))
+if (! file.exists(opt$input_loom)) {
+  stop((paste("File", opt$input_loom, "does not exist")))
 }
 
-
-# Input from Loom format
+# Filter out unexpressed features
 
-scle <- import(opt$input_loom, format='loom', type='SingleCellLoomExperiment')
-scle <- normalize(scle, exprs_values = 1)
-scle <- runTSNE(scle, perplexity=10)
-plot <- plotTSNE(scle, colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by)
+sce <- import(opt$input_loom, format = "loom", type = "SingleCellLoomExperiment")
+sce <- logNormCounts(sce)
+sce <- runTSNE(sce, perplexity = 10)
+plot <- plotTSNE(sce, colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by)
 
-
-ggsave(opt$output_plot_file, plot, device="pdf")
+ggsave(opt$output_plot_file, plot, device = "pdf")