Mercurial > repos > mingchen0919 > rmarkdown_mirdeep2
comparison mirdeep2.Rmd @ 0:963905bcb754 draft
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_mirdeep2 commit 29e8b40899c71ca12fd07b2bb530b0ee65037588-dirty
author | mingchen0919 |
---|---|
date | Tue, 08 Aug 2017 13:14:41 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:963905bcb754 |
---|---|
1 --- | |
2 title: 'Mirdeep2' | |
3 output: | |
4 html_document: | |
5 number_sections: true | |
6 toc: true | |
7 theme: cosmo | |
8 highlight: tango | |
9 --- | |
10 | |
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE} | |
12 knitr::opts_chunk$set( | |
13 echo = ECHO | |
14 ) | |
15 ``` | |
16 | |
17 # Job command line | |
18 | |
19 ```{r 'build PATH', echo=FALSE} | |
20 # set PATH environment. | |
21 PATH = system('pwd', intern = TRUE) %>% | |
22 (function(x) { | |
23 paste0('/home/galaxy/mirdeep2/bin:', x) | |
24 }) %>% | |
25 (function(x) { | |
26 paste0('/home/galaxy/mirdeep2_patch:', x) | |
27 }) %>% | |
28 paste0(':$PATH') | |
29 ``` | |
30 | |
31 ## Build job command line. | |
32 | |
33 ```{r 'build command line'} | |
34 # change directory to OUTPUT DIR | |
35 command_line = paste0('cd OUTPUT_DIR &&') %>% | |
36 # PATH and other environment variables | |
37 paste0('export PATH=', PATH, ' && ') %>% | |
38 (function(x) { | |
39 paste0(x, 'export PERL_MB_OPT="--install_base /home/galaxy/perl5" && | |
40 export PERL_MM_OPT="INSTALL_BASE=/home/galaxy/perl5" && | |
41 export PERL5LIB=/home/galaxy/mirdeep2/lib/perl5 && ') | |
42 }) %>% | |
43 # link collapsed reads and reads mapping files | |
44 (function(x) { | |
45 paste0(x, 'ln -s COLLAPSED_READS reads_collapsed.fa && ') | |
46 }) %>% | |
47 (function(x) { | |
48 paste0(x, 'ln -s READS_MAPPING reads_collapsed_vs_genome.arf && ') | |
49 }) %>% | |
50 paste0(' miRDeep2.pl ') %>% | |
51 # collapsed reads | |
52 (function(x) { | |
53 paste0(x, ' reads_collapsed.fa ') | |
54 }) %>% | |
55 # reference genome | |
56 (function(x) { | |
57 paste0(x, ' REFERENCE_GENOME ') | |
58 }) %>% | |
59 # reads mapping | |
60 (function(x) { | |
61 paste0(x, ' reads_collapsed_vs_genome.arf ') | |
62 }) %>% | |
63 # mature miRNA for this species | |
64 (function(x) { | |
65 if('SPECIES_MATURE_MIRNA' == 'None') { | |
66 paste0(x, tolower('SPECIES_MATURE_MIRNA'), ' ') | |
67 } else { | |
68 paste0(x, ' SPECIES_MATURE_MIRNA ') | |
69 } | |
70 }) %>% | |
71 # mature miRNA from related species | |
72 (function(x) { | |
73 if('SPECIES_RELATED_MATURE_MIRNA' == 'None') { | |
74 paste0(x, tolower('SPECIES_RELATED_MATURE_MIRNA'), ' ') | |
75 } else { | |
76 paste0(x, 'SPECIES_RELATED_MATURE_MIRNA ') | |
77 } | |
78 }) %>% | |
79 # precursor sequences | |
80 (function(x) { | |
81 if('PRECURSOR_SEQUENCES' == 'None') { | |
82 paste0(x, tolower('PRECURSOR_SEQUENCES'), ' ') | |
83 } else { | |
84 paste0(x, 'PRECURSOR_SEQUENCES ') | |
85 } | |
86 }) %>% | |
87 # min read stack height | |
88 (function(x) { | |
89 ifelse('MIN_READ_STACK_HEIGHT' == 'TRUE', x, paste0(x, ' -a MIN_READ_STACK_HEIGHT ')) | |
90 }) %>% | |
91 # min score cutoff | |
92 (function(x) { | |
93 paste0(x, '-b MIN_SCORE_CUTOFF ') | |
94 }) %>% | |
95 # disable randfold analysis | |
96 (function(x) { | |
97 ifelse(RANDFOLD_ANALYSIS, paste0(x, '-c '), x) | |
98 }) %>% | |
99 # max precursors number | |
100 (function(x) { | |
101 paste0(x, ' -g MAX_PRECURSOR_NUMBER ') | |
102 }) %>% | |
103 # species | |
104 (function(x) { | |
105 ifelse('SPECIES' == 'all', x, paste0(x, ' -t SPECIES ')) | |
106 }) %>% | |
107 # switch | |
108 (function(x) { | |
109 ifelse(SWITCH, x, paste0(x, ' -P ')) | |
110 }) %>% | |
111 # write stdout to reprot.log | |
112 (function(x) { | |
113 paste0(x, ' >report.log 2>&1 ') | |
114 }) | |
115 | |
116 command_line | |
117 | |
118 ## run job | |
119 system(command_line) | |
120 ``` | |
121 | |
122 ## Results | |
123 | |
124 ```{r echo=TRUE} | |
125 system('cp OUTPUT_DIR/result*.html result.html') | |
126 system('cp OUTPUT_DIR/result*.csv result.csv') | |
127 system('cp OUTPUT_DIR/report.log report.log') | |
128 system('mv OUTPUT_DIR/pdfs_* OUTPUT_DIR/pdfs') | |
129 | |
130 ## check if OUTPUT DIR has results that we want. | |
131 system('ls OUTPUT_DIR', intern = TRUE) | |
132 ``` | |
133 | |
134 ### PDF files | |
135 | |
136 ```{r echo=TRUE} | |
137 pdf_report_list = list() | |
138 pdf_files = list.files('OUTPUT_DIR/pdfs', pattern = '.*pdf') | |
139 pdf_files | |
140 for (i in pdf_files) { | |
141 # note that the root directory is OUTPUT_DIR, all the file links should be a relative path to the root directory! | |
142 pdf_report_list[[i]] = tags$li(tags$a(href=paste0('pdfs/', i), i)) | |
143 } | |
144 tags$ul(pdf_report_list) | |
145 ``` | |
146 |