annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
1 library('getopt')
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
2 suppressPackageStartupMessages(library('phyloseq'))
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
3 Sys.setenv("DISPLAY"=":1")
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
4
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
5 options(warn=-1)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
6 option_specification = matrix(c(
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
7 'biomfile','b',2,'character',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
8 'metafile','m',2,'character',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
9 'xcolumn','x',2,'numeric',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
10 'lcolumn','l',2,'numeric',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
11 'outdir','o',2,'character',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
12 'htmlfile','h',2,'character'
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
13 ),byrow=TRUE,ncol=4);
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
14
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
15
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
16 options <- getopt(option_specification);
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
17 options(bitmapType="cairo")
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
18
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
19
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
20 if (!is.null(options$outdir)) {
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
21 # Create the directory
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
22 dir.create(options$outdir,FALSE)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
23 }
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
24
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
25
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
26 galaxy_biom <- import_biom(options$biomfile)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
27 galaxy_map <- import_qiime_sample_data(options$metafile)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
28 tax_col_norm <- c("Kingdom","Phylum","Class","Order","Family","Genus","Species")
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
29 tax_col_extra <- c("None","Kingdom","Phylum","Class","Order","Family","Genus","Species")
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
30
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
31 number.of.tax.rank<-length(colnames(tax_table(galaxy_biom)))
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
32
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
33 if( number.of.tax.rank == 7){
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
34 colnames(tax_table(galaxy_biom)) <- tax_col_norm
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
35 }else{
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
36 colnames(tax_table(galaxy_biom)) <- tax_col_extra
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
37 }
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
38
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
39
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
40 AIP_galaxy <- merge_phyloseq(galaxy_biom,galaxy_map)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
41
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
42
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
43 x.selectedColumn<-colnames(galaxy_map)[options$xcolumn]
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
44 l.selectedColumn<-colnames(galaxy_map)[options$lcolumn]
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
45
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
46
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
47
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
48
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
49 pdffile <- gsub("[ ]+", "", paste(options$outdir,"/pdffile.pdf"))
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
50 pngfile_richness <- gsub("[ ]+", "", paste(options$outdir,"/richness.png"))
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
51 htmlfile <- gsub("[ ]+", "", paste(options$htmlfile))
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
52
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
53
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
54 # Produce PDF file
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
55 pdf(pdffile);
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
56 plot_richness(AIP_galaxy,measures=c("Observed"),color=l.selectedColumn,x=x.selectedColumn)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
57 garbage<-dev.off();
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
58
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
59 #png('richness.png')
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
60 bitmap(pngfile_richness,"png16m")
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
61 plot_richness(AIP_galaxy,measures=c("Observed"),color=l.selectedColumn,x=x.selectedColumn)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
62 garbage<-dev.off()
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
63
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
64 # Produce the HTML file
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
65 htmlfile_handle <- file(htmlfile)
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
66 html_output = c('<html><body>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
67 '<table align="center">',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
68 '<tr>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
69 '<td valign="middle" style="vertical-align:middle;">',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
70 '<a href="pdffile.pdf"><img src="richness.png"/></a>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
71 '</td>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
72 '</tr>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
73 '</table>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
74 '<table align="center>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
75 '<tr>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
76 '<td valign="middle" style="vertical-align:middle;">',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
77 '<a href="pdffile.pdf"><img src="richness.png"/></a>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
78 '</td>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
79 '</tr>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
80 '</table>',
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
81 '</html></body>');
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
82 writeLines(html_output, htmlfile_handle);
0ab4501d805b "planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_richness commit a8245efa0d80103939285565948beaf8dfb88a73"
qfabrepo
parents:
diff changeset
83 close(htmlfile_handle);