Mercurial > repos > iuc > scater_plot_pca
comparison scater-plot-tsne.R @ 2:9e5c0bb18d08 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:55 +0000 |
| parents | 46fc6751d746 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:46fc6751d746 | 2:9e5c0bb18d08 |
|---|---|
| 10 library(scater) | 10 library(scater) |
| 11 library(Rtsne) | 11 library(Rtsne) |
| 12 | 12 |
| 13 # parse options | 13 # parse options |
| 14 | 14 |
| 15 option_list = list( | 15 option_list <- list( |
| 16 make_option( | 16 make_option( |
| 17 c("-i", "--input-loom"), | 17 c("-i", "--input-loom"), |
| 18 action = "store", | 18 action = "store", |
| 19 default = NA, | 19 default = NA, |
| 20 type = 'character', | 20 type = "character", |
| 21 help = "A SingleCellExperiment object file in Loom format." | 21 help = "A SingleCellExperiment object file in Loom format." |
| 22 ), | 22 ), |
| 23 make_option( | 23 make_option( |
| 24 c("-c", "--colour-by"), | 24 c("-c", "--colour-by"), |
| 25 action = "store", | 25 action = "store", |
| 26 default = NULL, | 26 default = NULL, |
| 27 type = 'character', | 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" | 28 help = "Feature (from annotation file) to colour t-SNE plot points by. The values represented in this options should be categorical" |
| 29 ), | 29 ), |
| 30 make_option( | 30 make_option( |
| 31 c("-s", "--size-by"), | 31 c("-s", "--size-by"), |
| 32 action = "store", | 32 action = "store", |
| 33 default = NULL, | 33 default = NULL, |
| 34 type = 'character', | 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" | 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 ), | 36 ), |
| 37 make_option( | 37 make_option( |
| 38 c("-p", "--shape-by"), | 38 c("-p", "--shape-by"), |
| 39 action = "store", | 39 action = "store", |
| 40 default = NULL, | 40 default = NULL, |
| 41 type = 'character', | 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" | 42 help = "Feature (from annotation file) to shape t-SNE plot points by. The values represented in this options should be categorical" |
| 43 ), | 43 ), |
| 44 make_option( | 44 make_option( |
| 45 c("-o", "--output-plot-file"), | 45 c("-o", "--output-plot-file"), |
| 46 action = "store", | 46 action = "store", |
| 47 default = NA, | 47 default = NA, |
| 48 type = 'character', | 48 type = "character", |
| 49 help = "Path of the PDF output file to save plot to." | 49 help = "Path of the PDF output file to save plot to." |
| 50 ) | 50 ) |
| 51 ) | 51 ) |
| 52 | 52 |
| 53 opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file')) | 53 opt <- wsc_parse_args(option_list, mandatory = c("input_loom", "output_plot_file")) |
| 54 | |
| 54 # Check parameter values | 55 # Check parameter values |
| 55 | 56 |
| 56 if ( ! file.exists(opt$input_loom)){ | 57 if (! file.exists(opt$input_loom)) { |
| 57 stop((paste('File', opt$input_loom, 'does not exist'))) | 58 stop((paste("File", opt$input_loom, "does not exist"))) |
| 58 } | 59 } |
| 59 | 60 |
| 61 # Filter out unexpressed features | |
| 60 | 62 |
| 61 # Input from Loom format | 63 sce <- import(opt$input_loom, format = "loom", type = "SingleCellLoomExperiment") |
| 64 sce <- logNormCounts(sce) | |
| 65 sce <- runTSNE(sce, perplexity = 10) | |
| 66 plot <- plotTSNE(sce, colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by) | |
| 62 | 67 |
| 63 scle <- import(opt$input_loom, format='loom', type='SingleCellLoomExperiment') | 68 ggsave(opt$output_plot_file, plot, device = "pdf") |
| 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") |
