nclark-lab / RERconverge

Analysis of convergence between organismal traits and DNA/protein sequences
GNU General Public License v3.0
47 stars 26 forks source link

Differences between clade-based correlation and non-clade based correlations? #74

Open MichaelTene7 opened 1 year ago

MichaelTene7 commented 1 year ago

I have noticed that there is a difference in the correlation values produced by the Foreground + Sisterlist -> foreground2TreeClades -> tree2PathsClades -> correlateWithBinaryPhenotype pipeline and the Foreground -> foreground2Tree -> tree2Paths -> correlateWithBinaryPhenotype pipeline.

If I am not using the in-built permulations functions, should I be using the clade-based version of the paths?

Example code (and output):

library(RERconverge)
rerpath = find.package('RERconverge')

#read trees
toytreefile = "subsetMammalGeneTrees.txt" 
toyTrees=readTrees(paste(rerpath,"/extdata/",toytreefile,sep=""), max.read = 200)

#Calculate RERs
mamRERw = getAllResiduals(toyTrees, transform="sqrt", weighted=T, scale=T)

#Clades-based correlation results:
marineFg = c("Killer_whale", "Dolphin", "Walrus", "Seal", "Manatee")
sisters_marine = list("clade1"=c("Killer_whale", "Dolphin"))
marineFgTree = foreground2TreeClades(marineFg,sisters_marine,toyTrees,plotTree=F)
pathvec = tree2PathsClades(marineFgTree, toyTrees)
res = correlateWithBinaryPhenotype(mamRERw, pathvec, min.sp=10, min.pos=2,
                                   weighted="auto")

#Non-Clades-Based correlation results:
marineNoCladesFgTree = foreground2Tree(marineFg,toyTrees,plotTree=F)
nonCladePath = tree2Paths(marineNoCladesFgTree, toyTrees)
noCladeRes = correlateWithBinaryPhenotype(mamRERw, nonCladePath, min.sp=10, min.pos=2,
                                          weighted="auto")
head(noCladeRes)
head(res)

image

MichaelTene7 commented 1 year ago

Solved issue on my own: the difference is the ancestral vs effectively-all clade setup between the two setups.

I have a secondary question about some branches in the sisterlist being removed from the foreground during foreground2TreeClades, but that is not as easy to provide a discrete example for.