reptalex / phylofactor

26 stars 9 forks source link

summary of Phylofactor with method='max.var' throws error. #28

Closed SilasK closed 4 years ago

SilasK commented 4 years ago

Just to let you know that I get the following error.

It works when I use the PhyCA function.

pf= PhyloFactor(as.matrix(data),tree,method='max.var' )
summary(pf)
Error in paste("       phylofactor object from function ", PF$phylofactor.fcn,  : 
  cannot coerce type 'closure' to vector of type 'character'

I don't think the warnings are relevant:

1: In PhyloFactor(as.matrix(data), tree, method = "max.var", ncores = 4,  :
  some tips in tree are not found in dataset - output PF$tree will contain a trimmed tree
2: In PhyloFactor(as.matrix(data), tree, method = "max.var", ncores = 4,  :
  rows of data are in different order of tree tip-labels - use output$data for downstream analysis, or set Data <- Data[output$tree$tip.label,]
reptalex commented 4 years ago

Huh - that's weird, thanks for pointing it out!

Seems to be an issue with printing such objects. For an immediate fix, I think you can set pf$phylofactor.fcn <- PhyCA, and I'll work on debugging. Thanks!

reptalex commented 4 years ago

Fixed! Should work now with using PhyloFactor for method=max.var. The problem was in the print.phylofactor function - let me know if anything else pops up!

SilasK commented 4 years ago

Thank you, this was really fast. The summary works, however, I can't get the ilr values from the factor summary for phyca and phylofactor with method='max.var'

> FactorSummary=pf.summary(phyca,taxonomy,factor=1)
> FactorSummary$ilr
NULL
reptalex commented 4 years ago

I believe that is contained in FactorSummary$data$Data. Is there a tutorial/help file that suggests it's in .$ilr?

SilasK commented 4 years ago

For normal phylofactor this old tutorial recommend to use Factor summary$ilr

For pyca I haven't found much information in the tutorials. So I'm trying to find ways to plot phyca results.

Also in the helpf of ?PhyCa there is probably some small error, because it plots twice the same figure

pf.heatmap(tree=tree,Data=clr(Data))

phca <- PhyCA(Data,tree,ncomponents = 2)
phcaPAR <- PhyCA(Data,tree,ncomponents=2,ncores=2)

pf.heatmap(tree=tree,Data=clr(Data))
SilasK commented 4 years ago

When using max.var I don't get the FactorSumary$data attribute.

I only get $group1$otudata

reptalex commented 4 years ago

Ah!

try using the new function,

FactorSummary <- summary(pf,taxonomy,factor=1)

It has the .$data element, and also shows how various taxonomic groups (aggregated by their shortest unique taxonomic prefix distinguishing them from taxa in other the contrasted group) contribute to the signal. It has a nice print function, too, so you can just type

FactorSummary

and see a lot of info.

For more info, check out the new tutorial here

Also, thanks for finding that error in the ? PhyCA - I've pushed a fix that plots the pf.heatmap of the PhyCA object. Note - it didn't find the most obvious blocks. I've done some simulated annealing modifications (might find time to write that up eventually) that correctly capture those big blocks, but I think showing that the clades ID'd are correctly very different across sites, and better summaries than OTU lists, but not the perfect, minimal set of 2 clades to capture those blocks in the feces/tongue dataset.