annotate R/Heatmaply.R @ 15:dbde253606c5 draft default tip

Uploaded
author dereeper
date Wed, 11 Dec 2024 08:25:06 +0000
parents 5a5c9a6b047b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/R
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
2
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
3 library("optparse")
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
4 library(heatmaply)
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
5
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
6 option_list = list(
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
7 make_option(c("-f", "--file"), type="character", default=NULL,
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
8 help="dataset file name", metavar="character"),
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
9 make_option(c("-o", "--out"), type="character", default="out.txt",
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
10 help="output file name [default= %default]", metavar="character")
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
11 );
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
12 opt_parser = OptionParser(option_list=option_list);
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
13 opt = parse_args(opt_parser);
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
14
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
15 if (is.null(opt$file)){
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
16 print_help(opt_parser)
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
17 stop("At least one argument must be supplied (input file).\n", call.=FALSE)
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
18 }
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
19
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
20 if (is.null(opt$out)){
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
21 print_help(opt_parser)
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
22 stop("At least one argument must be supplied (out file).\n", call.=FALSE)
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
23 }
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
24
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
25 mydata <- read.table(opt$file,sep="\t",fill=TRUE,header=TRUE, row.names = 1)
5a5c9a6b047b Uploaded
dereeper
parents:
diff changeset
26 heatmaply(mydata,file = "heatmaply.html",plot_method="plotly",scale_fill_gradient_fun = ggplot2::scale_fill_gradient2( low = "white" , high = "blue", limits = c(0, 100)))