[adegenet-forum] MSPA no listw lw

Jombart, Thibaut t.jombart at imperial.ac.uk
Mon Jan 31 11:39:35 CET 2011


Dear Cecile, 

sorry for the late reply, and for the issue. Indeed the $cn must be removed. This is because in earlier version of chooseCN, the function was returning list with a $cn and a $xy, while now the xy coordinates are passed as attribute.

However, I fail to reproduce the second error. Make sure to have the right version of the function installed:
####
install.packages("sedarJombart", repos="http://R-Forge.R-project.org")
library(ade4)
library(spdep)
library(sedarJombart)

## Hellinger transformation
hellTrans <- function(X){
if (!( is.matrix(X) | is.data.frame(X) )) stop("Object is not a matrix or
data frame.")
if (any(is.na(X))) stop("na entries in table.")
sumRow <- apply(X,1,sum)
Y <- X/sumRow
Y <- sqrt(Y)
return(Y)
}


## analysis of Hill & Smith for mixed variables
hsEnv <- dudi.hillsmith(oribatid$envir,scannf=FALSE)

## detrending of the data (residuals from projection on xy coordinates)
hsEnv.detr <- pcaivortho(hsEnv,oribatid$xy,scannf=FALSE)

## MSPA of environmental data
mspaEnv <- mspa(hsEnv.detr,cn,scannf=FALSE,nf=2)
scatter(mspaEnv)

####

As a side note, I won't probably be able to live with a package called 'sedarJombart'... the MSPA will likely integrate a single sedaR package (if it comes to existence eventually) or be moved to ade4 (less likely to adegenet, since it was not designed for genetic data in the first place).

Best regards

Thibaut


________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] On Behalf Of Cecile Berthouly-Salazar [cberthouly at sun.ac.za]
Sent: 27 January 2011 09:11
To: adegenet-forum at r-forge.wu-wien.ac.at
Subject: [adegenet-forum] MSPA no listw lw

Hi Thibaut,

I'm learning how to apply the MSPA methods from the supplemetary data from paper in Ecography.
If I do exactly what it written then I have this:
> cn <- chooseCN(oribatid$xy,res="listw",ask=FALSE,type=1)$cn
> class(cn)
[1] "NULL"
> mspaEnv <- mspa(hsEnv.detr,cn,scannf=FALSE)
Error in mspa(hsEnv.detr, cn, scannf = FALSE) :
  lw must be a listw object (package spdep)

If I remonve $cn, then I have this:

> cn <- chooseCN(oribatid$xy,res="listw",ask=FALSE,type=1)
> class(cn)
[1] "listw" "nb"
> mspaEnv <- mspa(hsEnv.detr,cn,scannf=FALSE)
Error in mspa(hsEnv.detr, cn, scannf = FALSE) :
  object 'network' not found

How should I do?
Thanks
Cecile


More information about the adegenet-forum mailing list