pf.predict: Predicts based on phylofactorization

View source: R/pf.predict.R

pf.predictR Documentation

Predicts based on phylofactorization

Description

Predicts based on phylofactorization

Usage

pf.predict(PF, factors = NULL, ...)

Arguments

PF

PhyloFactor object

factors

Set of factors to be used for prediction. Currently, must be a continuous integer sequence from 1:nfactors

...

optional input arguments for predict

Value

estimated data based on estimates from phylofactorization

Examples

library(caper)
set.seed(1)
tree <- unroot(rtree(8))
Data <- matrix(rlnorm(80),nrow=8)
rownames(Data) <- tree$tip.label
Grp <- clade.members.list(tree)$'12'
for (gg in Grp){
Data[gg,] <- Data[gg,]*20^(seq(-1,1,length.out=10))
}

X <- 1:10
colnames(Data) <- X

Data <- clo(Data)
rownames(Data) <- tree$tip.label

PF <- PhyloFactor(Data,tree,X,nfactors=1)

CommunityEst <- pf.predict(PF,factors=1,newdata=data.frame(X=seq(0,11,by=1/3)))
rownames(CommunityEst) <- rownames(Data)

clr <- function(A) apply(A,MARGIN=2,FUN=function(a) log(a)-mean(log(a)))
pf.heatmap(tree=tree,Data=clr(Data))
pf.heatmap(tree=tree,Data=clr(CommunityEst))

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