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