Re: [R-sig-phylo] graphics for pglm results
I believe pic() (from the ape package) is the function you're looking for. This will return contrasts that can be plotted. You can manipulate which model of evolution is used by transforming the tree with ouTree() or similar functions. Nick - Nicholas Albert Mason MS Candidate, Burns Lab http://kevinburnslab.com/ Department of Biology - EB Program San Diego State University 5500 Campanile Drive San Diego, CA 92182-4614 845-240-0649 (cell) On Apr 1, 2012, at 4:38 AM, Ligia Pizzatto do Prado wrote: Hi there, I'm new using R and phylogenetic generalized least square models (pglm). I have learned how to run the analyses and now I'm a bit stuck with graphical representation of the results. My model has a continuous y-variable, and two factors. I was first advised to make a box plot using the raw data for each factor (not corrected for phylogenetic and covariates), which is also what I have seen in publications. However, when I do this, for one of the factors there seems to be a very big difference between the two states while the results of the analyses tells the difference is marginally non-significant (p~0.06). For the other factor the analyses reveals significant difference between the states but again the graph using the raw variables show only a minor difference. This is causing some confusion for the readers and I wonder how I can get the corrected values (let's say removing effects of phylogeny and covariates), and if that would be appropriated.In a simple independent contrast analyses I know I could just make grap! hs! using the contrasts, and I know how to do it in Mesquite... but for pglm in R I have no idea!!! Anyone??? Thanks Ligia [[alternative HTML version deleted]] ___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo [[alternative HTML version deleted]] ___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Re: [R-sig-phylo] How to calculate phylogenetically independent contrasts
This tutorial put together by Carl Boettiger is a good starting point: http://bodegaphylo.wikispot.org/Continuous_Character_Evolution_(Boettiger)_2011 Nick Mason - Nicholas Albert Mason MS Candidate, Burns Lab http://kevinburnslab.com/ Department of Biology - EB Program San Diego State University 5500 Campanile Drive San Diego, CA 92182-4614 845-240-0649 (cell) On Mar 28, 2012, at 6:03 AM, Yong Shen wrote: Dear all, I want to use an online tool of Phylomatic and R package ape to calculate phylogenetically Independent Contrasts, but I don't know how to produce a file as the attachment, I hope anyone knows can tell me, thanks a lot, please check the attachment. Geospiza.nex.txt___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo [[alternative HTML version deleted]] ___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
[R-sig-phylo] Error with PGLS under OU model using corMartins
Dear Rsigphylo users, I am having issues running PGLS (with nlme function gls()) under an OU model using the corMartins command from ape. I've included links to a reproducible example via my dropbox account below. Previous posts have been made about the same error I've encounter, but neither thread seems to have relevant replies or have resolved the issue. Apologies if I've missed something else from previous rsigphylo threads. https://stat.ethz.ch/pipermail/r-sig-phylo/2011-January/000875.html http://www.mail-archive.com/r-sig-phylo@r-project.org/msg00577.html In short, the data set I've linked to will run gls() under a correlation structure as defined by corBrownian and corPagel but not corMartins. The following error is encountered with corMartins: Error in recalc.corStruct(object[[i]], conLin) : NA/NaN/Inf in foreign function call (arg 4) Has anyone else experienced this issue or know how to resolve it? What does this message mean? This happens with each variable I examine, not just the example included here. Thanks in advance for any help or answers provided. Cheers, Nick Mason The R object below contains a list called sampledata. sampledata[[1]] is a data frame with tip values and sampledata[[2]] is the corresponding tree. Link to R objects: http://db.tt/ablyDBt1 Link to Rscript via public dropbox: http://db.tt/tJ8jg0JQ require(ape) require(nlme) load(sampledata.Rdata) sampledata[[1]]-tipdata sampledata[[2]]-tree gls(TraitA~TraitB,data=tipdata,correlation=corMartins(1,tree)) gls(TraitA~TraitB,data=tipdata,correlation=corBrownian(1,tree)) gls(TraitA~TraitB,data=tipdata,correlation=corPagel(1,tree)) - Nicholas Albert Mason MS Candidate, Burns Lab http://kevinburnslab.com/ Department of Biology - EB Program San Diego State University 5500 Campanile Drive San Diego, CA 92182-4614 845-240-0649 (cell) [[alternative HTML version deleted]] ___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
[R-sig-phylo] pic() vs gls()
Dear R-sig-phylo users,I have a question regarding comparative analyses of contrasts done with the functions fitContinuous() and pic() compared to using PGLS (using the gls() function).From my understanding the first method involving pic() below fits alpha (estimated using fitContinuous()) to each character independently then performs a regression on the resulting contrasts.The second (PGLS) method involving gls() fits both the regression and contrasts simultaneously and reports a single alpha value for the relationship between two traits.These two methods appear very similar, yet I get slightly different results between the two functions, particularly with respect to p-values. Using fitContinuous(), the results from the data set attached are r2 = 0.075 p = 0.091. Using gls(): r2 = 0.079 p =0.0519. Furthermore, if I switch the dependent and independent variables (V1~V2 vs V2~V1), I get the same answer with pic(), but gls() differs: r2 = -0.069 p =0.02 (see pglsModel1a vs pglsModel1b in the attachment).Could anyone explain why these functions vary (in my mind they were doing essentially the same thing) and if there are situations where one should be favored over another? Also, why does PGLS vary if you switch the dependent/independent variables in the linear model?Thanks in advance for any advice or comments offered!!Cheers,Nick MasonBelow I have the code I have been using (also attached as Mason.R):require(ape)require(nlme)require(geiger)read.csv(file="Mason_data.csv")-smdatarownames(smdata)-smdata[,1]smdata[,1]-NULL#ASIDE: If anyone could tell me how to get around these two lines of code, that would also be awesome. Header=T doesn't seem to work for me.read.tree(file="Mason_tree.tre")-spbmname.check(smdata,spbm)fitContinuous(spbm,smdata,model="OU")-ou2pr_contrast-pic(smdata[,1],ouTree(spbm,alpha=ou2$Pause_Rate$alpha))pc1_contrast-pic(smdata[,2],ouTree(spbm,alpha=ou2$Comp.1$alpha))summary(lm(pr_contrast~pc1_contrast-1))pglsModel1a-gls(Pause_Rate~Comp.1, correlation=corMartins(1, spbm),data=smdata)summary(pglsModel1a)pglsModel1b-gls(Comp.1~Pause_Rate, correlation=corMartins(1, spbm),data=smdata)summary(pglsModel1b) Mason_tree.tre Description: Binary data ,Pause_Rate,Comp.1,Comp.2 Sporophila_schistacea,0.97572108797618,1.3796099841333,-1.12587956726316 Sporophila_intermedia,0.314864247370089,2.36946494397968,1.16313695174602 Sporophila_plumbea,0.525348288841447,2.71609091582214,-0.0201502845760047 Sporophila_torqueola,0.090114188687708,3.55768691291833,0.0588440560485339 Sporophila_collaris,0.258598106973663,-0.866576621272912,-0.375459372210033 Sporophila_lineola,1.91924407069217,5.38973476610418,-0.719604956651293 Sporophila_luctuosa,0.316867010852651,3.51591652591355,-1.01122149539569 Sporophila_nigricollis,0.646766139216069,4.60967961843748,0.403572095059875 Sporophila_caerulescens,1.19967606461856,4.42942981620688,0.266281245585206 Sporophila_albogularis,-0.747926431242122,2.14986795813319,0.453292241973436 Sporophila_peruviana,-0.662055276873553,-5.75668334764164,0.194910239070253 Sporophila_simplex,-0.0159932866483984,0.50911606352083,-0.961689651320771 Sporophila_bouvreuil,-0.113798179556032,4.96419876880559,-0.0444962146993295 Sporophila_minuta,-0.653039978630658,4.51909264308507,0.271433436605055 Sporophila_hypoxantha,-1.33520075061216,3.6424747461571,-0.143885556798834 Sporophila_ruficollis,-1.10188388209151,3.69620160094318,-1.122292891 Sporophila_castaneiventris,-0.957617880681526,5.13264024147439,0.71993032372333 Sporophila_hypochroma,-0.860526127835558,3.70604616959997,-0.317101374278479 Sporophila_cinnamomea,-0.859253764452833,4.92903311573274,-0.397590156130398 Sporophila_melanogaster,0.246280339669374,3.57517426978125,0.492140024454993 Sporophila_telasco,0.512066210743585,4.57687350229544,0.151380525693064 Oryzoborus_nuttingi,-0.803111018941645,-16.0737467067366,-1.53209487276288 Oryzoborus_crassirostris,-0.57221657664358,-10.5639148825931,1.92861328894315 Oryzoborus_atrirostris,-0.871304566495871,-18.0081579920927,-0.767118053337893 Oryzoborus_maximiliani,-0.326024013387329,-14.0150572642919,-0.0204930609520138 Oryzoborus_angolensis,-0.142855044536879,-6.48632361126553,0.96227143885814 Dolospingus_fringilloides,1.26961240149379,-2.93723705653849,1.74362516139737 Mason.R Description: Binary data -Nicholas Albert MasonMS Candidate, Burns LabDepartment of Biology - EB ProgramSan Diego State University5500 Campanile DriveSan Diego, CA 92182-4614845-240-0649 (cell) ___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo