Tabela de conteúdos

Rafael L. G. Raimundo

rafael-raimundo2.png

Doutorando em Ecologia, IB-USP. Orientador: Paulo Guimarães Jr. Projeto de Tese: Especiação adaptativa em mutualismos. Desenvolvemos modelos baseados em indivíduos para simular cenários nos quais a seleção disruptiva e acasalamentos não-aleatórios podem causar a origem de novas espécies, considerando os efeitos da competição e da estrutura das redes ecológicas.

rafael.raimundo@usp.br

PROPOSTA DE TRABALHO FINAL

PRINCIPAL: Redes sociais - métricas básicas e modelos nulos

Propõe-se uma função que transforme dados de redes sociais da Internet em matrizes a partir das quais seja possível descrever a estrutura dessas redes (e. g. centralidade de grau, diâmetro, modularidade). A função deve ainda simular matrizes/redes randômicas cujas propriedades sejam as mesmas que as da rede original, possibilitando testar-se se a estrutura de rede observada pode ter sido gerada ao acaso.

exec

Fonte e Estrutura dos Dados

PLANO B

Similar ao anterior, mas usando matrizes binárias que descrevem redes de interações animais-planta. No caso, o modelo nulo seria implementado conforme Bascompte et al. (2003).

Referências - Plano B

Bascompte et al. 2003

Dormann et al. 2009

Comentários

Bem legal, a idéia é bem generalizável (vide proposta B). Como vai apresentar seu output? Os dados de outras redes sociais que não Twitter são de fácil acesso e são disponibilizados da mesma maneira? Se não, talvez seja legal criar uma maneira de padronizá-los para que entrem da mesma forma na função. Parece factível no prazo.

Gabriel

Após a entrega: não gerou todos os gráficos, e seu código retorna um erro:

 Erro em plot.window(...) : valores finitos são necessários para 'xlim'

Resposta: Estou ciente do erro. Não consegui resolver e coloquei uma descrição mais detalhada do problema no Forum: http://bie5782.138098.n3.nabble.com/Error-in-plot-window-need-finite-xlim-values-tp2827809p2827809.html

mas não houve nenhuma resposta.

Página de Ajuda

alpha.gamma                package:none                R Documentation

Relationships between alpha and gamma diversity: local-regional plots and nestedness

Description

The function alpha-gamma builds local-regional diversity plots (saturation test) and compare matrix temperatures for observed assemblages and null model predictions.

Usage

alpha.gamma(regional.dataset, local.datasets, nsmul)

Arguments:

regional.dataset     path (if necessary) and filename for the regional plant x animal interactions matrix

local.datasets     unique pattern (e. g. "loc") common and exclusive to all "locN.txt" files, each file containing 1 local community matrix

nsmul number of theoretical matrices

Details

