Mercurial > repos > qfabrepo > metadegalaxy_phyloseq_richness
comparison phyloseq_richness.r @ 0:0ab4501d805b draft
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
author | qfabrepo |
---|---|
date | Mon, 14 Sep 2020 07:38:57 +0000 |
parents | |
children | e0225f3e8ef6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0ab4501d805b |
---|---|
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 'outdir','o',2,'character', | |
12 'htmlfile','h',2,'character' | |
13 ),byrow=TRUE,ncol=4); | |
14 | |
15 | |
16 options <- getopt(option_specification); | |
17 options(bitmapType="cairo") | |
18 | |
19 | |
20 if (!is.null(options$outdir)) { | |
21 # Create the directory | |
22 dir.create(options$outdir,FALSE) | |
23 } | |
24 | |
25 | |
26 galaxy_biom <- import_biom(options$biomfile) | |
27 galaxy_map <- import_qiime_sample_data(options$metafile) | |
28 tax_col_norm <- c("Kingdom","Phylum","Class","Order","Family","Genus","Species") | |
29 tax_col_extra <- c("None","Kingdom","Phylum","Class","Order","Family","Genus","Species") | |
30 | |
31 number.of.tax.rank<-length(colnames(tax_table(galaxy_biom))) | |
32 | |
33 if( number.of.tax.rank == 7){ | |
34 colnames(tax_table(galaxy_biom)) <- tax_col_norm | |
35 }else{ | |
36 colnames(tax_table(galaxy_biom)) <- tax_col_extra | |
37 } | |
38 | |
39 | |
40 AIP_galaxy <- merge_phyloseq(galaxy_biom,galaxy_map) | |
41 | |
42 | |
43 x.selectedColumn<-colnames(galaxy_map)[options$xcolumn] | |
44 l.selectedColumn<-colnames(galaxy_map)[options$lcolumn] | |
45 | |
46 | |
47 | |
48 | |
49 pdffile <- gsub("[ ]+", "", paste(options$outdir,"/pdffile.pdf")) | |
50 pngfile_richness <- gsub("[ ]+", "", paste(options$outdir,"/richness.png")) | |
51 htmlfile <- gsub("[ ]+", "", paste(options$htmlfile)) | |
52 | |
53 | |
54 # Produce PDF file | |
55 pdf(pdffile); | |
56 plot_richness(AIP_galaxy,measures=c("Observed"),color=l.selectedColumn,x=x.selectedColumn) | |
57 garbage<-dev.off(); | |
58 | |
59 #png('richness.png') | |
60 bitmap(pngfile_richness,"png16m") | |
61 plot_richness(AIP_galaxy,measures=c("Observed"),color=l.selectedColumn,x=x.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="pdffile.pdf"><img src="richness.png"/></a>', | |
71 '</td>', | |
72 '</tr>', | |
73 '</table>', | |
74 '<table align="center>', | |
75 '<tr>', | |
76 '<td valign="middle" style="vertical-align:middle;">', | |
77 '<a href="pdffile.pdf"><img src="richness.png"/></a>', | |
78 '</td>', | |
79 '</tr>', | |
80 '</table>', | |
81 '</html></body>'); | |
82 writeLines(html_output, htmlfile_handle); | |
83 close(htmlfile_handle); |