Skip to content

Commit

Permalink
Merge pull request #288 from phenoscape/ci-fixes
Browse files Browse the repository at this point in the history
Changes to address R CMD check and CI issues
  • Loading branch information
hlapp authored Oct 30, 2024
2 parents 100a89c + 80c83d2 commit 3bf7fcf
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 52 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cache
vignettes/cache
^docs$
^_pkgdown\.yml$
LICENSE.md

^\.github$
^\.circleci$
26 changes: 0 additions & 26 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,28 +1,2 @@
YEAR: 2015
COPYRIGHT HOLDER: Hong Xu

The MIT License (MIT)

Copyright (c) 2015 Hong Xu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.




21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Hong Xu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RPhenoscape: Semantically rich phenotypic traits from the Phenoscape Knowledgebase

[![Build
Status](https://circleci.com/gh/phenoscape/rphenoscape.svg?style=svg)](https://circleci.com/gh/phenoscape/rphenoscape)
Status](https://circleci.com/gh/phenoscape/rphenoscape.svg?style=svg)](https://app.circleci.com/pipelines/github/phenoscape/rphenoscape)

- Author: Hong Xu, Hilmar Lapp, John Bradley
- Maintainer: Hilmar Lapp
Expand Down Expand Up @@ -96,8 +96,7 @@ Knowledgebase API](https://kb.phenoscape.org/api/v2/docs/). The base URL
path to the API endpoints can changed from the default by setting the
`PHENOSCAPE_API` environment variable. (See [R
Startup](https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html)
and [RStudio support on
.Renviron](https://support.rstudio.com/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf)
and [.Renviron](https://bookdown.org/csgillespie/efficientR/set-up.html#renviron)
on how to control environment variables at R session startup.)

------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions README.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ output:
<!-- README.md is generated from README.rmd. Please edit that file -->
# RPhenoscape: Semantically rich phenotypic traits from the Phenoscape Knowledgebase

[![Build Status](https://circleci.com/gh/phenoscape/rphenoscape.svg?style=svg)](https://circleci.com/gh/phenoscape/rphenoscape)
[![Build Status](https://circleci.com/gh/phenoscape/rphenoscape.svg?style=svg)](https://app.circleci.com/pipelines/github/phenoscape/rphenoscape)

- Author: Hong Xu, Hilmar Lapp, John Bradley
- Maintainer: Hilmar Lapp
Expand Down Expand Up @@ -76,7 +76,7 @@ The functionality and operations of the RPhenoscape package can be viewed on the
- Subsetting matrices by taxonomic subgroup or anatomical part
- Searching for details for a given taxon

By definition, most functions in this package connect to the [Phenoscape Knowledgebase API]. The base URL path to the API endpoints can changed from the default by setting the `PHENOSCAPE_API` environment variable. (See [R Startup] and [RStudio support on .Renviron] on how to control environment variables at R session startup.)
By definition, most functions in this package connect to the [Phenoscape Knowledgebase API]. The base URL path to the API endpoints can changed from the default by setting the `PHENOSCAPE_API` environment variable. (See [R Startup] and [.Renviron] on how to control environment variables at R session startup.)

---
[![Phenoscape Knowledgebase](https://wiki.phenoscape.org/wg/phenoscape/images/f/f6/Phenoscape_Logo.png)](http://kb.phenoscape.org)
Expand All @@ -85,4 +85,4 @@ By definition, most functions in this package connect to the [Phenoscape Knowled
[CRAN]: https://cran.r-project.org
[Phenoscape Knowledgebase API]: https://kb.phenoscape.org/api/v2/docs/
[R Startup]: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html
[RStudio support on .Renviron]: https://support.rstudio.com/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf
[.Renviron]: https://bookdown.org/csgillespie/efficientR/set-up.html#renviron
12 changes: 11 additions & 1 deletion man/get_term_iri.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/terms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 31 additions & 18 deletions vignettes/rphenoscape.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ vignette: >

Most of the services provided with the [Phenoscape Knowledgebase (KB) API](https://kb.phenoscape.org/api/v2/docs/) return data in JSON format, plain text (usually tab-delimited), and NeXML. This package facilitates interfacing with the Phenoscape Knowledgebase for searching ontology terms, retrieving term info, and querying data matrices.


```{r compile-settings, include=FALSE}
## Set the paths for cache and figure
library(knitr)
Expand All @@ -22,70 +21,84 @@ opts_chunk$set(tidy=FALSE, warning=FALSE, message=FALSE, comment = NA, verbose =

## Installation

The development version of RPhenoscape is available on [Github](http://www.github.com/phenoscape/rphenoscape). It has not yet been released to [CRAN]. To install RPhenoscape from Github, use the `install_github()` function in the `remotes` package (which can be installed from CRAN using `install.packages()`). See the [package README](https://rphenoscape.phenoscape.org) for details.
The development version of RPhenoscape is available on [Github](https://github.com/phenoscape/rphenoscape). It has not yet been released to [CRAN]. To install RPhenoscape from Github, use the `install_github()` function in the `remotes` package (which can be installed from CRAN using `install.packages()`). See the [package README](https://rphenoscape.phenoscape.org) for details.

Once installed, the package can be loaded ("attached") as any other R package:

```{r}
library(rphenoscape)
```

## Character Matrix via OntoTrace
Use OntoTrace to obtain a character matrix of inferred and author-asserted presence/absence associations for a taxonomic clade and anatomical region of interest.

The [ontotrace endpoint in the Phenoscape KB API](https://kb.phenoscape.org/api/v2/docs/#/OntoTrace/get_ontotrace) returns the presence/absence character matrix in NeXML format. The first step is to get the NeXML object using ```get_ontotrace_data``` method.
Use OntoTrace to obtain a character matrix of inferred and author-asserted presence/absence associations for a taxonomic clade and anatomical region of interest.

The [ontotrace endpoint in the Phenoscape KB API](https://kb.phenoscape.org/api/v2/docs/#/OntoTrace/get_ontotrace) returns the presence/absence character matrix in NeXML format. The first step is to get the NeXML object using `get_ontotrace_data` method.

```{r}
nex <- get_ontotrace_data(taxon = c("Ictalurus", "Ameiurus"), entity = "fin spine")
```

The result is an object of class `nexml` defined in the RNeXML package. The object mirrors the structure of a NeXML file, and can be inspected accordingly. Note that although generically NeXML files can contain multiple OTUs blocks and multiple characters blocks, NeXML files generated by the KB's OntoTrace API contain only one. This means we can, for example, inspect the number of taxa and characters as follows:

```{r}
# number of taxa in the first (and only) OTUs block
length(nex@otus[[1]]@otu)
# number of characters in the first (and only) characters block
length(nex@characters[[1]]@format@char)
```

More details on the [`nexml` object] can be found in the [RNeXML documentation].
More details on the [`nexml` object](https://docs.ropensci.org/RNeXML/reference/nexml-class.html) can be found in the [RNeXML documentation](https://docs.ropensci.org/RNeXML/).

Then retrieve wanted information from the NeXML object.
Then retrieve wanted information from the NeXML object.
Get character matrix:

```{r}
(m <- get_char_matrix(nex))
```
The character matrix can be integrated with other data, such as meta data which include taxon identifiers, character identifiers, etc.
Get meta data:

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 <- get_char_matrix_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```).
First step is to retrieve the list of studies given a taxonomic clade and anatomical structures (returned as `data.frame`).

```{r}
(slist <- get_studies(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 ```get_study_data```.
Based off the study ids retained from previous step, get the evolutionary character matrix for each study id (in NeXML-format) using `get_study_data`.

```{r}
(nex_list <- get_study_data(slist$id))
```

From the list of NeXML objects, retrieve the character matrices.

```{r}
study_matrix <- lapply(nex_list, function(nex) get_char_matrix(nex, otus_id = FALSE, states_as_labels = TRUE))
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:
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 <- lapply(nex_list, function(nex) get_char_matrix_meta(nex))
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 ```is_descendant``` and ```is_ancestor``` methods, a matrix can be subsetted to a taxonomic subgroup that is the descendants/ancestors of a given taxon.

A matrix obtained from Phenoscape can be subsetted (filtered) by taxonomic subgroup or anatomical part. For example, using `is_descendant` and `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 <- is_descendant('Ictalurus', m$taxa))
Expand All @@ -95,28 +108,28 @@ m[is_desc, ] #subsetting to the descendants of Ictalurus
### Term Search

Search for details for a given taxon:

```{r}
taxon_info("Coralliozetus")
```

Search for details for a given anatomical structure:

```{r}
anatomy_term_info("basihyal bone")
```


#### Miscellaneous methods:

Resolve a given term to its IRI:

```{r}
get_term_iri("Coralliozetus", "vto")
get_term_iri("basihyal bone", "uberon")
```

Test if a taxon is extinct:

```{r}
is_extinct("Fisherichthys")
```

[`nexml` object]: https://docs.ropensci.org/RNeXML/reference/nexml-class.html
[RNeXML documentation]: https://docs.ropensci.org/RNeXML

0 comments on commit 3bf7fcf

Please sign in to comment.