RNeXML: Semantically Rich I/O for the 'NeXML' Format

> library(RNeXML)
Loading required package: ape
> data("simmap_ex")

バージョン: 2.0.4


関数名 概略
add_basic_meta Add basic metadata
add_characters Add character data to a nexml object
add_meta Add metadata to a nexml file
add_namespaces add namespaces
add_trees add_trees
c,ListOfmeta-method Concatenate ListOfmeta elements into a ListOfmeta
c,meta-method Concatenate meta elements into a ListOfmeta
c,nexml-method Concatenate nexml files
flatten_multiphylo Flatten a multiphylo object
get_characters Get character data.frame, accepts either nexml object, or a list of data.frames
get_characters_list Extract the character matrix
get_citation get_citation
get_flat_trees get_flat_trees
get_license get_license
get_metadata get_metadata
get_namespaces get namespaces
get_rdf Extract rdf-xml from a NeXML file
get_taxa get_taxa
get_taxa_list get_taxa_list
get_trees extract a phylogenetic tree from the nexml
get_trees_list extract all phylogenetic trees in ape format
meta Constructor function for metadata nodes
nexml_add add elements to a new or existing nexml object
nexml_figshare publish nexml to figshare
nexml_get Get the desired element from the nexml object
nexml_publish publish nexml files to the web and receive a DOI
nexml_read Read NeXML files into various R formats
nexml_to_simmap nexml_to_simmap
nexml_validate validate nexml using the online validator tool
nexml_write Write nexml files
reset_id_counter reset id counter
simmap_ex A nexml class R object that includes simmap annotations
simmap_to_nexml simmap_to_nexml
taxize_nexml taxize nexml
toPhylo nexml to phylo

add_trees

> data("geospiza", package = "geiger")
> add_trees(geospiza$phy)
A nexml object representing:
      1 phylogenetic tree blocks, where: 
      block 1 contains 1 phylogenetic trees 
      3 meta elements 
      0 character matrices 
      14 taxonomic units 
 Taxa:      fuliginosa, fortis, magnirostris, conirostris, scandens, difficilis ... 

 NeXML generated by RNeXML using schema version: 0.9 
 size: 187.5 Kb

get_characters

> f <- system.file("examples", "comp_analysis.xml", package = "RNeXML")
> f %>% read.nexml() %>% get_characters()
         log snout-vent length reef-dwelling
taxon_8             -3.2777799             0
taxon_9              2.0959433             1
taxon_10             3.1373971             0
taxon_1              4.7532824             1
taxon_2             -2.7624146             0
taxon_3              2.1049413             0
taxon_4             -4.9504770             0
taxon_5              1.2714718             1
taxon_6              6.2593966             1
taxon_7              0.9099634             1

get_trees

nexmlから系統樹を引き出す

> comp_analysis <- system.file("examples", "comp_analysis.xml", package = "RNeXML")
> tree <- comp_analysis %>% nexml_read() %>% get_trees()
> tree

Phylogenetic tree with 10 tips and 9 internal nodes.

Tip labels:
    taxon_8, taxon_9, taxon_10, taxon_1, taxon_2, taxon_3, ...

Rooted; includes branch lengths.
> class(tree)
[1] "phylo"
> # plot(tree)

nexml_read

NeXMLフォーマットファイルの読み込み

> f <- system.file("examples", "trees.xml", package = "RNeXML")
> f %>% nexml_read() %>% {
+   print(.)
+   class(.)
+ }
A nexml object representing:
      1 phylogenetic tree blocks, where: 
      block 1 contains 2 phylogenetic trees 
      5 meta elements 
      0 character matrices 
      5 taxonomic units 
 Taxa:      species 1, species 2, species 3, species 4, species 5 ... 

 NeXML generated by RNeXML using schema version: 0.9 
 size: 142.9 Kb
[1] "nexml"
attr(,"package")
[1] "RNeXML"

