Mercurial > repos > iuc > scater_normalize
comparison scater-plot-tsne.R @ 1:946179ef029c draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 61f3899168453092fd25691cf31871a3a350fd3b"
| author | iuc |
|---|---|
| date | Tue, 03 Sep 2019 14:28:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:87757f7b9974 | 1:946179ef029c |
|---|---|
| 1 #!/usr/bin/env Rscript | |
| 2 | |
| 3 # Creates a t-SNE 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 library(Rtsne) | |
| 12 | |
| 13 # parse options | |
| 14 | |
| 15 option_list = list( | |
| 16 make_option( | |
| 17 c("-i", "--input-loom"), | |
| 18 action = "store", | |
| 19 default = NA, | |
| 20 type = 'character', | |
| 21 help = "A SingleCellExperiment object file in Loom format." | |
| 22 ), | |
| 23 make_option( | |
| 24 c("-c", "--colour-by"), | |
| 25 action = "store", | |
| 26 default = NULL, | |
| 27 type = 'character', | |
| 28 help = "Feature (from annotation file) to colour t-SNE plot points by. The values represented in this options should be categorical" | |
| 29 ), | |
| 30 make_option( | |
| 31 c("-s", "--size-by"), | |
| 32 action = "store", | |
| 33 default = NULL, | |
| 34 type = 'character', | |
| 35 help = "Feature (from annotation file) to size t-SNE plot points by. The values represented in this options should be numerical and not categorical" | |
| 36 ), | |
| 37 make_option( | |
| 38 c("-p", "--shape-by"), | |
| 39 action = "store", | |
| 40 default = NULL, | |
| 41 type = 'character', | |
| 42 help = "Feature (from annotation file) to shape t-SNE plot points by. The values represented in this options should be categorical" | |
| 43 ), | |
| 44 make_option( | |
| 45 c("-o", "--output-plot-file"), | |
| 46 action = "store", | |
| 47 default = NA, | |
| 48 type = 'character', | |
| 49 help = "Path of the PDF output file to save plot to." | |
| 50 ) | |
| 51 ) | |
| 52 | |
| 53 opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file')) | |
| 54 # Check parameter values | |
| 55 | |
| 56 if ( ! file.exists(opt$input_loom)){ | |
| 57 stop((paste('File', opt$input_loom, 'does not exist'))) | |
| 58 } | |
| 59 | |
| 60 | |
| 61 # Input from Loom format | |
| 62 | |
| 63 scle <- import(opt$input_loom, format='loom', type='SingleCellLoomExperiment') | |
| 64 scle <- normalize(scle, exprs_values = 1) | |
| 65 scle <- runTSNE(scle, perplexity=10) | |
| 66 plot <- plotTSNE(scle, colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by) | |
| 67 | |
| 68 | |
| 69 ggsave(opt$output_plot_file, plot, device="pdf") |