Plots of local (alpha) versus regional (gama) species richness allow testing for species saturation in ecological communities (Cornell 1985). A proportional relationship between alpha and gama is interpreted as evidence that the number of locally coexisting species is a proportinal sample of the regional species pool  (unsaturated or type-1 community). However, if ecological processes constrain the number of locally coexisting species, no correlation between is expected between local and regional richness (saturated or type-2 communities (Lawton 1994).
                                                                                 

The function alpha.gamma stores the regional plant-animal interactions matrix and the local networks matrices in lists, and manipulate that objects in order to build local-regional plots and to estimate matrices temperatures.

The null model proposed by Bascompte et al. (2003) was applied to the regional animal-plant matrix and the resulting theoretical matrices were used to simulate the assembly of local communities when local process do not constrain the number of coexisting species (unsaturated communities), i. e., if local communities are proportional samples of the regional species pool.

The function computes the mean local animal species richness per plant and the nestedness temperature for theoretical and empirical matrices. 

Value

Returns a windows with a set of 6 figures describing

1. Local-Regional plot (Null Models)
2. Local-Regional plot (Field Data)
3. Kernel Distribution for Matrix Temperatures (Null Models)
4. Kernel Distribution for Matrix Temperatures (Field Data)
5. Regional Matrix Temperature
6. Regional Interactions Graph   

Warning

Function will not run if data matrices have NA. 

The packages bipartite and ggplot2 are required.

The output will be printed in about 30 s.

Author(s):

Rafael L. G. Raimundo

References

Bascompte et al. (2003). [[http://www.pnas.org/content/100/16/9383|The nested assembly of plant-animal mutualistic networks]]. Proceedings of the National Academy of Sciences (USA), 100: 9383-9387.

Cornell, H. V. (1985). [[http://www.jstor.org/pss/1939178|Local and regional richness of cynipine galls wasps on california oaks]]. Ecology 66: 1247-1260.

Lawton, J., (1984). [[http://ecoplexity.org/files/uploads/Ecology_patterns.pdf|Are there general laws in Ecology?]] Oikos 84: 177-192.

Poisot, T. (2010)., [[http://www.r-bloggers.com/a-fast-null-model-of-bipartite-networks/|A fast (!) null model of bipartite networks.]]. R Bloggers. 


Examples

alpha.gamma(regional.dataset="regional.example.txt", loc="__com", nsmul=10)

Please unpack the file {{:bie5782:01_curso_atual:alunos:trabalho_final:rafael:alpha.gamma.r.example.zip|alpha.gamma.r.example.zip}} to run the function using data from Vázquez & Simberloff (2002). This zip file contains the function file, 1 regional matrix (species pool) and 8 local matrices of pollinators and plants (local assemblages).

I will post the automatic examples here soon.

Código da Função

#######################################################################
### Função desenvolvida como projeto de final de curso BIE5782 - PPGEco - USP
### Prof. P. I. Prado e Prof. A. Adalardo de Oliveira
### Aluno: R. L. G. Raimundo
#######################################################################
alpha.gamma<-function(regional.dataset, local.datasets, nsmul) 
    
### LOAD ALL THAT HARD FIELD WORK
### The link to download the example files [from Vázquez & Simberloff (2005)]  
{
pool<-read.table(regional.dataset)
colnames(pool)<-paste("Pollinator", seq(1:dim(pool)[2]))
rownames(pool)<-paste("Plant", seq(1:dim(pool)[1]))
dir( pattern = local.datasets )->local.files
length(local.files)->lfn

###FIELD DATA
### Compute nestedness temperature for each empirical matrix
### Compute pollinator richness by plant for each emperical matrix
require(bipartite)
alpha.field.list=list()
nestedness.field.list=list()
local.list=list()
for(i in 1:lfn)
  {
      temp.table<-read.table(local.files[i])
      temp.table[temp.table>0] <- 1
      #rownames(temp.table)<-paste("Plant", seq(1:dim(temp.table)[2]))
      #colnames(temp.table)<-paste("Pollinator", seq(1:dim(temp.table)[1]))
      local.list[[i]] = temp.table
      nested(local.list[[i]], null.models=FALSE)->temperatures.field
      rowSums(local.list[[i]])->richnesses.field
   alpha.field.list[[i]]=richnesses.field
   nestedness.field.list[[i]]=temperatures.field
  }  
### A NULL MODEL FOR BIPARTITE NETWORKS (SCENARIO: LOCAL NETWORKS ARE RANDOM SAMPLES OF THE REGIONAL SPECIES POOL)
### Generate nsmul matrices according to the null model (i. e., proportionaly sample local communities from the regional pool)
### Compute nestedness temperature for each theoretical matrix
### Compute pollinator richness by plant for each theoretical matrix
alpha.list=list()
nestedness.list=list()
bascompte.list=list()
for(k in 1:nsmul)
    {
      for(u in 1:nsmul){
        ref<-read.table(regional.dataset) 
        ref[ref>0] <- 1
        margin <- ifelse(ncol(ref)< nrow(ref),2,1)
        currentweb <- matrix(0,ncol=ncol(ref),nrow=nrow(ref))
        pc <- colMeans(ref)
        pr <- rowMeans(ref)
        if(margin==2)
          {
            for(i in 1:ncol(ref))
              {
                currentweb[,i] <- (pc[i]+pr)/2
              }
          } else
        {
          for(i in 1:nrow(ref))
            {
              currentweb[i,] <- (pr[i]+pc)/2
            }
        }
        (apply(currentweb,margin,function(x)rbinom(length(x),1,x)))->expected.local
        t(expected.local)->expected.local
        bascompte.list[[u]]=expected.local
        nested(bascompte.list[[u]], null.models=FALSE)->temperatures
        rowSums(bascompte.list[[u]])->richnesses.null
     }
      alpha.list[[k]]=richnesses.null
      nestedness.list[[k]]=temperatures
    }

################### arent matrices lists cool? 
pool
pool[pool>0]<-1
pool->pool.plot
rowSums(pool)->gama.sum

gama.sum # pollinator richness for each plant at the regional scale

alpha.list # pollinator richness for each plant at the local scale (null model)
alpha.field.list # observed pollinator richness for each plant at the local scale

nestedness.field.list #nestedness temperatures for each empirical matrix
nestedness.list # nestedness temperatures for each theoretical matrix

################### Output
require(ggplot2)
#Compute mean local pollinator richness by plant (Null Model)
melt.list(alpha.list)->alpha.theor
alpha.theor$L1<-c(rep(seq(1:dim(temp.table)[1]),nsmul))
colnames(alpha.theor)<-c("Alpha", "Plant")
as.factor(alpha.theor$Plant)->alpha.theor$Plant
tapply(alpha.theor$Alpha, alpha.theor$Plant, mean)->mean.alpha.theor
tapply(alpha.theor$Alpha, alpha.theor$Plant, sd)->dp.alpha.theor

#Compute mean local pollinator richness by plant (Field Data)
melt.list(alpha.field.list)->alpha.empiric
alpha.empiric$L1<-c(rep(seq(1:dim(temp.table)[1]),lfn))
colnames(alpha.empiric)<-c("Alpha", "Plant")
as.factor(alpha.empiric$Plant)->alpha.empiric$Plant
tapply(alpha.empiric$Alpha, alpha.empiric$Plant, mean)->mean.alpha.empiric
tapply(alpha.empiric$Alpha, alpha.empiric$Plant, sd)->dp.alpha.empiric

#Melt nestedness temperatures - theoretical and empirical matrices
melt(nestedness.list)->nestedness.theor
nestedness.theor$value->z1
melt(nestedness.field.list)->nestedness.empiric
nestedness.empiric$value->z2

#Plot some figures summarizing all the job
require(bipartite)
par(mfrow=c(3,2))

plot(mean.alpha.theor~gama.sum, xlab="Regional Richness(Gama)", ylab="Mean Local Richness(Alpha)", main="Null Model")
lm(mean.alpha.theor~gama.sum)->alpha.null.m1
abline(alpha.null.m1)

plot(mean.alpha.empiric~gama.sum, xlab="Regional Richness(Gama)", ylab="Mean Local Richness(Alpha)", main="Field Data")
lm(mean.alpha.empiric~gama.sum)->alpha.empiric.m1
abline(alpha.empiric.m1)

hist(z1, prob=TRUE, main=paste("Null Model"), xlab="Local Matrices Temperature")
lines(density(z1))
hist(z2, prob=TRUE, main=paste("Field Data"), xlab="Local Matrices Temperature")
lines(density(z2))

pool.plot->pool.plot2
nestedtemp(pool.plot2)->pool.plot2
plot(pool.plot2, main="Regional Matrix and Regional Network")

pool.plot->rede
plotweb(rede, method="normal", ybig=0.8)

return()
}

Arquivo da Função

Please unpack the file alpha.gamma.r.zip to run the function using data from Vázquez & Simberloff (2002). This zip file contains the function file, 1 regional matrix (species pool) and 8 local matrices of pollinators and plants (local assemblages).

Exercícios

Exercício 1 Exercício 2 Exercício 3 Exercício 4 Exercício 5Exercício 6Exercício 7Exercício 8 Exercício 9

Outros arquivos

Matriz de Interações - Cecrópias e Formigas

R.css

A program for applying the principle of parsimony in multiple regression

To explain or to predict?