',
+ '');
+ writeLines(html_output, htmlfile_handle);
+ close(htmlfile_handle);
+}
if(!is.null(options$biom)){
#physeq<-import_biom(options$biom)
physeq<-readBIOM(options$biom)
-
+
if(length(rank_names(physeq)) == 8){
- tax_table(physeq) <- tax_table(physeq)[,-1]
- colnames(tax_table(physeq)) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species")
+ tax_table(physeq) <- tax_table(physeq)[,-1]
+ colnames(tax_table(physeq)) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species")
+ } else {
+ colnames(tax_table(physeq)) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species")
}
+
### select column name from sample table for nmds plot
- category_type<-colnames(sample_data(physeq))[options$subset]
+ ## which(colnames(sample_data(biom)) == "vegetation_type_id")
+ #category_type<-colnames(sample_data(physeq))[options$subset]
+ category_type <- options$subset
### obtain the unique value in the selected column from sample table
category_option<-unique(sample_data(physeq))[,options$subset]
@@ -121,69 +212,46 @@
### select a kingdom for phyloseq plot (e.g., "phylum")
#kingdom_str<-colnames(tax_table)[options$kingdom]
#kingdom_str<-options$kingdom
-
-
- ### Remove OTUs that do not appear more than 5 times in more than half the samples
+
+
### filtering OTUs based on cutoff value (e.g., 5)
- physeq_temp =genefilter_sample(physeq, filterfun_sample(function(x) x > cutoff_value), A=0.1*nsamples(physeq))
-
+ #physeq_temp =genefilter_sample(physeq, filterfun_sample(function(x) x > cutoff_value), A=0.1*nsamples(physeq))
+ physeq_temp =genefilter_sample(physeq, filterfun_sample(function(x) x > cutoff_value), A=filter*nsamples(physeq))
+
### phyloseq object after filtered
physeq_filter = prune_taxa(physeq_temp, physeq)
-
+
## Transform to even sampling depth
physeq_filter = transform_sample_counts(physeq_filter, function(x) 1E6 * x/sum(x))
+
+
+if(plottype == 1){
+
+ # kingdom_str <- as.numeric(kingdom_str)
## Keep only the most abundant five phyla
- phylum.sum = tapply(taxa_sums(physeq_filter), tax_table(physeq_filter)[, kingdom_str], sum, na.rm=TRUE)
-
+
+ phylum.sum = tapply(taxa_sums(physeq_filter), tax_table(physeq_filter)[, kingdom_str], sum,na.rm=TRUE)
### number of most abundance phyla to keep
topphyla = names(sort(phylum.sum, TRUE))[1:keep]
+
physeq_filter = prune_taxa((tax_table(physeq_filter)[, kingdom_str] %in% topphyla), physeq_filter)
+}else{
+
+ otu_table(physeq_filter)<-otu_table(physeq_filter)[,colSums(otu_table(physeq_filter)) > 1]
+
+}
### select category to plot NMDS
category_input = get_variable(physeq_filter, category_type) %in% category_option
sample_data(physeq_filter)$category_input <- factor(category_input)
- ### prepare the directory and file name
- pdffile <- gsub("[ ]+", "", paste(options$outdir,"/pdffile.pdf"))
- pngfile_nmds <- gsub("[ ]+", "", paste(options$outdir,"/nmds.png"))
- pngfile_nmds_facet <- gsub("[ ]+", "", paste(options$outdir,"/nmds_facet.png"))
- htmlfile <- gsub("[ ]+", "", paste(options$htmlfile))
-
-
- # Produce PDF file
- pdf(pdffile);
physeq_ord<-ordinate(physeq_filter,method,distance)
- plot_ordination(physeq,physeq_ord,type="taxa",color="Phylum",title="taxa")
- plot_ordination(physeq,physeq_ord,type="taxa",color="Phylum",title="taxa") + facet_wrap(formula(paste('~',kingdom_str)),3)
- garbage<-dev.off();
-
-
- #png('nmds.png')
- bitmap(pngfile_nmds,"png16m")
- plot_ordination(physeq,physeq_ord,type="taxa",color="Phylum",title="taxa")
- garbage<-dev.off()
- #png('nmds_facet.png')
- bitmap(pngfile_nmds_facet,"png16m")
- plot_ordination(physeq,physeq_ord,type="taxa",color="Phylum",title="taxa") + facet_wrap(formula(paste('~',kingdom_str)),3)
- garbage<-dev.off()
+if(plottype == 1){
+ #kingdom_str = colnames(tax_table)[2]
+ create_OTU_PDF(pdffile,physeq_filter,physeq_ord,kingdom_str,htmlfile,pngfile_nmds,pngfile_nmds_facet)
+}else{
+ create_SAMPLE_PDF(pdffile,physeq_filter,physeq_ord,htmlfile,pngfile_nmds,category_type)
+}
- # Produce the HTML file
- htmlfile_handle <- file(htmlfile)
- html_output = c('',
- '
',
- '',
- '',
- '',
- '
',
- '
',
- '',
- '
',
- '
',
- '
',
- '');
- writeLines(html_output, htmlfile_handle);
- close(htmlfile_handle);
diff -r e376a618eb9f -r 20adf95eb758 phyloseq_nmds.xml
--- a/phyloseq_nmds.xml Sat Jun 16 05:03:43 2018 -0400
+++ b/phyloseq_nmds.xml Fri Jul 20 00:23:53 2018 -0400
@@ -6,7 +6,7 @@
ghostscript /dev/null | grep -v -i "WARNING: ")
+ echo $(R --version | grep version | grep -v GNU)", phyloseq version" $(R --vanilla --slave -e "library(phyloseq); cat(sessionInfo()\$otherPkgs\$phyloseq\$Version)" 2> /dev/null | grep -v -i "WARNING: ")
]]>
+ ]]>
+
+
-
+
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
@@ -68,20 +81,23 @@
-
-
+
+
+
+
-
+
+
-
-
+
+
@@ -99,7 +115,8 @@
-
**What it does**
Creates NMDS plot using R package called phyloseq_.
@@ -110,16 +127,16 @@
**Input**
- **Choose a file type** - BIOM File or TABULAR file
-- **Select a subset column from metadata table** - This column is used to extract unique value from the column of interest for NMDS plot
+- **Select a column** - This column is used to extract unique value from the column of interest for NMDS plot
- **OTU TABLE** - this is a OTU matrix
- **Taxonomy TABLE** - this is a TAX matrix
- **Metadata TABLE** - this is a metadata file of the experiment design
- **Select NMDS method** - select a method for NMDS plot
- **Select a distance for NMDS** - select a distance option for NMDS plot
- **Select a taxonomy rank** - select a taxonomy for NMDS plot
-- **cutoff value for filtering OTU table** - this cutoff value is used to fitler OTU table
-- **number of most abundant phyla** - a number of most abundant phyla to be display in NMDS plot
- ]]>
+- **Number of samples to keep** - Number of samples to keep for analysis
+- **Cutoff value for filtering OTU table** - this cutoff value is used to fitler OTU table
+- **Number of most abundant phyla** - a number of most abundant phyla to be display in NMDS plot
10.18129/B9.bioc.phyloseq