nexml_to_simmap

> simmap_ex %>% nexml_to_simmap()

Phylogenetic tree with 18 tips and 17 internal nodes.

Tip labels:
    t1, t10, t11, t12, t13, t14, ...

Rooted; includes branch lengths.

nexml_validate

> data("bird.orders", package = "ape")
> birds <- nexml_write(bird.orders, "birds_orders.xml")
> nexml_validate("bird_orders.xml")
> # unlink("bird_orders.xml")

nexml_write

nexmlファイルの保存

Arguments

  • x
  • file
  • trees
  • characters
  • meta
  • ...
> data("bird.orders", package = "ape") # phylo class
> write.nexml(bird.orders, file="example.xml")

simmap_ex

> data("simmap_ex")
> simmap_ex %>% {
+   print(class(.))
+   str(., max.level = 2)
+ }
[1] "nexml"
attr(,"package")
[1] "RNeXML"
Formal class 'nexml' [package "RNeXML"] with 10 slots
  ..@ version           : chr "0.9"
  ..@ generator         : chr "RNeXML"
  ..@ xsi:schemaLocation: chr "http://www.nexml.org/2009/nexml.xsd"
  ..@ namespaces        : Named chr [1:13] "http://www.nexml.org/2009" "http://www.w3.org/2001/XMLSchema-instance" "http://www.w3.org/XML/1998/namespace" "http://www.evolutionaryontology.org/cdao/1.0/cdao.owl#" ...
  .. ..- attr(*, "names")= chr [1:13] "nex" "xsi" "xml" "cdao" ...
  ..@ otus              :Formal class 'ListOfotus' [package "RNeXML"] with 2 slots
  ..@ trees             :Formal class 'ListOftrees' [package "RNeXML"] with 2 slots
  ..@ characters        :Formal class 'ListOfcharacters' [package "RNeXML"] with 2 slots
  ..@ meta              :Formal class 'ListOfmeta' [package "RNeXML"] with 2 slots
  ..@ about             : chr(0) 
  ..@ xsi:type          : chr(0)

simmap_to_nexml

> simmap_ex %>% nexml_to_simmap() %>% simmap_to_nexml()

taxize_nexml

> data("bird.orders", package = "ape")
> bird.orders %>% add_trees() %>% taxize_nexml(., type = "NCBI")

Retrieving data for taxon 'Struthioniformes'


Retrieving data for taxon 'Tinamiformes'


Retrieving data for taxon 'Craciformes'


Retrieving data for taxon 'Galliformes'


Retrieving data for taxon 'Anseriformes'


Retrieving data for taxon 'Turniciformes'


Retrieving data for taxon 'Piciformes'


Retrieving data for taxon 'Galbuliformes'


Retrieving data for taxon 'Bucerotiformes'


Retrieving data for taxon 'Upupiformes'


Retrieving data for taxon 'Trogoniformes'


Retrieving data for taxon 'Coraciiformes'


Retrieving data for taxon 'Coliiformes'


Retrieving data for taxon 'Cuculiformes'


Retrieving data for taxon 'Psittaciformes'


Retrieving data for taxon 'Apodiformes'


Retrieving data for taxon 'Trochiliformes'


Retrieving data for taxon 'Musophagiformes'


Retrieving data for taxon 'Strigiformes'


Retrieving data for taxon 'Columbiformes'


Retrieving data for taxon 'Gruiformes'


Retrieving data for taxon 'Ciconiiformes'


Retrieving data for taxon 'Passeriformes'
A nexml object representing:
      1 phylogenetic tree blocks, where: 
      block 1 contains 1 phylogenetic trees 
      26 meta elements 
      0 character matrices 
      23 taxonomic units 
 Taxa:      Struthioniformes, Tinamiformes, Craciformes, Galliformes, Anseriformes, Turniciformes ... 

 NeXML generated by RNeXML using schema version: 0.9 
 size: 346.6 Kb