pf.summary: Summary of pf object for a given node or factor number

View source: R/pf.summary.R

pf.summaryR Documentation

Summary of pf object for a given node or factor number

Description

Summary of pf object for a given node or factor number

Usage

pf.summary(PF, taxonomy, factor = NULL, minimum.level = Inf)

Arguments

PF

PhyloFactor object

taxonomy

Taxonomy, first column is OTU ids in tree, second column is greengenes taxonomic string

factor

Factor number to summarize.

minimum.level

Integer. Lowest taxonomic level (high: kingdom, low: subspecies) to used to summarize species.

Value

summary object. List containing $group and $complement info, each containing summary.group output for that group - $IDs, $otuData and $PF.prediction

Examples

data("FTmicrobiome")
OTUTable <- FTmicrobiome$OTUTable        #OTU table
Taxonomy <- FTmicrobiome$taxonomy        #taxonomy
tree <- FTmicrobiome$tree                #tree
X <- FTmicrobiome$X                      
#independent variable - factor indicating if sample is from feces or tongue

rm('FTmicrobiome')

# remove rare taxa
ix <- which(rowSums(OTUTable==0)<30)
OTUTable <- OTUTable[ix,]
OTUs <- rownames(OTUTable)
tree <- drop.tip(tree,which(!(tree$tip.label %in% OTUs)))

par(mfrow=c(1,1))
clr <- function(A) apply(A,MARGIN=2,FUN=function(a) log(a)-mean(log(a)))
OTUTable[OTUTable==0]=0.65
pf.heatmap(tree=tree,Data=clr(OTUTable))

PF <- PhyloFactor(OTUTable,tree,X,nfactors=2,ncores=2,choice='var')

FactorSummary <- pf.summary(PF,Taxonomy,factor=1)

str(FactorSummary)

par(mfrow=c(1,2))
plot(FactorSummary$ilr,ylab='ILR coordinate',main='ILR coordinate of factor',
      xlab='sample no.',pch=16)
lines(FactorSummary$fitted.values,lwd=2,col='blue')
legend(x=1,y=-5,list('data','prediction'),pch=c(16,NA),lty=c(NA,1),
        col=c('black','blue'),lwd=c(NA,2))

plot(FactorSummary$MeanRatio,ylab='ILR coordinate',main='Mean Ratio of Grp1/Grp2',
       xlab='sample no.',pch=16)
lines(FactorSummary$fittedMeanRatio,lwd=2,col='blue')
legend(x=1,y=-5,list('data','prediction'),pch=c(16,NA),lty=c(NA,1),
        col=c('black','blue'),lwd=c(NA,2))

reptalex/phylofactor documentation built on Feb. 28, 2024, 3:19 p.m.