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

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
author iuc
date Sat, 03 Mar 2018 17:33:56 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
1 #!/usr/bin/env Rscript
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
2
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
3 args = commandArgs(trailingOnly=T)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
4
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
5 script_dir = args[1]
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
6 config_file = args[2]
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
7
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
8 # Load libs, common functions, source RaceID,
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
9 # Galaxy Params, and read input data (sc)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
10 source(paste(script_dir, "common.R", sep="/"))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
11
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
12 # Read input data
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
13 message("Count matrix with %.0f cells and %.0f genes", dim(sc@fdata)[1], dim(sc@fdata)[2])
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
14
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
15 cdiff <- clustdiffgenes(sc, pvalue=c_pval)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
16
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
17 if (generate_extable){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
18 # differentially expressed genes in cluster
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
19
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
20 if (!(dir.exists(outtable_dir))){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
21 dir.create(outtable_dir)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
22 }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
23
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
24 for ( n in names(cdiff) ){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
25 write.table(
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
26 data.frame(
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
27 GENEID=rownames(cdiff[[n]]),
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
28 cdiff[[n]]
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
29 ),
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
30 paste(outtable_dir, "/gdiff", "_", n, ".tsv", sep=""), # gdiff_cl.n.tsv
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
31 row.names=FALSE,
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
32 col.names=TRUE,
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
33 sep="\t",
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
34 quote=FALSE
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
35 )
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
36 }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
37 }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
38
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
39 if (compare_clusters){
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
40 clust1 <- c(unlist(lapply(strsplit(clust1, "\\s*,\\s*"), as.integer)))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
41 clust2 <- c(unlist(lapply(strsplit(clust2, "\\s*,\\s*"), as.integer)))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
42
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
43 if (length(clust1) == 1){ clust1 <- clust1[[1]] }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
44 if (length(clust2) == 1){ clust2 <- clust2[[1]] }
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
45
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
46 message("Performing diffgenes with cl1=%s, cl2=%s, mincount=%.0f, gene='%s'", clust1, clust2, mcount, gene_name)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
47 d <- diffgenes(sc,cl1 = clust1, cl2 = clust2, mincount = mcount)
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
48
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
49 plotter("plot_diffgenes", plotdiffgenes(d,gene= gene_name))
ea8215239735 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid commit 39918bfdb08f06862ca395ce58a6f5e4f6dd1a5e
iuc
parents:
diff changeset
50 }