Mercurial > repos > qfabrepo > metadegalaxy_phyloseq_net
annotate phyloseq_net.r @ 1:22abc415e142 draft default tip
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit dd99d48abe2b118e0ff59ad36da4b641b83037ff"
author | qfabrepo |
---|---|
date | Wed, 16 Sep 2020 05:42:51 +0000 |
parents | af6d9ad14a0f |
children |
rev | line source |
---|---|
0
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
1 library('getopt') |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
2 library('data.table') |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
3 suppressPackageStartupMessages(library('phyloseq')) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
4 suppressPackageStartupMessages(library('DESeq2')) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
5 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
6 Sys.setenv("DISPLAY"=":1") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
7 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
8 options(warn= -1) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
9 option_specification = matrix(c( |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
10 'infile','i',2,'character', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
11 'metafile','m',2,'character', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
12 'biom','b',2,'character', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
13 'obsfile','o',2,'character', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
14 'norm','n',2,'logical', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
15 'xcolumn','x',2,'numeric', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
16 'lcolumn','l',2,'numeric', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
17 'outdir','d',2,'character', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
18 'htmlfile','h',2,'character' |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
19 ),byrow=TRUE,ncol=4); |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
20 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
21 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
22 options <- getopt(option_specification) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
23 options(bitmapType="cairo") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
24 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
25 matrix.format<-function(x) { |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
26 m<-as.matrix(x[,-1]) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
27 rownames(m)<-x[,1] |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
28 m |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
29 } |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
30 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
31 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
32 gm_mean = function(x, na.rm=TRUE){ exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x))} |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
33 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
34 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
35 tax_col_norm <- c("Kingdom","Phylum","Class","Order","Family","Genus","Species") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
36 tax_col_extra <- c("None","Kingdom","Phylum","Class","Order","Family","Genus","Species") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
37 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
38 tax_col_norm_otu <- c("OTUID","Kingdom","Phylum","Class","Order","Family","Genus","Species") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
39 tax_col_extra_otu <- c("OTUID","None","Kingdom","Phylum","Class","Order","Family","Genus","Species") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
40 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
41 if (!is.null(options$outdir)) { |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
42 # Create the directory |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
43 dir.create(options$outdir,FALSE) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
44 } |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
45 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
46 is.biom<-options$biom |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
47 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
48 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
49 pdffile <- gsub("[ ]+", "", paste(options$outdir,"/pdffile.pdf")) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
50 pngfile_net <- gsub("[ ]+", "", paste(options$outdir,"/net.png")) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
51 htmlfile <- gsub("[ ]+", "", paste(options$htmlfile)) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
52 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
53 if(is.biom=="set_biom"){ |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
54 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
55 galaxy_biom <- import_biom(options$infile) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
56 galaxy_map <- import_qiime_sample_data(options$metafile) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
57 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
58 number.of.tax.rank<-length(colnames(tax_table(galaxy_biom))) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
59 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
60 if(number.of.tax.rank == 7){ |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
61 colnames(tax_table(galaxy_biom)) <- tax_col_norm |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
62 } else { |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
63 colnames(tax_table(galaxy_biom)) <- tax_col_extra |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
64 } |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
65 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
66 physeq_galaxy <- merge_phyloseq(galaxy_biom,galaxy_map) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
67 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
68 } else { |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
69 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
70 count.table<-read.table(options$infile,header=T,sep="\t",comment.char="",stringsAsFactors = F) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
71 meta.table<-read.table(options$metafile,header=T,sep="\t",comment.char="",stringsAsFactors = F) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
72 tax.table<-read.table(options$obsfile,header=T,sep="\t",comment.char="",stringsAsFactors = F) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
73 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
74 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
75 colnames(count.table)<-gsub("^X","",colnames(count.table)) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
76 colnames(meta.table)<-gsub("^X.","",colnames(meta.table)) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
77 colnames(tax.table)<-gsub("^X.","",colnames(tax.table)) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
78 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
79 count.table.formatted<-matrix.format(count.table) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
80 OTU<-otu_table(count.table.formatted,taxa_are_rows = TRUE) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
81 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
82 tax.table.new<-as.data.frame(cbind(tax.table[,1],t(as.data.table(strsplit(tax.table[,2],";"))))) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
83 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
84 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
85 if(length(colnames(tax.table.new)) != length(tax_col_extra_otu)){ |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
86 colnames(tax.table.new)<-tax_col_norm_otu |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
87 }else{ |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
88 colnames(tax.table.new)<-tax_col_extra_otu |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
89 } |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
90 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
91 tax.table.formatted<-matrix.format(tax.table.new) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
92 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
93 TAX<-tax_table(tax.table.formatted) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
94 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
95 physeq_galaxy <- phyloseq(OTU, TAX) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
96 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
97 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
98 galaxy_map<-meta.table |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
99 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
100 rownames(galaxy_map)<-meta.table[,1] |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
101 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
102 sampledata<-sample_data(as.data.frame(galaxy_map,row.names=sample_names(galaxy_map),stringsAsFactos=F)) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
103 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
104 sample_data(physeq_galaxy)<-sampledata |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
105 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
106 } |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
107 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
108 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
109 x.selectedColumn<-colnames(galaxy_map)[options$xcolumn] |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
110 l.selectedColumn<-colnames(galaxy_map)[options$lcolumn] |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
111 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
112 ### normalisation |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
113 if(is.null(options$norm) || options$norm =="false"){ |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
114 suppressMessages(raw.count.deseq2.obj<-phyloseq_to_deseq2(physeq_galaxy,as.formula(paste('~',x.selectedColumn,sep="")))) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
115 geoMeans = apply(counts(raw.count.deseq2.obj), 1, gm_mean) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
116 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
117 deseq.obj = estimateSizeFactors(raw.count.deseq2.obj, geoMeans = geoMeans) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
118 deseq.obj.norm<-otu_table(as.matrix(counts(deseq.obj,normalized=T)),taxa_are_rows=TRUE) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
119 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
120 otu_table(physeq_galaxy)<-deseq.obj.norm |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
121 } |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
122 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
123 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
124 # Produce PDF file |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
125 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
126 pdf(pdffile); |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
127 plot_net(physeq_galaxy,point_label=x.selectedColumn,color=l.selectedColumn) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
128 garbage<-dev.off(); |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
129 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
130 #Cairo(pngfile_net, type="png", bg="white",pointsize=12,dpi=100,units="in",width=6,height=6) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
131 png(pngfile_net,units="in",width=6,height=6,pointsize=12,res=100,bg="white") |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
132 plot_net(physeq_galaxy,point_label=x.selectedColumn,color=l.selectedColumn) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
133 garbage<-dev.off() |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
134 |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
135 # Produce the HTML file |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
136 htmlfile_handle <- file(htmlfile) |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
137 html_output = c('<html><body>', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
138 '<table align="center">', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
139 '<tr>', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
140 '<td valign="middle" style="vertical-align:middle;">', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
141 '<a href="pdffile.pdf"><img src="net.png"/></a>', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
142 '</td>', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
143 '</tr>', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
144 '</table>', |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
145 '</html></body>'); |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
146 writeLines(html_output, htmlfile_handle); |
af6d9ad14a0f
"planemo upload for repository https://github.com/QFAB-Bioinformatics/metaDEGalaxy/tree/master/phyloseq_net commit 8bd68662b72404f6291e9628327dcb109b5fa55e"
qfabrepo
parents:
diff
changeset
|
147 close(htmlfile_handle); |