pf.nullsim: Null Simulation of phylofactor object

View source: R/pf.nullsim.R

pf.nullsimR Documentation

Null Simulation of phylofactor object

Description

Null Simulation of phylofactor object

Usage

pf.nullsim(PF, reps, nfactors = NULL, seed = NULL, nullsimFcn = NULL,
  output = "ExpVar", col.shuffle = T, row.shuffle = T, ...)

Arguments

PF

class phylofactor object from PhyloFactor

reps

number of replicate null simulations

nfactors

number of factors to run for null simulation

seed

optional seed for set.seed

nullsimFcn

Either NULL, the string "shuffle", or a function taking class "phylofactor" object and producing null dataset. Default for twoSampleFactor output is to resample data with replacement. If "shuffle" will shuffle rows and columns of PF$Data. Default otherwise is to simulate standard Gaussian null data.

output

output to return from each simulation. Must be in names(PF) or c('ExpVar','F','All'). If 'All', will output phylofactor object from each sim (may be memory intensive)

col.shuffle

Logical. Whether or not to shuffle the columns of data. Only used if nullsimFcn=='shuffle'

row.shuffle

Logical. Whether or not to shuffle the rows of data. Only used if nullsimFcn=='shuffle'

...

optional arguments to PhyloFactor or twoSampleFactor

Examples

library(ape)
library(phylofactor)
set.seed(1)
m=7
n=10
tree <- rtree(m)
X <- rnorm(n)
Data <- rlnorm(m*n) %>% matrix(.,nrow=m)
rownames(Data) <- tree$tip.label
clade <- c('t1','t3','t6')
for (tip in clade){ Data[tip,] <- Data[tip,]*exp(8*X) }
PF <- PhyloFactor(Data,tree,X,nfactors=4)

#nullsim <- phylofactor:::pf.nullsim(PF,10,nfactors=4)

#plot(PF$ExplainedVar,type='l')
#for (nn in 1:10){lines(nullsim[[nn]],col='grey')}
#legend('center',c('Original Data','Null Data'),col=c('black','gray'),lty=c(1,1))

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