Commit 50b57dc2 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

all try data run

No related merge requests found
Showing with 34 additions and 34 deletions
+34 -34
...@@ -142,54 +142,54 @@ species.tab2$Latin_name_syn<- trim.trailing(species.tab2$Latin_name_syn) ...@@ -142,54 +142,54 @@ species.tab2$Latin_name_syn<- trim.trailing(species.tab2$Latin_name_syn)
## lapply(unique(species.tab2$Latin_name_syn)[1:10],FUN=tnrs) ## lapply(unique(species.tab2$Latin_name_syn)[1:10],FUN=tnrs)
### find synonyme ## ### find synonyme
getsynonymnamesfromtsn(tsn = 502590) ## getsynonymnamesfromtsn(tsn = 502590)
### find synonyme ## ### find synonyme
tp_synonyms(id =502590 ) ## tp_synonyms(id =502590 )
# Example R script which calls the TNRS in the context of adding names to a phylogeny ## # Example R script which calls the TNRS in the context of adding names to a phylogeny
## FROM Boyle et al. 2013 BMC Bioinformatics ## ## FROM Boyle et al. 2013 BMC Bioinformatics
library(ape) ## library(ape)
library(rjson) ## library(rjson)
library(RCurl) ## library(RCurl)
tnrs.api<-'http://tnrs.iplantc.org/tnrsm-svc' ## tnrs.api<-'http://tnrs.iplantc.org/tnrsm-svc'
#Tree topology from Ackerly, D. 2009. Conservatism and diversification of plant functional traits: Evolutionary rates versus phylogenetic signal. PNAS 106:19699--19706. ## #Tree topology from Ackerly, D. 2009. Conservatism and diversification of plant functional traits: Evolutionary rates versus phylogenetic signal. PNAS 106:19699--19706.
lobelioids.string<-'((((((Lobelia_kauaensis,Lobelia_villosa),Lobelia_gloria-montis),(Trematolobelia_kauaiensis,Trematolobelia_macrostachys)),((Lobelia_hypoleuca,Lobelia_yuccoides),Lobelia_niihauensis)),((Brighamia_insignis,Brighamia_rockii),(Delissea_rhytidosperma,Delissea_subcordata))),((((Cyanea_pilosa,Cyanea_acuminata),Cyanea_hirtella),(Cyanea_coriacea,Cyanea_leptostegia)),(((Clermontia_kakeana,Clermontia_parviflora),Clermontia_arborescens),Clermontia_fauriei)));' ## lobelioids.string<-'((((((Lobelia_kauaensis,Lobelia_villosa),Lobelia_gloria-montis),(Trematolobelia_kauaiensis,Trematolobelia_macrostachys)),((Lobelia_hypoleuca,Lobelia_yuccoides),Lobelia_niihauensis)),((Brighamia_insignis,Brighamia_rockii),(Delissea_rhytidosperma,Delissea_subcordata))),((((Cyanea_pilosa,Cyanea_acuminata),Cyanea_hirtella),(Cyanea_coriacea,Cyanea_leptostegia)),(((Clermontia_kakeana,Clermontia_parviflora),Clermontia_arborescens),Clermontia_fauriei)));'
#Transform the newick sting into an ape phylo object ## #Transform the newick sting into an ape phylo object
tree<-read.tree(text=lobelioids.string) ## tree<-read.tree(text=lobelioids.string)
#Obtain the taxa names ## #Obtain the taxa names
old.names<-tree$tip.label ## old.names<-tree$tip.label
#Change the underscore characters into blank spaces ## #Change the underscore characters into blank spaces
old.names<-gsub('_',' ',old.names) ## old.names<-gsub('_',' ',old.names)
old.names <- species.tab2$Latin_name_syn ## old.names <- species.tab2$Latin_name_syn
#Transporms the vector into a string ## #Transporms the vector into a string
old.names<-paste(old.names,collapse=',') ## old.names<-paste(old.names,collapse=',')
#The string needs to be URL-encoded ## #The string needs to be URL-encoded
old.names<-curlEscape(old.names) ## old.names<-curlEscape(old.names)
#Send a request to the TNRS service ## #Send a request to the TNRS service
url<-paste(tnrs.api,'/matchNames?retrieve=best&names=',old.names,sep='') ## url<-paste(tnrs.api,'/matchNames?retrieve=best&names=',old.names,sep='')
tnrs.json<-getURL(url) ## tnrs.json<-getURL(url)
#The response needs to be converted from JSON ## #The response needs to be converted from JSON
tnrs.results<-fromJSON(tnrs.json) ## tnrs.results<-fromJSON(tnrs.json)
#The corrected names are extracted from the response ## #The corrected names are extracted from the response
names<-sapply(tnrs.results[[1]], function(x) c(x$nameSubmitted,x$acceptedName)) ## names<-sapply(tnrs.results[[1]], function(x) c(x$nameSubmitted,x$acceptedName))
names<-as.data.frame(t(names),stringsAsFactors=FALSE) ## names<-as.data.frame(t(names),stringsAsFactors=FALSE)
#If TNRS did not return any accepted name (no match, or name is already accepted), the submitted name is retained ## #If TNRS did not return any accepted name (no match, or name is already accepted), the submitted name is retained
names[names[,2]=="",2]<-names[names[,2]=="",1] ## names[names[,2]=="",2]<-names[names[,2]=="",1]
### SAME ERROR FOR FAGUS SYLVATICA TEH WEB SITE GIVE A GOOD RESULTS BUT NOT THE CALL FROM R ? ## ### SAME ERROR FOR FAGUS SYLVATICA TEH WEB SITE GIVE A GOOD RESULTS BUT NOT THE CALL FROM R ?
### change format try species names ### change format try species names
TRY.DATA.FORMATED$AccSpeciesName <- as.character(TRY.DATA.FORMATED$AccSpeciesName) TRY.DATA.FORMATED$AccSpeciesName <- as.character(TRY.DATA.FORMATED$AccSpeciesName)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment