joey711/phyloseq — Issue #70: Update print/show methods to be more concise, useful
Author: joey711
Created: 2012-02-13 20:40:40+00:00
State: open
Labels: Feature

They are currently quite repetitive and verbose, to the point that print a phyloseq-class instance to screen is a little bit painful and pushes out your other recent commands

An example consolidated version of code for printing to screen that could potentially be used for the `show` method:

```R

################################################################################
# New phyloseq-class object summary to print/show to screen
################################################################################
special.print <- function(physeq){
cat("phyloseq-class experiment-level object", fill=TRUE)
# print otuTable (always there).
cat(paste("OTU Table: [", nspecies(otuTable(physeq)), " species and ",
nsamples(otuTable(physeq)), " samples]", sep = ""), fill = TRUE)
if( speciesAreRows(otuTable(physeq)) ){
cat(" species are rows", fill=TRUE)
} else {
cat(" species are columns", fill=TRUE)
}

# print sample Map if there
if(!is.null(sampleMap(physeq, FALSE))){
cat(paste("Sample Map: [", dim(sampleMap(physeq))[1], " samples by ",
dim(sampleMap(physeq))[2],
" sample variables]:", sep = ""), fill = TRUE)
}

# print tax Tab if there
if(!is.null(taxTab(physeq, FALSE))){
cat(paste("Taxonomy Table: [", dim(taxTab(physeq))[1], " species by ",
dim(taxTab(physeq))[2],
" taxonomic ranks]:", sep = ""), fill = TRUE)
}

# print tree if there
if(!is.null(tre(physeq, FALSE))){
cat(paste("Phylogenetic Tree: [", nspecies(tre(physeq)), " tips and ",
tre(physeq)$Nnode,
" internal nodes]", sep = ""),
fill = TRUE
)
if( is.rooted(tre(physeq)) ){
cat(" rooted", fill=TRUE)
} else {
cat(" unrooted", fill=TRUE)
}
}
}
################################################################################
```