Mercurial > repos > iuc > raceid_filtnormconf
annotate scripts/cluster.R @ 0:8dc8ff057b0f draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
author | iuc |
---|---|
date | Thu, 22 Nov 2018 04:44:44 -0500 |
parents | |
children | 01290f30211f |
rev | line source |
---|---|
0
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env R |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
2 VERSION = "0.2" |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
3 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
4 args = commandArgs(trailingOnly = T) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
5 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
6 if (length(args) != 1){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
7 message(paste("VERSION:", VERSION)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
8 stop("Please provide the config file") |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
9 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
10 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
11 suppressWarnings(suppressPackageStartupMessages(require(RaceID))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
12 suppressWarnings(suppressPackageStartupMessages(require(scran))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
13 source(args[1]) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
14 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
15 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
16 do.filter <- function(sc){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
17 if (!is.null(filt.lbatch.regexes)){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
18 lar <- filt.lbatch.regexes |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
19 nn <- colnames(sc@expdata) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
20 filt$LBatch <- lapply(1:length(lar), function(m){ return( nn[grep(lar[[m]], nn)] ) }) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
21 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
22 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
23 sc <- do.call(filterdata, c(sc, filt)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
24 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
25 ## Get histogram metrics for library size and number of features |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
26 raw.lib <- log(colSums(as.matrix(sc@expdata))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
27 raw.feat <- log(rowSums(as.matrix(sc@expdata))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
28 filt.lib <- log(colSums(getfdata(sc))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
29 filt.feat <- log(rowSums(getfdata(sc))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
30 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
31 br <- 50 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
32 ## Determine limits on plots based on the unfiltered data |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
33 ## (doesn't work, R rejects limits and norm data is too different to compare to exp data |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
34 ## so let them keep their own ranges) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
35 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
36 ## betterrange <- function(floatval){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
37 ## return(10 * (floor(floatval / 10) + 1)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
38 ## } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
39 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
40 ## tmp.lib <- hist(raw.lib, breaks=br, plot=F) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
41 ## tmp.feat <- hist(raw.feat, breaks=br, plot=F) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
42 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
43 ## lib.y_lim <- c(0,betterrange(max(tmp.lib$counts))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
44 ## lib.x_lim <- c(0,betterrange(max(tmp.lib$breaks))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
45 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
46 ## feat.y_lim <- c(0,betterrange(max(tmp.feat$counts))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
47 ## feat.x_lim <- c(0,betterrange(max(tmp.feat$breaks))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
48 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
49 par(mfrow=c(2,2)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
50 print(hist(raw.lib, breaks=br, main="ExpData Log(LibSize)")) # , xlim=lib.x_lim, ylim=lib.y_lim) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
51 print(hist(raw.feat, breaks=br, main="ExpData Log(NumFeat)")) #, xlim=feat.x_lim, ylim=feat.y_lim) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
52 print(hist(filt.lib, breaks=br, main="FiltData Log(LibSize)")) # , xlim=lib.x_lim, ylim=lib.y_lim) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
53 print(hist(filt.feat, breaks=br, main="FiltData Log(NumFeat)")) # , xlim=feat.x_lim, ylim=feat.y_lim) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
54 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
55 if (filt.use.ccorrect){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
56 par(mfrow=c(2,2)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
57 sc <- do.call(CCcorrect, c(sc, filt.ccc)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
58 print(plotdimsat(sc, change=T)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
59 print(plotdimsat(sc, change=F)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
60 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
61 return(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
62 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
63 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
64 do.cluster <- function(sc){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
65 sc <- do.call(compdist, c(sc, clust.compdist)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
66 sc <- do.call(clustexp, c(sc, clust.clustexp)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
67 if (clust.clustexp$sat){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
68 print(plotsaturation(sc, disp=F)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
69 print(plotsaturation(sc, disp=T)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
70 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
71 print(plotjaccard(sc)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
72 return(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
73 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
74 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
75 do.outlier <- function(sc){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
76 sc <- do.call(findoutliers, c(sc, outlier.findoutliers)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
77 if (outlier.use.randomforest){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
78 sc <- do.call(rfcorrect, c(sc, outlier.rfcorrect)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
79 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
80 print(plotbackground(sc)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
81 print(plotsensitivity(sc)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
82 print(plotoutlierprobs(sc)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
83 ## Heatmaps |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
84 test1 <- list() |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
85 test1$side = 3 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
86 test1$line = 0 #1 #3 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
87 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
88 x <- clustheatmap(sc, final=FALSE) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
89 print(do.call(mtext, c(paste("(Initial)"), test1))) ## spacing is a hack |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
90 x <- clustheatmap(sc, final=TRUE) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
91 print(do.call(mtext, c(paste("(Final)"), test1))) ## spacing is a hack |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
92 return(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
93 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
94 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
95 do.clustmap <- function(sc){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
96 sc <- do.call(comptsne, c(sc, cluster.comptsne)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
97 sc <- do.call(compfr, c(sc, cluster.compfr)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
98 return(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
99 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
100 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
101 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
102 mkgenelist <- function(sc){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
103 ## Layout |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
104 test <- list() |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
105 test$side = 3 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
106 test$line = 0 #1 #3 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
107 test$cex = 0.8 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
108 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
109 df <- c() |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
110 options(cex = 1) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
111 lapply(unique(sc@cpart), function(n){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
112 dg <- clustdiffgenes(sc, cl=n, pvalue=genelist.pvalue) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
113 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
114 dg.goi <- dg[dg$fc > genelist.foldchange,] |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
115 dg.goi.table <- head(dg.goi, genelist.tablelim) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
116 df <<- rbind(df, cbind(n, dg.goi.table)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
117 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
118 goi <- head(rownames(dg.goi.table), genelist.plotlim) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
119 print(plotmarkergenes(sc, goi)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
120 print(do.call(mtext, c(paste(" Cluster ",n), test))) ## spacing is a hack |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
121 test$line=-1 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
122 print(do.call(mtext, c(paste(" Sig. Genes"), test))) ## spacing is a hack |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
123 test$line=-2 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
124 print(do.call(mtext, c(paste(" (fc > ", genelist.foldchange,")"), test))) ## spacing is a hack |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
125 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
126 }) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
127 write.table(df, file=out.genelist, sep="\t", quote=F) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
128 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
129 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
130 pdf(out.pdf) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
131 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
132 if (use.filtnormconf){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
133 sc <- do.filter(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
134 message(paste(" - Source:: genes:",nrow(sc@expdata),", cells:",ncol(sc@expdata))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
135 message(paste(" - Filter:: genes:",nrow(sc@ndata),", cells:",ncol(sc@ndata))) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
136 message(paste(" :: ", |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
137 sprintf("%.1f", 100 * nrow(sc@ndata)/nrow(sc@expdata)), "% of genes remain,", |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
138 sprintf("%.1f", 100 * ncol(sc@ndata)/ncol(sc@expdata)), "% of cells remain")) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
139 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
140 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
141 if (use.cluster){ |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
142 par(mfrow=c(2,2)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
143 sc <- do.cluster(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
144 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
145 par(mfrow=c(2,2)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
146 sc <- do.outlier(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
147 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
148 par(mfrow=c(2,2), mar=c(1,1,6,1)) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
149 sc <- do.clustmap(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
150 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
151 mkgenelist(sc) |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
152 } |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
153 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
154 dev.off() |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
155 |
8dc8ff057b0f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit f880060c478d42202df5b78a81329f8af56b1138
iuc
parents:
diff
changeset
|
156 saveRDS(sc, out.rdat) |