comparison phyloseq_abundance_taxonomy.r @ 0:b2fafdd3533d draft default tip

"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_abundance_taxonomy commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
author qfabrepo
date Mon, 14 Sep 2020 08:07:43 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b2fafdd3533d
1 library('getopt')
2 suppressPackageStartupMessages(library('phyloseq'))
3 Sys.setenv("DISPLAY"=":1")
4
5 options(warn=-1)
6 option_specification = matrix(c(
7 'biomfile','b',2,'character',
8 'metafile','m',2,'character',
9 'xcolumn','x',2,'numeric',
10 'lcolumn','l',2,'numeric',
11 'taxonomy','t',2,'character',
12 'outdir','o',2,'character',
13 'htmlfile','h',2,'character'
14 ),byrow=TRUE,ncol=4);
15
16
17 options <- getopt(option_specification);
18 options(bitmapType="cairo")
19
20
21 if (!is.null(options$outdir)) {
22 # Create the directory
23 dir.create(options$outdir,FALSE)
24 }
25
26
27 galaxy_biom <- import_biom(options$biomfile)
28 galaxy_map <- import_qiime_sample_data(options$metafile)
29 tax_col_norm <- c("Kingdom","Phylum","Class","Order","Family","Genus","Species")
30 tax_col_extra <- c("None","Kingdom","Phylum","Class","Order","Family","Genus","Species")
31
32 number.of.tax.rank<-length(colnames(tax_table(galaxy_biom)))
33
34 if( number.of.tax.rank == 7){
35 colnames(tax_table(galaxy_biom)) <- tax_col_norm
36 }else{
37 colnames(tax_table(galaxy_biom)) <- tax_col_extra
38 }
39
40
41 AIP_galaxy <- merge_phyloseq(galaxy_biom,galaxy_map)
42
43
44 x.selectedColumn<-colnames(galaxy_map)[options$xcolumn]
45 l.selectedColumn<-colnames(galaxy_map)[options$lcolumn]
46
47 tax.selected<-options$taxonomy
48
49 pdffile <- gsub("[ ]+", "", paste(options$outdir,"/kingdom.pdf"))
50 pngfile_kingdom <- gsub("[ ]+", "", paste(options$outdir,"/kingdom.png"))
51 htmlfile <- gsub("[ ]+", "", paste(options$htmlfile))
52
53
54 # Produce PDF file
55 pdf(pdffile);
56 plot_bar(AIP_galaxy,x=x.selectedColumn,facet_grid = paste('~', tax.selected),fill=l.selectedColumn)
57 garbage<-dev.off();
58
59 #png('kingdom.png')
60 bitmap(pngfile_kingdom,"png16m")
61 plot_bar(AIP_galaxy,x=x.selectedColumn,facet_grid = paste('~', tax.selected),fill=l.selectedColumn)
62 garbage<-dev.off()
63
64 # Produce the HTML file
65 htmlfile_handle <- file(htmlfile)
66 html_output = c('<html><body>',
67 '<table align="center">',
68 '<tr>',
69 '<td valign="middle" style="vertical-align:middle;">',
70 '<a href="kingdom.pdf"><img src="kingdom.png"/></a>',
71 '</td>',
72 '</tr>',
73 '</table>',
74 '</html></body>');
75 writeLines(html_output, htmlfile_handle);
76 close(htmlfile_handle);