Mercurial > repos > iuc > raceid_main
annotate scripts/RaceID_class.R @ 0:e01c989c7543 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:34:16 -0500 |
parents | |
children |
rev | line source |
---|---|
0
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
1 ## load required packages. |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
2 require(tsne) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
3 require(pheatmap) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
4 require(MASS) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
5 require(cluster) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
6 require(mclust) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
7 require(flexmix) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
8 require(lattice) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
9 require(fpc) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
10 require(amap) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
11 require(RColorBrewer) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
12 require(locfit) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
13 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
14 ## class definition |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
15 SCseq <- setClass("SCseq", slots = c(expdata = "data.frame", ndata = "data.frame", fdata = "data.frame", distances = "matrix", tsne = "data.frame", kmeans = "list", background = "list", out = "list", cpart = "vector", fcol = "vector", filterpar = "list", clusterpar = "list", outlierpar ="list" )) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
16 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
17 setValidity("SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
18 function(object) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
19 msg <- NULL |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
20 if ( ! is.data.frame(object@expdata) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
21 msg <- c(msg, "input data must be data.frame") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
22 }else if ( nrow(object@expdata) < 2 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
23 msg <- c(msg, "input data must have more than one row") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
24 }else if ( ncol(object@expdata) < 2 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
25 msg <- c(msg, "input data must have more than one column") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
26 }else if (sum( apply( is.na(object@expdata),1,sum ) ) > 0 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
27 msg <- c(msg, "NAs are not allowed in input data") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
28 }else if (sum( apply( object@expdata,1,min ) ) < 0 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
29 msg <- c(msg, "negative values are not allowed in input data") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
30 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
31 if (is.null(msg)) TRUE |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
32 else msg |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
33 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
34 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
35 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
36 setMethod("initialize", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
37 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
38 definition = function(.Object, expdata ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
39 .Object@expdata <- expdata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
40 .Object@ndata <- expdata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
41 .Object@fdata <- expdata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
42 validObject(.Object) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
43 return(.Object) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
44 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
45 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
46 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
47 setGeneric("filterdata", function(object, mintotal=3000, minexpr=5, minnumber=1, maxexpr=500, downsample=FALSE, dsn=1, rseed=17000) standardGeneric("filterdata")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
48 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
49 setMethod("filterdata", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
50 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
51 definition = function(object,mintotal,minexpr,minnumber,maxexpr,downsample,dsn,rseed) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
52 if ( ! is.numeric(mintotal) ) stop( "mintotal has to be a positive number" ) else if ( mintotal <= 0 ) stop( "mintotal has to be a positive number" ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
53 if ( ! is.numeric(minexpr) ) stop( "minexpr has to be a non-negative number" ) else if ( minexpr < 0 ) stop( "minexpr has to be a non-negative number" ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
54 if ( ! is.numeric(minnumber) ) stop( "minnumber has to be a non-negative integer number" ) else if ( round(minnumber) != minnumber | minnumber < 0 ) stop( "minnumber has to be a non-negative integer number" ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
55 if ( ! ( is.numeric(downsample) | is.logical(downsample) ) ) stop( "downsample has to be logical (TRUE/FALSE)" ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
56 if ( ! is.numeric(dsn) ) stop( "dsn has to be a positive integer number" ) else if ( round(dsn) != dsn | dsn <= 0 ) stop( "dsn has to be a positive integer number" ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
57 object@filterpar <- list(mintotal=mintotal, minexpr=minexpr, minnumber=minnumber, maxexpr=maxexpr, downsample=downsample, dsn=dsn) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
58 object@ndata <- object@expdata[,apply(object@expdata,2,sum,na.rm=TRUE) >= mintotal] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
59 if ( downsample ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
60 set.seed(rseed) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
61 object@ndata <- downsample(object@expdata,n=mintotal,dsn=dsn) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
62 }else{ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
63 x <- object@ndata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
64 object@ndata <- as.data.frame( t(t(x)/apply(x,2,sum))*median(apply(x,2,sum,na.rm=TRUE)) + .1 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
65 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
66 x <- object@ndata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
67 object@fdata <- x[apply(x>=minexpr,1,sum,na.rm=TRUE) >= minnumber,] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
68 x <- object@fdata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
69 object@fdata <- x[apply(x,1,max,na.rm=TRUE) < maxexpr,] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
70 return(object) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
71 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
72 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
73 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
74 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
75 downsample <- function(x,n,dsn){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
76 x <- round( x[,apply(x,2,sum,na.rm=TRUE) >= n], 0) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
77 nn <- min( apply(x,2,sum) ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
78 for ( j in 1:dsn ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
79 z <- data.frame(GENEID=rownames(x)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
80 rownames(z) <- rownames(x) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
81 initv <- rep(0,nrow(z)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
82 for ( i in 1:dim(x)[2] ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
83 y <- aggregate(rep(1,nn),list(sample(rep(rownames(x),x[,i]),nn)),sum) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
84 na <- names(x)[i] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
85 names(y) <- c("GENEID",na) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
86 rownames(y) <- y$GENEID |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
87 z[,na] <- initv |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
88 k <- intersect(rownames(z),y$GENEID) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
89 z[k,na] <- y[k,na] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
90 z[is.na(z[,na]),na] <- 0 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
91 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
92 rownames(z) <- as.vector(z$GENEID) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
93 ds <- if ( j == 1 ) z[,-1] else ds + z[,-1] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
94 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
95 ds <- ds/dsn + .1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
96 return(ds) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
97 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
98 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
99 dist.gen <- function(x,method="euclidean", ...) if ( method %in% c("spearman","pearson","kendall") ) as.dist( 1 - cor(t(x),method=method,...) ) else dist(x,method=method,...) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
100 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
101 dist.gen.pairs <- function(x,y,...) dist.gen(t(cbind(x,y)),...) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
102 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
103 clustfun <- function(x,clustnr=20,bootnr=50,metric="pearson",do.gap=TRUE,SE.method="Tibs2001SEmax",SE.factor=.25,B.gap=50,cln=0,rseed=17000) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
104 { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
105 if ( clustnr < 2) stop("Choose clustnr > 1") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
106 di <- dist.gen(t(x),method=metric) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
107 if ( do.gap | cln > 0 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
108 gpr <- NULL |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
109 if ( do.gap ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
110 set.seed(rseed) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
111 gpr <- clusGap(as.matrix(di), FUN = kmeans, K.max = clustnr, B = B.gap) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
112 if ( cln == 0 ) cln <- maxSE(gpr$Tab[,3],gpr$Tab[,4],method=SE.method,SE.factor) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
113 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
114 if ( cln <= 1 ) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
115 clb <- list(result=list(partition=rep(1,dim(x)[2])),bootmean=1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
116 names(clb$result$partition) <- names(x) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
117 return(list(x=x,clb=clb,gpr=gpr,di=di)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
118 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
119 clb <- clusterboot(di,B=bootnr,distances=FALSE,bootmethod="boot",clustermethod=KmeansCBI,krange=cln,scaling=FALSE,multipleboot=FALSE,bscompare=TRUE,seed=rseed) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
120 return(list(x=x,clb=clb,gpr=gpr,di=di)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
121 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
122 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
123 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
124 KmeansCBI <- function (data, krange, k = NULL, scaling = FALSE, runs = 1, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
125 criterion = "ch", method="euclidean",...) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
126 { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
127 if (!is.null(k)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
128 krange <- k |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
129 if (!identical(scaling, FALSE)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
130 sdata <- scale(data, center = TRUE, scale = scaling) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
131 else sdata <- data |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
132 c1 <- Kmeansruns(sdata, krange, runs = runs, criterion = criterion, method = method, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
133 ...) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
134 partition <- c1$cluster |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
135 cl <- list() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
136 nc <- krange |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
137 for (i in 1:nc) cl[[i]] <- partition == i |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
138 out <- list(result = c1, nc = nc, clusterlist = cl, partition = partition, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
139 clustermethod = "kmeans") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
140 out |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
141 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
142 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
143 Kmeansruns <- function (data, krange = 2:10, criterion = "ch", iter.max = 100, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
144 runs = 100, scaledata = FALSE, alpha = 0.001, critout = FALSE, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
145 plot = FALSE, method="euclidean", ...) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
146 { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
147 data <- as.matrix(data) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
148 if (criterion == "asw") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
149 sdata <- dist(data) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
150 if (scaledata) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
151 data <- scale(data) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
152 cluster1 <- 1 %in% krange |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
153 crit <- numeric(max(krange)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
154 km <- list() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
155 for (k in krange) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
156 if (k > 1) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
157 minSS <- Inf |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
158 kmopt <- NULL |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
159 for (i in 1:runs) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
160 options(show.error.messages = FALSE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
161 repeat { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
162 kmm <- try(Kmeans(data, k, iter.max = iter.max, method=method, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
163 ...)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
164 if (class(kmm) != "try-error") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
165 break |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
166 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
167 options(show.error.messages = TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
168 swss <- sum(kmm$withinss) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
169 if (swss < minSS) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
170 kmopt <- kmm |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
171 minSS <- swss |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
172 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
173 if (plot) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
174 par(ask = TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
175 pairs(data, col = kmm$cluster, main = swss) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
176 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
177 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
178 km[[k]] <- kmopt |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
179 crit[k] <- switch(criterion, asw = cluster.stats(sdata, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
180 km[[k]]$cluster)$avg.silwidth, ch = calinhara(data, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
181 km[[k]]$cluster)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
182 if (critout) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
183 cat(k, " clusters ", crit[k], "\n") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
184 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
185 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
186 if (cluster1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
187 cluster1 <- dudahart2(data, km[[2]]$cluster, alpha = alpha)$cluster1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
188 k.best <- which.max(crit) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
189 if (cluster1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
190 k.best <- 1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
191 km[[k.best]]$crit <- crit |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
192 km[[k.best]]$bestk <- k.best |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
193 out <- km[[k.best]] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
194 out |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
195 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
196 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
197 binompval <- function(p,N,n){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
198 pval <- pbinom(n,round(N,0),p,lower.tail=TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
199 pval[!is.na(pval) & pval > 0.5] <- 1-pval[!is.na(pval) & pval > 0.5] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
200 return(pval) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
201 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
202 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
203 setGeneric("clustexp", function(object,clustnr=20,bootnr=50,metric="pearson",do.gap=TRUE,SE.method="Tibs2001SEmax",SE.factor=.25,B.gap=50,cln=0,rseed=17000) standardGeneric("clustexp")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
204 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
205 setMethod("clustexp", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
206 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
207 definition = function(object,clustnr,bootnr,metric,do.gap,SE.method,SE.factor,B.gap,cln,rseed) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
208 if ( ! is.numeric(clustnr) ) stop("clustnr has to be a positive integer") else if ( round(clustnr) != clustnr | clustnr <= 0 ) stop("clustnr has to be a positive integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
209 if ( ! is.numeric(bootnr) ) stop("bootnr has to be a positive integer") else if ( round(bootnr) != bootnr | bootnr <= 0 ) stop("bootnr has to be a positive integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
210 if ( ! ( metric %in% c( "spearman","pearson","kendall","euclidean","maximum","manhattan","canberra","binary","minkowski") ) ) stop("metric has to be one of the following: spearman, pearson, kendall, euclidean, maximum, manhattan, canberra, binary, minkowski") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
211 if ( ! ( SE.method %in% c( "firstSEmax","Tibs2001SEmax","globalSEmax","firstmax","globalmax") ) ) stop("SE.method has to be one of the following: firstSEmax, Tibs2001SEmax, globalSEmax, firstmax, globalmax") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
212 if ( ! is.numeric(SE.factor) ) stop("SE.factor has to be a non-negative integer") else if ( SE.factor < 0 ) stop("SE.factor has to be a non-negative integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
213 if ( ! ( is.numeric(do.gap) | is.logical(do.gap) ) ) stop( "do.gap has to be logical (TRUE/FALSE)" ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
214 if ( ! is.numeric(B.gap) ) stop("B.gap has to be a positive integer") else if ( round(B.gap) != B.gap | B.gap <= 0 ) stop("B.gap has to be a positive integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
215 if ( ! is.numeric(cln) ) stop("cln has to be a non-negative integer") else if ( round(cln) != cln | cln < 0 ) stop("cln has to be a non-negative integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
216 if ( ! is.numeric(rseed) ) stop("rseed has to be numeric") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
217 if ( !do.gap & cln == 0 ) stop("cln has to be a positive integer or do.gap has to be TRUE") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
218 object@clusterpar <- list(clustnr=clustnr,bootnr=bootnr,metric=metric,do.gap=do.gap,SE.method=SE.method,SE.factor=SE.factor,B.gap=B.gap,cln=cln,rseed=rseed) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
219 y <- clustfun(object@fdata,clustnr,bootnr,metric,do.gap,SE.method,SE.factor,B.gap,cln,rseed) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
220 object@kmeans <- list(kpart=y$clb$result$partition, jaccard=y$clb$bootmean, gap=y$gpr) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
221 object@distances <- as.matrix( y$di ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
222 set.seed(111111) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
223 object@fcol <- sample(rainbow(max(y$clb$result$partition))) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
224 return(object) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
225 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
226 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
227 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
228 setGeneric("findoutliers", function(object,outminc=5,outlg=2,probthr=1e-3,thr=2**-(1:40),outdistquant=.75) standardGeneric("findoutliers")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
229 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
230 setMethod("findoutliers", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
231 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
232 definition = function(object,outminc,outlg,probthr,thr,outdistquant) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
233 if ( length(object@kmeans$kpart) == 0 ) stop("run clustexp before findoutliers") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
234 if ( ! is.numeric(outminc) ) stop("outminc has to be a non-negative integer") else if ( round(outminc) != outminc | outminc < 0 ) stop("outminc has to be a non-negative integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
235 if ( ! is.numeric(outlg) ) stop("outlg has to be a non-negative integer") else if ( round(outlg) != outlg | outlg < 0 ) stop("outlg has to be a non-negative integer") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
236 if ( ! is.numeric(probthr) ) stop("probthr has to be a number between 0 and 1") else if ( probthr < 0 | probthr > 1 ) stop("probthr has to be a number between 0 and 1") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
237 if ( ! is.numeric(thr) ) stop("thr hast to be a vector of numbers between 0 and 1") else if ( min(thr) < 0 | max(thr) > 1 ) stop("thr hast to be a vector of numbers between 0 and 1") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
238 if ( ! is.numeric(outdistquant) ) stop("outdistquant has to be a number between 0 and 1") else if ( outdistquant < 0 | outdistquant > 1 ) stop("outdistquant has to be a number between 0 and 1") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
239 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
240 object@outlierpar <- list( outminc=outminc,outlg=outlg,probthr=probthr,thr=thr,outdistquant=outdistquant ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
241 ### calibrate background model |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
242 m <- log2(apply(object@fdata,1,mean)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
243 v <- log2(apply(object@fdata,1,var)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
244 f <- m > -Inf & v > -Inf |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
245 m <- m[f] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
246 v <- v[f] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
247 mm <- -8 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
248 repeat{ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
249 fit <- lm(v ~ m + I(m^2)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
250 if( coef(fit)[3] >= 0 | mm >= 3){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
251 break |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
252 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
253 mm <- mm + .5 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
254 f <- m > mm |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
255 m <- m[f] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
256 v <- v[f] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
257 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
258 object@background <- list() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
259 object@background$vfit <- fit |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
260 object@background$lvar <- function(x,object) 2**(coef(object@background$vfit)[1] + log2(x)*coef(object@background$vfit)[2] + coef(object@background$vfit)[3] * log2(x)**2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
261 object@background$lsize <- function(x,object) x**2/(max(x + 1e-6,object@background$lvar(x,object)) - x) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
262 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
263 ### identify outliers |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
264 out <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
265 stest <- rep(0,length(thr)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
266 cprobs <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
267 for ( n in 1:max(object@kmeans$kpart) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
268 if ( sum(object@kmeans$kpart == n) == 1 ){ cprobs <- append(cprobs,.5); names(cprobs)[length(cprobs)] <- names(object@kmeans$kpart)[object@kmeans$kpart == n]; next } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
269 x <- object@fdata[,object@kmeans$kpart == n] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
270 x <- x[apply(x,1,max) > outminc,] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
271 z <- t( apply(x,1,function(x){ apply( cbind( pnbinom(round(x,0),mu=mean(x),size=object@background$lsize(mean(x),object)) , 1 - pnbinom(round(x,0),mu=mean(x),size=object@background$lsize(mean(x),object)) ),1, min) } ) ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
272 cp <- apply(z,2,function(x){ y <- p.adjust(x,method="BH"); y <- y[order(y,decreasing=FALSE)]; return(y[outlg]);}) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
273 f <- cp < probthr |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
274 cprobs <- append(cprobs,cp) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
275 if ( sum(f) > 0 ) out <- append(out,names(x)[f]) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
276 for ( j in 1:length(thr) ) stest[j] <- stest[j] + sum( cp < thr[j] ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
277 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
278 object@out <-list(out=out,stest=stest,thr=thr,cprobs=cprobs) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
279 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
280 ### cluster outliers |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
281 clp2p.cl <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
282 cols <- names(object@fdata) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
283 di <- as.data.frame(object@distances) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
284 for ( i in 1:max(object@kmeans$kpart) ) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
285 tcol <- cols[object@kmeans$kpart == i] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
286 if ( sum(!(tcol %in% out)) > 1 ) clp2p.cl <- append(clp2p.cl,as.vector(t(di[tcol[!(tcol %in% out)],tcol[!(tcol %in% out)]]))) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
287 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
288 clp2p.cl <- clp2p.cl[clp2p.cl>0] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
289 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
290 cpart <- object@kmeans$kpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
291 cadd <- list() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
292 if ( length(out) > 0 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
293 if (length(out) == 1){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
294 cadd <- list(out) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
295 }else{ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
296 n <- out |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
297 m <- as.data.frame(di[out,out]) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
298 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
299 for ( i in 1:length(out) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
300 if ( length(n) > 1 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
301 o <- order(apply(cbind(m,1:dim(m)[1]),1,function(x) min(x[1:(length(x)-1)][-x[length(x)]])),decreasing=FALSE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
302 m <- m[o,o] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
303 n <- n[o] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
304 f <- m[,1] < quantile(clp2p.cl,outdistquant) | m[,1] == min(clp2p.cl) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
305 ind <- 1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
306 if ( sum(f) > 1 ) for ( j in 2:sum(f) ) if ( apply(m[f,f][j,c(ind,j)] > quantile(clp2p.cl,outdistquant) ,1,sum) == 0 ) ind <- append(ind,j) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
307 cadd[[i]] <- n[f][ind] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
308 g <- ! n %in% n[f][ind] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
309 n <- n[g] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
310 m <- m[g,g] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
311 if ( sum(g) == 0 ) break |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
312 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
313 }else if (length(n) == 1){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
314 cadd[[i]] <- n |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
315 break |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
316 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
317 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
318 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
319 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
320 for ( i in 1:length(cadd) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
321 cpart[cols %in% cadd[[i]]] <- max(cpart) + 1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
322 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
323 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
324 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
325 ### determine final clusters |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
326 for ( i in 1:max(cpart) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
327 d <- object@fdata[,cols[cpart == i]] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
328 if ( sum(cpart == i) == 1 ) cent <- d else cent <- apply(d,1,mean) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
329 if ( i == 1 ) dcent <- data.frame(cent) else dcent <- cbind(dcent,cent) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
330 if ( i == 1 ) tmp <- data.frame(apply(object@fdata[,cols],2,dist.gen.pairs,y=cent,method=object@clusterpar$metric)) else tmp <- cbind(tmp,apply(object@fdata[,cols],2,dist.gen.pairs,y=cent,method=object@clusterpar$metric)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
331 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
332 cpart <- apply(tmp,1,function(x) order(x,decreasing=FALSE)[1]) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
333 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
334 for ( i in max(cpart):1){if (sum(cpart==i)==0) cpart[cpart>i] <- cpart[cpart>i] - 1 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
335 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
336 object@cpart <- cpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
337 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
338 set.seed(111111) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
339 object@fcol <- sample(rainbow(max(cpart))) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
340 return(object) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
341 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
342 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
343 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
344 setGeneric("plotgap", function(object) standardGeneric("plotgap")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
345 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
346 setMethod("plotgap", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
347 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
348 definition = function(object){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
349 if ( length(object@kmeans$kpart) == 0 ) stop("run clustexp before plotgap") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
350 plot(object@kmeans$gap) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
351 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
352 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
353 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
354 setGeneric("plotsilhouette", function(object) standardGeneric("plotsilhouette")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
355 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
356 setMethod("plotsilhouette", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
357 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
358 definition = function(object){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
359 if ( length(object@kmeans$kpart) == 0 ) stop("run clustexp before plotsilhouette") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
360 if ( length(unique(object@kmeans$kpart)) < 2 ) stop("only a single cluster: no silhouette plot") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
361 kpart <- object@kmeans$kpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
362 distances <- dist.gen(object@distances) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
363 si <- silhouette(kpart,distances) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
364 plot(si) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
365 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
366 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
367 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
368 setGeneric("plotjaccard", function(object) standardGeneric("plotjaccard")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
369 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
370 setMethod("plotjaccard", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
371 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
372 definition = function(object){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
373 if ( length(object@kmeans$kpart) == 0 ) stop("run clustexp before plotjaccard") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
374 if ( length(unique(object@kmeans$kpart)) < 2 ) stop("only a single cluster: no Jaccard's similarity plot") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
375 barplot(object@kmeans$jaccard,names.arg=1:length(object@kmeans$jaccard),ylab="Jaccard's similarity") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
376 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
377 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
378 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
379 setGeneric("plotoutlierprobs", function(object) standardGeneric("plotoutlierprobs")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
380 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
381 setMethod("plotoutlierprobs", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
382 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
383 definition = function(object){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
384 if ( length(object@cpart) == 0 ) stop("run findoutliers before plotoutlierprobs") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
385 p <- object@kmeans$kpart[ order(object@kmeans$kpart,decreasing=FALSE)] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
386 x <- object@out$cprobs[names(p)] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
387 fcol <- object@fcol |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
388 for ( i in 1:max(p) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
389 y <- -log10(x + 2.2e-16) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
390 y[p != i] <- 0 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
391 if ( i == 1 ) b <- barplot(y,ylim=c(0,max(-log10(x + 2.2e-16))*1.1),col=fcol[i],border=fcol[i],names.arg=FALSE,ylab="-log10prob") else barplot(y,add=TRUE,col=fcol[i],border=fcol[i],names.arg=FALSE,axes=FALSE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
392 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
393 abline(-log10(object@outlierpar$probthr),0,col="black",lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
394 d <- b[2,1] - b[1,1] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
395 y <- 0 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
396 for ( i in 1:max(p) ) y <- append(y,b[sum(p <=i),1] + d/2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
397 axis(1,at=(y[1:(length(y)-1)] + y[-1])/2,lab=1:max(p)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
398 box() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
399 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
400 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
401 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
402 setGeneric("plotbackground", function(object) standardGeneric("plotbackground")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
403 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
404 setMethod("plotbackground", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
405 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
406 definition = function(object){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
407 if ( length(object@cpart) == 0 ) stop("run findoutliers before plotbackground") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
408 m <- apply(object@fdata,1,mean) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
409 v <- apply(object@fdata,1,var) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
410 fit <- locfit(v~lp(m,nn=.7),family="gamma",maxk=500) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
411 plot(log2(m),log2(v),pch=20,xlab="log2mean",ylab="log2var",col="grey") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
412 lines(log2(m[order(m)]),log2(object@background$lvar(m[order(m)],object)),col="red",lwd=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
413 lines(log2(m[order(m)]),log2(fitted(fit)[order(m)]),col="orange",lwd=2,lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
414 legend("topleft",legend=substitute(paste("y = ",a,"*x^2 + ",b,"*x + ",d,sep=""),list(a=round(coef(object@background$vfit)[3],2),b=round(coef(object@background$vfit)[2],2),d=round(coef(object@background$vfit)[1],2))),bty="n") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
415 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
416 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
417 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
418 setGeneric("plotsensitivity", function(object) standardGeneric("plotsensitivity")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
419 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
420 setMethod("plotsensitivity", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
421 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
422 definition = function(object){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
423 if ( length(object@cpart) == 0 ) stop("run findoutliers before plotsensitivity") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
424 plot(log10(object@out$thr), object@out$stest, type="l",xlab="log10 Probability cutoff", ylab="Number of outliers") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
425 abline(v=log10(object@outlierpar$probthr),col="red",lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
426 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
427 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
428 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
429 setGeneric("clustdiffgenes", function(object,pvalue=.01) standardGeneric("clustdiffgenes")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
430 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
431 setMethod("clustdiffgenes", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
432 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
433 definition = function(object,pvalue){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
434 if ( length(object@cpart) == 0 ) stop("run findoutliers before clustdiffgenes") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
435 if ( ! is.numeric(pvalue) ) stop("pvalue has to be a number between 0 and 1") else if ( pvalue < 0 | pvalue > 1 ) stop("pvalue has to be a number between 0 and 1") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
436 cdiff <- list() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
437 x <- object@ndata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
438 y <- object@expdata[,names(object@ndata)] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
439 part <- object@cpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
440 for ( i in 1:max(part) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
441 if ( sum(part == i) == 0 ) next |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
442 m <- apply(x,1,mean) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
443 n <- if ( sum(part == i) > 1 ) apply(x[,part == i],1,mean) else x[,part == i] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
444 no <- if ( sum(part == i) > 1 ) median(apply(y[,part == i],2,sum))/median(apply(x[,part == i],2,sum)) else sum(y[,part == i])/sum(x[,part == i]) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
445 m <- m*no |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
446 n <- n*no |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
447 pv <- binompval(m/sum(m),sum(n),n) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
448 d <- data.frame(mean.all=m,mean.cl=n,fc=n/m,pv=pv)[order(pv,decreasing=FALSE),] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
449 cdiff[[paste("cl",i,sep=".")]] <- d[d$pv < pvalue,] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
450 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
451 return(cdiff) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
452 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
453 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
454 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
455 setGeneric("diffgenes", function(object,cl1,cl2,mincount=5) standardGeneric("diffgenes")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
456 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
457 setMethod("diffgenes", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
458 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
459 definition = function(object,cl1,cl2,mincount){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
460 part <- object@cpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
461 cl1 <- c(cl1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
462 cl2 <- c(cl2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
463 if ( length(part) == 0 ) stop("run findoutliers before diffgenes") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
464 if ( ! is.numeric(mincount) ) stop("mincount has to be a non-negative number") else if ( mincount < 0 ) stop("mincount has to be a non-negative number") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
465 if ( length(intersect(cl1, part)) < length(unique(cl1)) ) stop( paste("cl1 has to be a subset of ",paste(sort(unique(part)),collapse=","),"\n",sep="") ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
466 if ( length(intersect(cl2, part)) < length(unique(cl2)) ) stop( paste("cl2 has to be a subset of ",paste(sort(unique(part)),collapse=","),"\n",sep="") ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
467 f <- apply(object@ndata[,part %in% c(cl1,cl2)],1,max) > mincount |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
468 x <- object@ndata[f,part %in% cl1] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
469 y <- object@ndata[f,part %in% cl2] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
470 if ( sum(part %in% cl1) == 1 ) m1 <- x else m1 <- apply(x,1,mean) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
471 if ( sum(part %in% cl2) == 1 ) m2 <- y else m2 <- apply(y,1,mean) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
472 if ( sum(part %in% cl1) == 1 ) s1 <- sqrt(x) else s1 <- sqrt(apply(x,1,var)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
473 if ( sum(part %in% cl2) == 1 ) s2 <- sqrt(y) else s2 <- sqrt(apply(y,1,var)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
474 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
475 d <- ( m1 - m2 )/ apply( cbind( s1, s2 ),1,mean ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
476 names(d) <- rownames(object@ndata)[f] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
477 if ( sum(part %in% cl1) == 1 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
478 names(x) <- names(d) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
479 x <- x[order(d,decreasing=TRUE)] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
480 }else{ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
481 x <- x[order(d,decreasing=TRUE),] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
482 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
483 if ( sum(part %in% cl2) == 1 ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
484 names(y) <- names(d) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
485 y <- y[order(d,decreasing=TRUE)] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
486 }else{ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
487 y <- y[order(d,decreasing=TRUE),] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
488 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
489 return(list(z=d[order(d,decreasing=TRUE)],cl1=x,cl2=y,cl1n=cl1,cl2n=cl2)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
490 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
491 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
492 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
493 plotdiffgenes <- function(z,gene=g){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
494 if ( ! is.list(z) ) stop("first arguments needs to be output of function diffgenes") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
495 if ( length(z) < 5 ) stop("first arguments needs to be output of function diffgenes") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
496 if ( sum(names(z) == c("z","cl1","cl2","cl1n","cl2n")) < 5 ) stop("first arguments needs to be output of function diffgenes") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
497 if ( length(gene) > 1 ) stop("only single value allowed for argument gene") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
498 if ( !is.numeric(gene) & !(gene %in% names(z$z)) ) stop("argument gene needs to be within rownames of first argument or a positive integer number") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
499 if ( is.numeric(gene) ){ if ( gene < 0 | round(gene) != gene ) stop("argument gene needs to be within rownames of first argument or a positive integer number") } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
500 x <- if ( is.null(dim(z$cl1)) ) z$cl1[gene] else t(z$cl1[gene,]) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
501 y <- if ( is.null(dim(z$cl2)) ) z$cl2[gene] else t(z$cl2[gene,]) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
502 plot(1:length(c(x,y)),c(x,y),ylim=c(0,max(c(x,y))),xlab="",ylab="Expression",main=gene,cex=0,axes=FALSE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
503 axis(2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
504 box() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
505 u <- 1:length(x) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
506 rect(u - .5,0,u + .5,x,col="red") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
507 v <- c(min(u) - .5,max(u) + .5) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
508 axis(1,at=mean(v),lab=paste(z$cl1n,collapse=",")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
509 lines(v,rep(mean(x),length(v))) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
510 lines(v,rep(mean(x)-sqrt(var(x)),length(v)),lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
511 lines(v,rep(mean(x)+sqrt(var(x)),length(v)),lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
512 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
513 u <- ( length(x) + 1 ):length(c(x,y)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
514 v <- c(min(u) - .5,max(u) + .5) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
515 rect(u - .5,0,u + .5,y,col="blue") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
516 axis(1,at=mean(v),lab=paste(z$cl2n,collapse=",")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
517 lines(v,rep(mean(y),length(v))) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
518 lines(v,rep(mean(y)-sqrt(var(y)),length(v)),lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
519 lines(v,rep(mean(y)+sqrt(var(y)),length(v)),lty=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
520 abline(v=length(x) + .5) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
521 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
522 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
523 setGeneric("clustheatmap", function(object,final=FALSE,hmethod="single") standardGeneric("clustheatmap")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
524 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
525 setMethod("clustheatmap", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
526 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
527 definition = function(object,final,hmethod){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
528 if ( final & length(object@cpart) == 0 ) stop("run findoutliers before clustheatmap") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
529 if ( !final & length(object@kmeans$kpart) == 0 ) stop("run clustexp before clustheatmap") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
530 x <- object@fdata |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
531 part <- if ( final ) object@cpart else object@kmeans$kpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
532 na <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
533 j <- 0 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
534 for ( i in 1:max(part) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
535 if ( sum(part == i) == 0 ) next |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
536 j <- j + 1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
537 na <- append(na,i) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
538 d <- x[,part == i] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
539 if ( sum(part == i) == 1 ) cent <- d else cent <- apply(d,1,mean) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
540 if ( j == 1 ) tmp <- data.frame(cent) else tmp <- cbind(tmp,cent) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
541 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
542 names(tmp) <- paste("cl",na,sep=".") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
543 if ( max(part) > 1 ) cclmo <- hclust(dist.gen(as.matrix(dist.gen(t(tmp),method=object@clusterpar$metric))),method=hmethod)$order else cclmo <- 1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
544 q <- part |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
545 for ( i in 1:max(part) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
546 q[part == na[cclmo[i]]] <- i |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
547 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
548 part <- q |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
549 di <- as.data.frame( as.matrix( dist.gen(t(object@distances)) ) ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
550 pto <- part[order(part,decreasing=FALSE)] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
551 ptn <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
552 for ( i in 1:max(pto) ){ pt <- names(pto)[pto == i]; z <- if ( length(pt) == 1 ) pt else pt[hclust(as.dist(t(di[pt,pt])),method=hmethod)$order]; ptn <- append(ptn,z) } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
553 col <- object@fcol |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
554 mi <- min(di,na.rm=TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
555 ma <- max(di,na.rm=TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
556 layout(matrix(data=c(1,3,2,4), nrow=2, ncol=2), widths=c(5,1,5,1), heights=c(5,1,1,1)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
557 ColorRamp <- colorRampPalette(brewer.pal(n = 7,name = "RdYlBu"))(100) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
558 ColorLevels <- seq(mi, ma, length=length(ColorRamp)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
559 if ( mi == ma ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
560 ColorLevels <- seq(0.99*mi, 1.01*ma, length=length(ColorRamp)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
561 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
562 par(mar = c(3,5,2.5,2)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
563 image(as.matrix(di[ptn,ptn]),col=ColorRamp,axes=FALSE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
564 abline(0,1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
565 box() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
566 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
567 tmp <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
568 for ( u in 1:max(part) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
569 ol <- (0:(length(part) - 1)/(length(part) - 1))[ptn %in% names(x)[part == u]] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
570 points(rep(0,length(ol)),ol,col=col[cclmo[u]],pch=15,cex=.75) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
571 points(ol,rep(0,length(ol)),col=col[cclmo[u]],pch=15,cex=.75) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
572 tmp <- append(tmp,mean(ol)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
573 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
574 axis(1,at=tmp,lab=cclmo) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
575 axis(2,at=tmp,lab=cclmo) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
576 par(mar = c(3,2.5,2.5,2)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
577 image(1, ColorLevels, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
578 matrix(data=ColorLevels, ncol=length(ColorLevels),nrow=1), |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
579 col=ColorRamp, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
580 xlab="",ylab="", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
581 xaxt="n") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
582 layout(1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
583 return(cclmo) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
584 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
585 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
586 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
587 setGeneric("comptsne", function(object,rseed=15555) standardGeneric("comptsne")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
588 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
589 setMethod("comptsne", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
590 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
591 definition = function(object,rseed){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
592 if ( length(object@kmeans$kpart) == 0 ) stop("run clustexp before comptsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
593 set.seed(rseed) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
594 di <- dist.gen(as.matrix(object@distances)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
595 ts <- tsne(di,k=2) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
596 object@tsne <- as.data.frame(ts) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
597 return(object) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
598 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
599 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
600 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
601 setGeneric("plottsne", function(object,final=TRUE) standardGeneric("plottsne")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
602 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
603 setMethod("plottsne", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
604 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
605 definition = function(object,final){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
606 if ( length(object@tsne) == 0 ) stop("run comptsne before plottsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
607 if ( final & length(object@cpart) == 0 ) stop("run findoutliers before plottsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
608 if ( !final & length(object@kmeans$kpart) == 0 ) stop("run clustexp before plottsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
609 part <- if ( final ) object@cpart else object@kmeans$kpart |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
610 plot(object@tsne,xlab="Dim 1",ylab="Dim 2",pch=20,cex=1.5,col="lightgrey") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
611 for ( i in 1:max(part) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
612 if ( sum(part == i) > 0 ) text(object@tsne[part == i,1],object@tsne[part == i,2],i,col=object@fcol[i],cex=.75,font=4) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
613 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
614 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
615 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
616 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
617 setGeneric("plotlabelstsne", function(object,labels=NULL) standardGeneric("plotlabelstsne")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
618 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
619 setMethod("plotlabelstsne", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
620 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
621 definition = function(object,labels){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
622 if ( is.null(labels ) ) labels <- names(object@ndata) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
623 if ( length(object@tsne) == 0 ) stop("run comptsne before plotlabelstsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
624 plot(object@tsne,xlab="Dim 1",ylab="Dim 2",pch=20,cex=1.5,col="lightgrey") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
625 text(object@tsne[,1],object@tsne[,2],labels,cex=.5) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
626 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
627 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
628 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
629 setGeneric("plotsymbolstsne", function(object,types=NULL) standardGeneric("plotsymbolstsne")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
630 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
631 setMethod("plotsymbolstsne", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
632 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
633 definition = function(object,types){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
634 if ( is.null(types) ) types <- names(object@fdata) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
635 if ( length(object@tsne) == 0 ) stop("run comptsne before plotsymbolstsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
636 if ( length(types) != ncol(object@fdata) ) stop("types argument has wrong length. Length has to equal to the column number of object@ndata") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
637 coloc <- rainbow(length(unique(types))) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
638 syms <- c() |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
639 plot(object@tsne,xlab="Dim 1",ylab="Dim 2",pch=20,col="grey") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
640 for ( i in 1:length(unique(types)) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
641 f <- types == sort(unique(types))[i] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
642 syms <- append( syms, ( (i-1) %% 25 ) + 1 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
643 points(object@tsne[f,1],object@tsne[f,2],col=coloc[i],pch=( (i-1) %% 25 ) + 1,cex=1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
644 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
645 legend("topleft", legend=sort(unique(types)), col=coloc, pch=syms) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
646 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
647 ) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
648 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
649 setGeneric("plotexptsne", function(object,g,n="",logsc=FALSE) standardGeneric("plotexptsne")) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
650 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
651 setMethod("plotexptsne", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
652 signature = "SCseq", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
653 definition = function(object,g,n="",logsc=FALSE){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
654 if ( length(object@tsne) == 0 ) stop("run comptsne before plottsne") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
655 if ( length(intersect(g,rownames(object@ndata))) < length(unique(g)) ) stop("second argument does not correspond to set of rownames slot ndata of SCseq object") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
656 if ( !is.numeric(logsc) & !is.logical(logsc) ) stop("argument logsc has to be logical (TRUE/FALSE)") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
657 if ( n == "" ) n <- g[1] |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
658 l <- apply(object@ndata[g,] - .1,2,sum) + .1 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
659 if (logsc) { |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
660 f <- l == 0 |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
661 l <- log(l) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
662 l[f] <- NA |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
663 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
664 mi <- min(l,na.rm=TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
665 ma <- max(l,na.rm=TRUE) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
666 ColorRamp <- colorRampPalette(rev(brewer.pal(n = 7,name = "RdYlBu")))(100) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
667 ColorLevels <- seq(mi, ma, length=length(ColorRamp)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
668 v <- round((l - mi)/(ma - mi)*99 + 1,0) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
669 layout(matrix(data=c(1,3,2,4), nrow=2, ncol=2), widths=c(5,1,5,1), heights=c(5,1,1,1)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
670 par(mar = c(3,5,2.5,2)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
671 plot(object@tsne,xlab="Dim 1",ylab="Dim 2",main=n,pch=20,cex=0,col="grey") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
672 for ( k in 1:length(v) ){ |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
673 points(object@tsne[k,1],object@tsne[k,2],col=ColorRamp[v[k]],pch=20,cex=1.5) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
674 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
675 par(mar = c(3,2.5,2.5,2)) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
676 image(1, ColorLevels, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
677 matrix(data=ColorLevels, ncol=length(ColorLevels),nrow=1), |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
678 col=ColorRamp, |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
679 xlab="",ylab="", |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
680 xaxt="n") |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
681 layout(1) |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
682 } |
e01c989c7543
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff
changeset
|
683 ) |