# HG changeset patch # User simon-gladman # Date 1542080534 18000 # Node ID 9fbb104e16d92a5fe41b1240a0d800884cca4bd9 # Parent 910739de7b8088a64eeb7dea6fe922d343bd91ba update diff -r 910739de7b80 -r 9fbb104e16d9 phyloseq_filter.R --- a/phyloseq_filter.R Wed Sep 05 22:21:43 2018 -0400 +++ b/phyloseq_filter.R Mon Nov 12 22:42:14 2018 -0500 @@ -2,10 +2,10 @@ library('ape') library('ggplot2') suppressPackageStartupMessages(library('phyloseq')) -library(biomformat) library(plyr) Sys.setenv("DISPLAY"=":1") library(biomformat) +library(jsonlite) suppressPackageStartupMessages(library(metagenomeSeq)) suppressPackageStartupMessages(library("doParallel")) ncores = ceiling(detectCores() * 0.8) @@ -65,6 +65,12 @@ pngfile_post_phyla_filtering<- gsub("[ ]+", "", paste(options$outdir,"/barplot_after_phyla_filtering.png")) htmlfile <- gsub("[ ]+", "", paste(options$htmlfile)) +### overwrite the write_biom function for proper BIOM format +### https://github.com/smdabdoub/biomformat/blob/master/R/IO-methods.R#L124 +write_biom <- function(x, biom_file){ + cat(toJSON(x, always_decimal=TRUE, auto_unbox=TRUE), file=biom_file) +} + ### This function accepts different two different type of BIOM file format readBIOM<-function(inBiom){ tryCatch({ @@ -152,7 +158,7 @@ #png('barplot_pre_phyla_filtering.png') bitmap(pngfile_pre_phyla_filtering,"png16m") - print(sample_data(physeq_pre_phyla_filtering)) + #print(sample_data(physeq_pre_phyla_filtering)) barplot_pre_phyla_filtering<-plot_bar(physeq_pre_phyla_filtering, x=colnames(sample_data(physeq_pre_phyla_filtering))[1], fill=kingdom_str) + geom_bar(stat="identity", position="stack") + labs(title=paste("Sample Depth Bar Chart",kingdom_str,sep=":"),subtitle="Sample Vs Abundance (Pre Phyla Filtering)",caption="source: Input Biom") + @@ -181,7 +187,7 @@ create_HTML<-function(htmlfile){ htmlfile_handle <- file(htmlfile) html_output = c('
', - '',
' ',
@@ -203,7 +209,7 @@
' | ',
'