====== Estrutura Filogenética usando Phylocom ====== Arquivo:Alexandre/R/Lecy/ReultFIlo/LecySTRU Os subdiretórios nesta pasta incluem os resultados de análises para três escalas (10x10, 20x20 e 40x40). Cada subdiretório representa um dos modelos nulos possíveis (ver abaixo). A filogenia usada foi aquela mais conservativa (a mesma que estivemos usando). ===== Explicação dos resultados Phylocom ===== * MPD = mean phylogenetic distance * MPD.rnd = mean phylogenetic distance of all randomly generated null communities * MPD.sd = standard deviation of phylogenetic distance of all randomly generated null communities * NRI = -1 * (MPDsample – rndMPDsample) / (sd_rndMPDsample) * MPD.rankLow = number null communities with MPD less than or equal to observed * MPD.rankHi = number null communities with MPD greater than or equal to observed **Note**: These ranks can be used to calculate P-values (e.g. for a one-tailed P-value, divide a rank by the number of runs + 1). Note that if the sum of rankLow and rankHi for MPD or MNND is not close to the number of runs, there must be a large number of ties between observed and null community values and results should be interpreted with caution. This situation may arise when using very small phylogenies or numbers of samples. * MNND = mean nearest phylogenetic neighbor distance for each sample * MNND.rnd = mean nearest phylogenetic neighbor of all randomly generated null communities * MNND.sd = standard deviation of nearest phylogenetic neighbor of all randomly generated null communities * NTI = -1 * (MNNDsample – rndMNNDsample) / (sd_rndMNNDsample) * MNND.rankLow = number null communities with MNND less than or equal to observed * MNND.rankHi = number null communities with MNND greater than or equal to observed **Note**: Two measures of “standardized effect size” of community phylogenetic structure are calculated: the Net Relatedness Index (NRI) and Nearest Taxon Index (NTI) describe the difference between average phylogenetic distances in the observed and null communities, standardized by the standard deviation of phylogenetic distances in the null communities. NRI and NTI are calculated for each sample in a manner similar to that described in Webb et al. 2002. ===== Modelos nulos ===== Choosing an appropriate null model to measure community phylogenetic structure requires careful consideration. Every null model makes different assumptions, and using two null models to analyze the same data can give radically different results! See Gotelli (2000) or Gotelli and Graves (1996) for an evaluation of the assumptions and shortcomings of the different types of null models implemented in this software, and Kembel and Hubbell (2006) for an example of these null models applied to ecological data. ====Phylogeny shuffle==== This null model shuffles species labels across the entire phylogeny. This randomizes phylogenetic relationships among species. **Arquivos de dados** {{lecy10results.txt.pdf|Arquivo resultado escala 10 m}} {{lecy20results.txt.pdf|Arquivo resultado escala 20 m}} {{lecy40results.txt.pdf|Arquivo resultado escala 40 m}} **Resultados mostrando para cada subparcela de 20×20 o valor do efeito filogenetico:** {{phyloShuffleclustering.pdf|Phylogenetic clustering}} {{phyloShuffleoverdispersion.pdf|Phylogenetic overdispersion}} ==== Sample pool ==== Species in each sample become random draws from sample pool - This null model maintains the species richness of each sample, but the identities of the species occurring in each sample are randomized. For each sample, species are drawn without replacement from the list of all species actually occurring in at least one sample. Thus, species in the phylogeny that are not actually observed to occur in a sample will not be included in the null communities. **Resultados mostrando para cada subparcela de 20x20 o valor do efeito filogenetico: ** {{samplepoolclustering.pdf|Phylogenetic clustering}} {{samplepooloverdispersion.pdf|Phylogenetic overdispersion}} ==== Phylogeny pool ==== Species in each sample become random draws from phylogeny pool. This null model maintains the species richness of each sample, but the identities of the species occurring in each sample are randomized. For each sample, species are drawn without replacement from the list of all species in the phylogeny pool. All species in the phylogeny will have equal probability of being included in the null communities. {{lecy10resultsphpool.txt.pdf|Arquivo resultado escala 10}} {{lecy20results.phpool.txt.pdf|Arquivo resultado escala 20}} {{lecy40resultsphpool.txt.pdf|Arquivo resultado escala 40}} **Resultados mostrando para cada subparcela de 20×20 o valor do efeito filogenetico:** {{phylogenypoolclustering.pdf|Phylogenetic clustering}} {{phylogenypooloverdispersion.pdf|Phylogenetic overdispersion}} ==== Independent swap ==== The independent swap algorithm (Gotelli and Entsminger 2003; also known as “SIM9” (Gotelli 2000)) creates swapped versions of the sample/species matrix. It constrains the swapped matrices to have the same row and column totals as the original matrix (i.e. number of species per sample and frequency of occurrence of each species across samples are held constant as species co-occurrences in samples are randomized). The algorithm searches the presence/absence matrix for “checkerboard” cells (pairs of species/samples of the form (0..1),(1..0) or vice versa) and swaps these cell contents when it finds them. {{lecy10results_indswap.txt.pdf|Arquivo resultado escala 10}} {{lecy20results_indswap.txt.pdf|Arquivo resultado escala 20}} {{lecy40results_indswap.txt.pdf|Arquivo resultado escala 40}} **Resultados mostrando para cada subparcela de 20×20 o valor do efeito filogenetico:** {{independentswapsclustering.pdf|Phylogenetic clustering}} {{independentswapsoverdispersion.pdf|Phylogenetic overdispersion}} ===== Análises de Hábitat ===== * Plotar distância phylogenética média e desvio padrão para os oito hábitats em 20x20 (ALEXANDRE). Testar se as médias são diferentes. ==== Estrutura Filogenética do Habitat ==== === Sample Pool === ^Habitat^ntaxa^MPD^MPD.rnd^MPD.sd^NRI^MPD.rankLow^MPD.rankHi^MNND^MNND.rnd^MNND.sd^NTI^MNND.rankLo^MNND.rankHi^runs^ |1|24|1.3933|1.3933|0.0000|-2.6365|0|1000|0.6596|0.6596|0.0000|nan|1000|1000|1000| |2|24|1.3933|1.3933|0.0000|-2.6021|3|998|0.6596|0.6596|0.0000|nan|1000|1000|1000| |3|21|1.3437|1.3928|0.0308|1.5933|921|79|0.6848|0.7143|0.0645|0.4570|660|343|1000| |4|24|1.3933|1.3933|0.0000|-2.7018|3|997|0.6596|0.6596|0.0000|nan|1000|1000|1000| |5|24|1.3933|1.3933|0.0000|-2.6383|3|998|0.6596|0.6596|0.0000|nan|1000|1000|1000| |6|24|1.3933|1.3933|0.0000|-2.6666|5|997|0.6596|0.6596|0.0000|nan|1000|1000|1000| |7|24|1.3933|1.3933|0.0000|-2.5916|5|997|0.6596|0.6596|0.0000|nan|1000|1000|1000| |8|24|1.3933|1.3933|0.0000|-2.6414|2|998|0.6596|0.6596|0.0000|nan|1000|1000|1000| === Phylogeny Shuffle === ^Habitat^ntaxa^MPD^MPD.rnd^MPD.sd^NRI^MPD.rankLow^MPD.rankHi^MNND^MNND.rnd^MNND.sd^NTI^MNND.rankLo^MNND.rankHi^runs^ |1|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| |2|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| |3|21|1.3437|1.4410|0.0361|2.6951|989|11|0.6848|0.7334|0.0619|0.7855|769|232|1000| |4|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| |5|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| |6|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| |7|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| |8|24|1.3933|1.4393|0.0179|2.5698|911|89|0.6596|0.6743|0.0301|0.4865|801|288|1000| === Phylogeny Pool === ^Habitat^ntaxa^MPD^MPD.rnd^MPD.sd^NRI^MPD.rankLow^MPD.rankHi^MNND^MNND.rnd^MNND.sd^NTI^MNND.rankLo^MNND.rankHi^runs^ |1|24|1.3933|1.4396|0.0180|2.5690|911|89|0.6596|0.6731|0.0281|0.4773|806|283|1000| |2|24|1.3933|1.4396|0.0180|2.5690|911|89|0.6596|0.6731|0.0281|0.4773|806|283|1000| |3|21|1.3437|1.4408|0.0379|2.5579|986|14|0.6848|0.7339|0.0653|0.7519|764|237|1000| |4|24|1.3933|1.4396|0.0180|2.5690|912|88|0.6596|0.6731|0.0281|0.4773|806|283|1000| |5|24|1.3933|1.4396|0.0180|2.5690|911|89|0.6596|0.6731|0.0281|0.4773|806|283|1000| |6|24|1.3933|1.4396|0.0180|2.5690|911|89|0.6596|0.6731|0.0281|0.4773|806|283|1000| |7|24|1.3933|1.4396|0.0180|2.5690|911|89|0.6596|0.6731|0.0281|0.4773|806|283|1000| |8|24|1.3933|1.4396|0.0180|2.5690|913|88|0.6596|0.6731|0.0281|0.4773|806|283|1000| ===== Apresentação dos Resultados ===== * Estrutura phylogenética de comunidades: Phylogenetic clustering vs. Phylogenetic overdispersion * Checar se a abundância entra nos cálculos do Phylomat (BETO) Gráficos parcela em três cores: Overdispersion: PV<0.05 (red), PV>=0.05 e <0.1 (laranja); PV>=0.1 (yellow) Clustering PV<0.05 (azul escuro), PV>=0.05 e <0.1 (azul claro); PV>=0.1 (azul esverdeado) Nan = branco Para cada uma das escalas e cada um dos modelos nullos. * Calcular o P e o valor para a parcela toda para cada um dos modelos (Tabela) Alexandre: Independent Swaps e Phylogeny pool Beto: Phylogeny shuffle e Sample pool ===== Funções do R para plotar os Resultados ===== * **Beto**: Usei as funções abaixo para ler os resultados do Phylocom e plotar os valores de P para MPD de cada subparcela. Para funcionar as duas funções abaixo precisam estar instaladas. Precisa também dos dados originais **lecydata** e **lecydistmat** my.read.phylocom <- function( phylocom.output="lecy20results.txt", gridsize=20, plotdim=c(1000,1000), phylo.test = "clustering", title="Phylogenetic Shuffle" ) { temp.f = read.table(phylocom.output,header=T,sep="\t") if (phylo.test=="overdispersion") { temp.f[is.na(temp.f$MPD),"MPD.rankHi"] <- NA temp.f$PV <- temp.f$MPD.rankHi/temp.f$runs } if (phylo.test=="clustering") { temp.f[is.na(temp.f$MPD),"MPD.rankLow"] <- NA temp.f$PV <- temp.f$MPD.rankLow/temp.f$runs } rownames(temp.f) <- temp.f$plot #REFAZ PRODUCAO DE DADOS PARA PHYLOCOM PARA TER A PARCELA abund(lecydata,gridsize=gridsize) -> fl #get species with phylogenetic information sppmatch1=rownames(fl)%in%rownames(lecydistmat) fl = fl[sppmatch1,] #sample file as required by phylocom fl = as.data.frame(t(fl)) #nome da parcela em phylocom e da parcela original plotname = as.data.frame(cbind(rownames(fl),1:dim(fl)[1],rownames(fl))) colnames(plotname) <- c("PLOT","PHYLOCOM.PLOT","PLOT.NAME") plotname[,1] <- as.numeric(gsub("X","",as.vector(plotname[,1]))) plotname$X <- ceiling(plotname[,1]/(plotdim[2]/gridsize)) plotname$Y <- (plotname[,1]-((plotdim[2]/gridsize)*plotname$X))+(plotdim[1]/gridsize) plotname$PV <- temp.f[rownames(plotname),"PV"] temp.res = matrix(NA,nrow=plotdim[2]/gridsize,ncol=plotdim[1]/gridsize) pv = plotname[!is.na(plotname$PV),"PV"] pv1 = length(pv[pv<0.05]) pv2 = length(pv[pv>=0.05 & pv<0.1]) pv3 = length(pv[pv>=0.1]) cat("Test for phylogenetic ",phylo.test,"\n") cat("\tNumber subplots with P<0.05",pv1,"\n") cat("\tNumber subplots with P>=0.05 & P<0.1",pv2,"\n") cat("\tNumber subplots with P>=0.1",pv3,"\n\n") for (i in 1:dim(plotname)[1]) { x = plotname[i,"X"] y = plotname[i,"Y"] pv = plotname[i,"PV"] if (is.na(pv)) {p=4} else { if (pv<0.05) {p=1} if (pv>=0.05 & pv<0.1) {p=2} if (pv>0.1) {p=3} } temp.res[x,y] <- p } title = paste(title," (",phylo.test,") ",sep="") my.img(temp.res,title=title) } my.img <- function(x,title="") { di = dim(x) nr <- di[1] nc <- di[2] rowInd <- 1L:nr colInd <- 1L:nc op <- par(no.readonly = TRUE) on.exit(par(op)) plot(1L:nc, 1L:nr, xlim = 0.5 + c(0, nc+10), ylim = 0.5 + c(0, nr), axes = F, xlab = "", ylab = "",type="n",asp=1) temp.x = as.data.frame(x) for (b in 1:dim(temp.x)[1]) { for (c in 1:dim(temp.x)[2]) { temp.v = as.vector(temp.x[b,c]) if (!is.na(temp.v)) { temp.v = as.numeric(round(temp.v,2)) xx = c(c-0.5,c-0.5,c+0.5,c+0.5) yy = c(b-0.5,b+0.5,b+0.5,b-0.5) if (temp.v==1) {bg.col="darkred"} if (temp.v==2) {bg.col="red"} if (temp.v==3) {bg.col="orange"} if (temp.v==4) {bg.col="yellow"} polygon(xx,yy,density=-1,col=bg.col,border=NA) } } } par(mgp=c(1.5,0.2,0),tcl=-0.1) axis(1, 1L:nc, las = 2, line=-1*(par("mar")[1]-2.7), cex.axis = 0.4,lwd=0.1) axis(2, 1L:nr, line=-1, las=2,cex.axis = 0.4,lwd=0.1) mtext(title,side=3,adj=0.35,cex=1,font=2,line=-1*(par("mar")[3]-2)) temp.leg = c("P<0.05","P>=0.05 & P<0.1","P>0.1","Nan") temp.col =c("darkred","red","orange","yellow","white") cc = nc+2 bb = (nr/2) text(cc+1,bb+2,labels="P value",adj=0) for (k in 1:length(temp.leg)) { xx = c(cc-0.5,cc-0.5,cc+0.5,cc+0.5) yy = c(bb-0.5,bb+0.5,bb+0.5,bb-0.5) polygon(xx,yy,density=-1,col=temp.col[k],lwd=0.1) text(cc+1.2,bb,as.character(temp.leg[k]),cex=0.7,adj=0) bb = bb-1.5 } } ===== Notas e observações ===== **Beto - 23Jun08 - **: De fato algumas parcelas que estão incluídas no arquivo de input do Phylocom não aparecem no arquivo de output. Acredito que é um bug do programa e irei escrever aos autores para saber o que está ocorrendo, mas preciso primeiro rodar uma nova análise para ter certeza de que é isso mesmo. Dos 2337 subparcelas do 20x20 só aparecem 2190 nos resultados. ** Beto - 28Jun08 - **: Chequei a história das parcelas que pareciam estar sumindo. Na verdade não estão não. Está tudo certo. Das 2337 parcelas tem 147 onde não há nenhum indivíduo de Lecy, por isso a discrepância.... Então os resultados estão corretos. **Resultados mostrando para cada subparcela de 20×20 o valor do efeito filogenetico:** {{phylocomfiguras1.pdf|Resultados de todos os modelos}}