reptalex / phylofactor

26 stars 9 forks source link

log-ratios are negative #25

Closed Jigyasa3 closed 4 years ago

Jigyasa3 commented 4 years ago

Hey @reptalex

I am comparing the log-ratios of two genes from metagenomes. And I have some values that are negative as gene in the denominator can be more abundant than the one in the numerator.

When I run these log-ratios in PhyloFactor glm analysis, I get an error-

my code-

pf_PhyloFactor<-PhyloFactor(wood1$Current_Log_Ratio,pruned.trees_diet_continuous,wood1$N15,frmla = Data~N15,nfactors=2,choice = "F")

error-

some tips in tree are not found in dataset - output PF$tree will contain a trimmed treedrop all tips of the tree: returning NULLError in PhyloFactor(wood1$Current_Log_Ratio, pruned.trees_diet_continuous, : For log-transformed data analysis, all entries of Data must be greater than or equal to 0

Is there a way around it? Log-ratios between gene families can be positive or negative. That's not sequencing artifact.

reptalex commented 4 years ago

Set transform.fcn=I

Also, check the tutorial - the default transform.fcn=log, thus it log-transforms your input Data prior to projection onto contrast basis elements. If you've already log-transformed your data (whether or not they're centered log ratios), then taking the log again will be troublesome.

Best, Alex

Jigyasa3 commented 4 years ago

Hey @reptalex

Thanks for replying! I have made the change you suggested. But I am running into the error. I can't find anything about it on the help page and tutorial. The tutorial I am following- https://docs.wixstatic.com/ugd/0119a1_099ae20df8424af9a38585dcebc0d45a.pdf. There is also no information about "transform.fcn=I" specifically except for in the "Amalgamation" contrast function.

As I am following the tutorial for metagenome analysis, the log-ratios I have are from gene families, not OTU abundance.

my data-

head(wood1) Current_Log_Ratio\tN15 sample1\t1.5\t2 sample2\t-1\t2.4 sample3\t0.0\t1

my code-

pf_PhyloFactor<-PhyloFactor(wood1$Current_Log_Ratio,pruned.trees,wood1$N15,transform.fcn=I,frmla = Data~N15,nfactors=2,choice = "F",method="glm")

Error- Error in UseMethod("is.rooted") : no applicable method for 'is.rooted' applied to an object of class "NULL"

reptalex commented 4 years ago

Your tree tip labels may not align with the rownames of your dataset, causing the tree to be trimmed to nothing when phylofactor filters out tips not in rownames(Data)