[Picante-commits] r90 - branches/gsoc/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jun 9 09:26:23 CEST 2008
Author: mrhelmus
Date: 2008-06-09 09:26:23 +0200 (Mon, 09 Jun 2008)
New Revision: 90
Modified:
branches/gsoc/R/phylodiversity.R
Log:
Fixed Bug: in PSE,PSC,PSV and sppPSV. Prunes the tree to the species found in the sample. Now the tree or the Cmatrix can have more species than the sample.
Modified: branches/gsoc/R/phylodiversity.R
===================================================================
--- branches/gsoc/R/phylodiversity.R 2008-06-05 06:13:53 UTC (rev 89)
+++ branches/gsoc/R/phylodiversity.R 2008-06-09 07:26:23 UTC (rev 90)
@@ -121,6 +121,7 @@
PSVcalc<-function(samp,tree,compute.var=TRUE){
# Make samp matrix a pa matrix
samp[samp>0]<-1
+
flag=0
if (is.null(dim(samp))) #if the samp matrix only has one site
{
@@ -130,12 +131,17 @@
if(is(tree)[1]=="phylo")
{
+ tree<-pruneMissing(samp[1,],tree)$tree
# Make sure that the species line up
samp<-samp[,tree$tip.label]
# Make a correlation matrix of the species pool phylogeny
Cmatrix<-vcv.phylo(tree,cor=T)
} else {
Cmatrix<-tree
+ species<-colnames(samp)
+ preval<-colSums(samp)/sum(samp)
+ species<-species[preval>0]
+ Cmatrix<-Cmatrix[species,species]
samp<-samp[,colnames(Cmatrix)]
}
@@ -251,12 +257,17 @@
if(is(tree)[1]=="phylo")
{
+ tree<-pruneMissing(samp[1,],tree)$tree
# Make sure that the species line up
samp<-samp[,tree$tip.label]
# Make a correlation matrix of the species pool phylogeny
Cmatrix<-vcv.phylo(tree,cor=T)
} else {
Cmatrix<-tree
+ species<-colnames(samp)
+ preval<-colSums(samp)/sum(samp)
+ species<-species[preval>0]
+ Cmatrix<-Cmatrix[species,species]
samp<-samp[,colnames(Cmatrix)]
}
@@ -311,12 +322,17 @@
if(is(tree)[1]=="phylo")
{
+ tree<-pruneMissing(samp[1,],tree)$tree
# Make sure that the species line up
samp<-samp[,tree$tip.label]
# Make a correlation matrix of the species pool phylogeny
Cmatrix<-vcv.phylo(tree,cor=T)
} else {
Cmatrix<-tree
+ species<-colnames(samp)
+ preval<-colSums(samp)/sum(samp)
+ species<-species[preval>0]
+ Cmatrix<-Cmatrix[species,species]
samp<-samp[,colnames(Cmatrix)]
}
@@ -368,12 +384,17 @@
}
if(is(tree)[1]=="phylo")
{
+ tree<-pruneMissing(samp[1,],tree)$tree
# Make sure that the species line up
samp<-samp[,tree$tip.label]
# Make a correlation matrix of the species pool phylogeny
Cmatrix<-vcv.phylo(tree,cor=T)
} else {
Cmatrix<-tree
+ species<-colnames(samp)
+ preval<-colSums(samp)/sum(samp)
+ species<-species[preval>0]
+ Cmatrix<-Cmatrix[species,species]
samp<-samp[,colnames(Cmatrix)]
}
# reduce given Cmatrix to the species observed in samp
@@ -421,4 +442,5 @@
}
return(data.frame(PSDout))
}
-}
\ No newline at end of file
+}
+
More information about the Picante-commits
mailing list