Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (103 sloc) 4.39 KB
---
title: "rphenoscape Intro"
author: "Hong Xu"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{rphenoscape Intro}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Most of the services provided with [Phenoscape Knowledgebase web API](http://kb.phenoscape.org/apidocs/) return data in JSON format, plain text (usually tab-delimited), and NeXML. This package facilitates the interfacing to the Phenoscape Knowledge for searching ontology terms, retrieving term info, and querying data matrices.
## Getting Started
The development version of rphenoscape is available on [Github](www.github.com/phenoscape/rphenoscape). With the `devtools` package installed on your system, rphenoscape can be installed using:
```{r compile-settings, include=FALSE}
## Set the paths for cache and figure
library(methods)
library(knitr)
opts_chunk$set(cache = 1)
basename <- gsub(".Rmd", "", knitr:::knit_concord$get('infile'))
opts_chunk$set(fig.path = paste("figure/", basename, "-", sep=""),
cache.path = paste("cache/", basename, "/", sep=""))
```
```{r, echo=FALSE}
library(knitr)
opts_knit$set(upload.fun = imgur_upload)
opts_chunk$set(tidy=FALSE, warning=FALSE, message=FALSE, comment = NA, verbose = TRUE)
```
```{r, eval = FALSE}
devtools::install_github("phenoscape/rphenoscape", build_opts=c("--no-manual"))
library(rphenoscape)
```
```{r, echo = FALSE}
library(rphenoscape)
```
The option `build_opts` ensures that the vignettes will be built and installed
as well. This will require a recent version of the knitr and rmarkdown
packages. You can install these beforehand, or include the option
`dependencies=TRUE`. The latter will also install packages otherwise only
needed for testing and for generating the help pages, which, if you don't
develop packages yourself, may be much more than you need.
## Character Matrix via Ontotrace
Use Ontotrace to obtain a character matrix for a taxonomic clade and anatomical region of interest.
The [Phenoscape Knowledgebase web API](http://kb.phenoscape.org/apidocs/#/OntoTrace/get_ontotrace) returns the evolutionary character matrix in NeXML format. The first step is to get the NeXML object using ```pk_get_ontotrace_xml``` method.
```{r}
nex <- pk_get_ontotrace_xml(taxon = c("Ictalurus", "Ameiurus"), entity = "fin spine")
```
Then retrieve wanted information from the NeXML object.
Get character matrix:
```{r}
(m <- pk_get_ontotrace(nex))
```
The character matrix can be integrated with other data, such as meta data which include taxon identifiers, character identifiers, etc.
Get meta data:
```{r}
(meta <- pk_get_ontotrace_meta(nex))
```
## Character Matrices for Studies
To obtain the character matrices for studies published for a taxonomic clade and anatomical region of interest.
First step is to retrieve the list of studies given a taxonomic clade and anatomical structures (returned as ```data.frame```).
```{r}
(slist <- pk_get_study_list(taxon = "Ictalurus australis", entity = "fin"))
```
Based off the study ids retained from previous step, get the evolutionary character matrix for each study id (in NeXML-format) using ```pk_get_study_xml```.
```{r}
(nex_list <- pk_get_study_xml(slist$id))
```
From the list of ReXML objects, retrieve the character matrices.
```{r}
study_matrix <- pk_get_study(nex_list)
study_matrix[[1]][1:5, 1:5]
```
Each character matrix can be integrated with other data, such as meta data which include taxon identifiers, character identifiers, etc.
Get meta data:
```{r}
study_metas <- pk_get_study_meta(nex_list)
study_metas[[1]]
```
## Obtain Other Data
### Subsetting a Matrix
A matrix obtained from Phenoscape can be subsetted (filtered) by taxonomic subgroup or anatomical part. For example, using ```pk_is_descendant``` and ```pk_is_ancestor``` methods, a matrix can be subsetted to a taxonomic subgroup that is the descendants/ancestors of a given taxon.
```{r}
m # original character matrix
(is_desc <- pk_is_descendant('Ictalurus', m$taxa))
m[is_desc, ] #subsetting to the descendants of Ictalurus
```
### Term Search
Search for details for a given taxon:
```{r}
pk_taxon_detail("Coralliozetus")
```
Search for details for a given anatomical structure:
```{r}
pk_anatomical_detail("basihyal bone")
```
#### Miscellaneous methods:
Resolve a given term to its IRI:
```{r}
pk_get_iri("Coralliozetus", "vto")
pk_get_iri("basihyal bone", "uberon")
```
Test if a taxon is extinct:
```{r}
pk_is_extinct("Fisherichthys")
```