annotate scripts/raceID_tsne.R @ 0:ea8215239735 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
author iuc
date Sat, 03 Mar 2018 17:33:56 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
1 ##!/usr/bin/env Rscript
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
2
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
3 args = commandArgs(trailingOnly=T)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
4
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
5 script_dir = args[1]
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
6 config_file = args[2]
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
7
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
8 # Load libs, common functions, source RaceID,
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
9 # Galaxy Params, and read input data (sc)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
10 source(paste(script_dir, "common.R", sep="/"))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
11
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
12 # Read input data
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
13 message("Count matrix with %.0f cells and %.0f genes", dim(sc@fdata)[1], dim(sc@fdata)[2])
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
14
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
15 sc <- comptsne(sc,rseed = c_rseed)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
16
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
17 message("Plotting initial and final tSNEs")
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
18
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
19 plotter("plot_initial", plottsne(sc,final = F))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
20 plotter("plot_final", plottsne(sc,final = T))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
21
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
22 if (gene_sets != "" ){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
23 ####all_sets <- strsplit(gene_sets, "+?\\s*__split__\\s*,?")
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
24 all_sets <- strsplit(gene_sets, '\\s*\\+?\\s*_split_\\s*,?')
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
25 print(all_sets)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
26
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
27 for (given in all_sets){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
28 given <- trimws(given)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
29 message("Plotting %s", given)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
30 g <- c(unlist(strsplit(given,'\\s*\\+\\s*')))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
31 plotter(paste("plot", given, sep="_"), plotexptsne(sc,g, n=given, logsc=T))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
32 }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
33 }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
34
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
35
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
36 if (regex_val != ""){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
37 message("using subcell groups")
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
38 plotter("plot_labels", plotlabelstsne(sc, labels = sub(regex_val, "", names(sc@ndata))))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
39 plotter("plot_symbols", plotsymbolstsne(sc, types = sub(regex_val, "", names(sc@ndata))))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
40 } else {
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
41 message("using all cell ids")
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
42 plotter("plot_labels", plotlabelstsne(sc, labels = names(sc@ndata)))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
43 plotter("plot_symbols", plotsymbolstsne(sc, types = names(sc@ndata)))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
44 }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
45
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
46 message("Saving SC object")
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
47 saveRDS(sc, output_rdat)