[Esm-commits] r23 - in pkg/ESM: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 4 14:38:22 CET 2010
Author: timotheepoisot
Date: 2010-02-04 14:38:22 +0100 (Thu, 04 Feb 2010)
New Revision: 23
Modified:
pkg/ESM/DESCRIPTION
pkg/ESM/R/draw.network.r
pkg/ESM/R/functions.r
pkg/ESM/R/std.matrix.r
pkg/ESM/man/draw.network.Rd
pkg/ESM/man/getspe.Rd
pkg/ESM/man/std.matrix.Rd
Log:
1.5.0
Modified: pkg/ESM/DESCRIPTION
===================================================================
--- pkg/ESM/DESCRIPTION 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/DESCRIPTION 2010-02-04 13:38:22 UTC (rev 23)
@@ -1,6 +1,6 @@
Package: ESM
-Version: 0.1.4-01
-Date: 2009-11-06
+Version: 0.1.5-01
+Date: 2010-02-04
Title: Ecological Specificity Measures
Author: Timothee Poisot <tpoisot at um2.fr>
Maintainer: Timothee Poisot <tpoisot at um2.fr>
@@ -8,4 +8,4 @@
Suggests: vegan
Description: Performs several measures of ecological specificity
License: GPL (>= 2)
-URL: http://www.timotheepoisot.fr
\ No newline at end of file
+URL: http://www.timotheepoisot.fr/R/
\ No newline at end of file
Modified: pkg/ESM/R/draw.network.r
===================================================================
--- pkg/ESM/R/draw.network.r 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/R/draw.network.r 2010-02-04 13:38:22 UTC (rev 23)
@@ -41,7 +41,7 @@
add=TRUE,
bg=org.col,
fg=border,
- main='Réseau',
+ main='Web',
xlab='',
ylab=''
)
Modified: pkg/ESM/R/functions.r
===================================================================
--- pkg/ESM/R/functions.r 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/R/functions.r 2010-02-04 13:38:22 UTC (rev 23)
@@ -6,7 +6,7 @@
return(out)
}
-get.HR <- function(pop)
+get.RR <- function(pop)
{
Ni <- sum(pop>0)
N <- length(pop)
@@ -66,12 +66,12 @@
return(spe)
}
-hr <- function(m)
+rr <- function(m)
{
spe <- vector('numeric',length=nrow(m))
for(i in 1:nrow(m))
{
- spe[i] <- get.HR(as.vector(as.numeric(m[i,])))
+ spe[i] <- get.RR(as.vector(as.numeric(m[i,])))
}
return(spe)
}
@@ -85,4 +85,23 @@
}
cv = function(d) sd(d)/mean(d)
-last = function(d) d[length(d)]
\ No newline at end of file
+last = function(d) d[length(d)]
+scale = function(v,m=0,M=1)
+{
+ v <- v-min(v)
+ v <- v/max(v)
+ v <- v*(M-m)
+ v <- v+m
+ return(v)
+}
+dmat = function(m,n=2)
+{
+ e <- (max(m)-min(m))/n
+ cl <- seq(from=0,to=1,by=e)
+ nm <- matrix(0,ncol=ncol(m),nrow=nrow(m))
+ for(i in 1:(length(cl)-1))
+ {
+ nm[(cl[i]<m)&(m<=cl[(i+1)])] <- cl[i]
+ }
+ return(scale(nm,0,1))
+}
\ No newline at end of file
Modified: pkg/ESM/R/std.matrix.r
===================================================================
--- pkg/ESM/R/std.matrix.r 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/R/std.matrix.r 2010-02-04 13:38:22 UTC (rev 23)
@@ -1,4 +1,4 @@
-std.matrix <- function(filename)
+std.matrix <- function(filename,t=FALSE)
{
dat <- read.table(filename)
if(t){dat<-t(dat)}
Modified: pkg/ESM/man/draw.network.Rd
===================================================================
--- pkg/ESM/man/draw.network.Rd 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/man/draw.network.Rd 2010-02-04 13:38:22 UTC (rev 23)
@@ -19,9 +19,7 @@
\examples{
# Read an interaction matrix
-library(vegan)
-dune <- data(dune)
-dune <- as.matrix(dune/max(dune))
+intmat <- matrix(runif(100,0,1),ncol=10)
# Plot
-draw.network(dune,org.col='palegreen',sortorg=rank(getspe(dune,hr)))
+draw.network(intmat,org.col='palegreen',sortorg=rank(getspe(intmat,lsd)))
}
\ No newline at end of file
Modified: pkg/ESM/man/getspe.Rd
===================================================================
--- pkg/ESM/man/getspe.Rd 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/man/getspe.Rd 2010-02-04 13:38:22 UTC (rev 23)
@@ -4,7 +4,7 @@
\title{Specificity}
\description{Returns a vector containing the specificity of each organism}
\usage{
-getspe(mat,measure=hr)
+getspe(mat,measure=lsd)
}
\arguments{
@@ -16,9 +16,9 @@
\item{}{A vector with the specificity of each organism. Uses names if the matrix as such property.}
}
-\details{Values of \kbd{measure} can be : \kbd{hr}, the classical host range; \kbd{ssi}, the species specialization index; \kbd{fd}, the Fitness Differences index; \kbd{hs}, Shannon's entropy.}
+\details{Values of \kbd{measure} can be : \kbd{rr}, the classical resource range; \kbd{ssi}, the species specialization index; \kbd{lsd}, the Link Strength Difference index; \kbd{hs}, Shannon's entropy.}
-\references{For FD, and this package, cite : Poisot, T & Hochberg, M E "..." XXX.
+\references{For LSD, and this package, cite : Poisot, T, Canard E, Mouquet N & Hochberg, M E "..." XXX.
For HS, cite : Schug J, et al. (2005) Promoter features related to tissue specificity as measured by Shannon entropy. Genome biology 6(4):R33
@@ -29,5 +29,5 @@
MAT <- 'http://www.nceas.ucsb.edu/interactionweb/data/host_parasite/text_matrices/mcgregor_p.txt'
mat <- t(read.table(MAT))
# Returns host range
-getspe(mat,hr)
+getspe(mat,lsd)
}
\ No newline at end of file
Modified: pkg/ESM/man/std.matrix.Rd
===================================================================
--- pkg/ESM/man/std.matrix.Rd 2010-02-01 11:00:14 UTC (rev 22)
+++ pkg/ESM/man/std.matrix.Rd 2010-02-04 13:38:22 UTC (rev 23)
@@ -1,19 +1,19 @@
\name{std.matrix}
\Rdversion{1.1}
\alias{std.matrix}
-\title{Specificity}
-\description{Returns a vector containing the specificity of each organism}
+\title{Read an interaction matrix}
+\description{Returns an interaction matrix normalized to 1}
\usage{
-getspe(mat,measure=hr)
+std.matrix(filename,t=FALSE)
}
\arguments{
-\item{mat}{A matrix giving the performance of each organism on each resource, with organisms as rows}
-\item{measure}{The index of specificity to use. Values can be}
+\item{filename}{The file containing the matrix (interaction)}
+\item{t}{Logical to transpose the matrix, FALSE by default}
}
\value{
- \item{}{A vector with the specificity of each organism. Uses names if the matrix as such property.}
+ \item{}{An interaction matrix}
}
\details{Values of \kbd{measure} can be : \kbd{hr}, the classical host range; \kbd{ssi}, the species specialization index; \kbd{dfp}, the DFP index; \kbd{shannon}, Shannon's entropy; \kbd{wadfp}, the weighted additive DFP.}
@@ -26,8 +26,5 @@
\examples{
# Read an interaction matrix
-MAT <- 'http://www.nceas.ucsb.edu/interactionweb/data/host_parasite/text_matrices/mcgregor_p.txt'
-mat <- t(read.table(MAT))
-# Returns host range
-getspe(mat,hr)
+MAT <- std.matrix('http://www.nceas.ucsb.edu/interactionweb/data/host_parasite/text_matrices/mcgregor_p.txt',t=TRUE)
}
\ No newline at end of file
More information about the Esm-commits
mailing list