comparison R/heatmaply.R @ 3:e42d30da7a74 draft

Uploaded
author dereeper
date Thu, 30 May 2024 11:52:25 +0000
parents
children
comparison
equal deleted inserted replaced
2:97e4e3e818b6 3:e42d30da7a74
1 #!/usr/bin/R
2
3 library(heatmaply)
4 library("optparse")
5
6 option_list = list(
7 make_option(c("-f", "--file"), type="character", default=NULL,
8 help="dataset file name", metavar="character"),
9 make_option(c("-o", "--out"), type="character", default="out.txt",
10 help="output file name [default= %default]", metavar="character"),
11 make_option(c("-r", "--rowmetadata"), type="character", default=NULL,
12 help="metadata for rows", metavar="character"),
13 make_option(c("-c", "--colmetadata"), type="character", default=NULL,
14 help="metadata for cols", metavar="character")
15 );
16 opt_parser = OptionParser(option_list=option_list);
17 opt = parse_args(opt_parser);
18
19 if (is.null(opt$file)){
20 print_help(opt_parser)
21 stop("At least one argument must be supplied (input file).\n", call.=FALSE)
22 }
23
24 if (is.null(opt$out)){
25 print_help(opt_parser)
26 stop("At least one argument must be supplied (out file).\n", call.=FALSE)
27 }
28
29 mydata <- read.table(opt$file, header=TRUE,sep="\t",row.names="Gene")
30 #colmetadata <- read.table(opt$colmetadata,sep="\t")
31 #rowmetadata <- read.table(opt$rowmetadata,sep="\t")
32
33 #metadata_tooltips <- read.table(paste(opt$file,"metadata_tooltips.txt",sep = "."),sep="\t")
34
35 #mat <- metadata_tooltips
36 #mat <- mydata
37 #mat[] <- paste("\nCountry: ", rowmetadata[, 2], "\nContinent: ", rowmetadata[, 3], "\nCOG: ", colmetadata)
38
39 heatmaply(mydata,file = "heatmaply.html")
40
41
42 #heatmaply(
43 #t(mydata), file = opt$out,
44 #custom_hovertext = mat,
45 #col_side_colors = colmetadata[, 3],
46 #row_side_colors = rowmetadata[, 2:4],
47 #scale_fill_gradient_fun = ggplot2::scale_fill_gradient2(
48 # low = "white" , mid="#E7E4EA", high = "#471777", limits = c(0, 1))
49 #)