-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgeneral_report.r
executable file
·55 lines (41 loc) · 1.76 KB
/
general_report.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env Rscript
usage = "\
Rscript general_report.r [\"all pdf files in wildcard\"] [\"all groups in wildcard\"]
"
date()
args <- commandArgs(trailingOnly = TRUE)
if (length(args)!=2) { write(usage,stderr()); quit(save='no'); }
suppressPackageStartupMessages(library(hwriter))
suppressPackageStartupMessages(library(ReportingTools))
suppressPackageStartupMessages(library(tools))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tidyr))
sessionInfo()
filelist=Sys.glob(args[1])
group_list=data.frame(read.table(args[2],header=T,sep="\t"))
cat("\n\n#### Start Genrating Report......\n")
htmlRep <- HTMLReport(shortName = "lncRNA_report", title="lncRNA Standard Report", reportDirectory = "./")
dir.create("figures",recursive=T,showWarnings=F)
for(i in 1:length(filelist)){
system(paste0("cp ",file_path_sans_ext(filelist[i]),"{.png,.pdf} figures/"))
cat(paste0(filelist[i],"\n"))
himg <- hwriteImage(paste0("figures/",file_path_sans_ext(basename(filelist[i])),".png"),link=paste0("figures/",file_path_sans_ext(basename(filelist[i])),".pdf"))
publish(toupper(gsub("_"," ",file_path_sans_ext(basename(filelist[i])))), htmlRep)
publish(hwrite(himg, br=TRUE), htmlRep,name=file_path_sans_ext(basename(filelist[i])))
}
publish(" ", htmlRep)
publish(" ", htmlRep)
publish(" ", htmlRep)
publish(" ", htmlRep)
publish(" ", htmlRep)
publish(" ", htmlRep)
publish(" Report for each grouping level", htmlRep)
for(i in 2:length(colnames(group_list))){
cat(paste0(colnames(group_list)[i],"\n"))
publish(hwrite(colnames(group_list)[i],link=paste0(colnames(group_list)[i],"/report.html")), htmlRep)
}
publish(group_list,htmlRep)
cat("Sucess: ")
finish(htmlRep)
cat("#### Done\n")
date()