-
Notifications
You must be signed in to change notification settings - Fork 0
/
rphg_walkthrough.Rmd
147 lines (114 loc) · 3.33 KB
/
rphg_walkthrough.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: "Introduction to rPHG"
output:
BiocStyle::html_document:
toc: false
fig_caption: true
toc_float: true
number_sections: false
vignette: >
%\VignetteIndexEntry{Introduction to rPHG}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
%\usepackage[utf8]{inputenc}
%\usepackage{float}
editor_options:
markdown:
wrap: 70
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
fig.path = "figure/graphics-",
cache.path = "cache/graphics-",
fig.align = "center",
external = TRUE,
echo = TRUE,
warning = FALSE
)
library(rPHG)
logFile <- tempfile(fileext = ".txt")
configFile <- tempfile()
rPHG:::createConfigFile(configFile)
```
The basic workflow of the `rPHG` package is as follows:
1. Create a connection object
2. Select a PHG "method"
3. Read data into the R environment
4. Analyze and visualize data retrieval
This document introduces you to `rPHG`'s methods and grammar, and
shows you how to apply them to the previously mentioned workflow.
## Creating connection objects
PHG databases can be connected through two primary sources:
- local
- server
Local connections are for databases set up to use PostgreSQL or SQLite
management systems, typically located either on a local machine or
hosted on a high performance compute cluster which are accessed via
the PHG API.
Conversely, server connections are for databases served on publicly
available web services leveraging Breeding API (BrAPI) endpoints for
data retrieval. For example,
[demo.hub.maizegenetics.net](demo.hub.maizegenetics.net) is a publicly
available PHG database housing information many known diversity
populations in maize.
### Establishing a local connection
To set up a local connection, prior knowledge about how configuration
files are set up is needed. If you would like more information about
this topic, please see the vignette "[Overview of configuration
files](rphg_config_files.html)"
We can supply a path to a valid configuration file to the constructor,
`PHGLocalCon()`:
```{r, echo=TRUE, eval=TRUE}
configFile |> PHGLocalCon()
```
Here, our configuration file path (`configFilePath`) is parsed to
create an object of type `PHGLocalCon`.
### Establishing a server connection
If you would like to use a PHG web service, we can use the following
similar method:
```{r, echo=TRUE, eval=TRUE}
"phg.maizegdb.org" |> PHGServerCon()
```
Here, a URL pointing to a PHG web service is supplied to the
constructor `PHGServerCon()` which will be parsed to create an object
of type `PHGServerCon`.
## PHG Methods
```{r, echo=TRUE, eval=TRUE}
configFile |>
PHGLocalCon() |>
showPHGMethods()
```
```{r, echo=TRUE, eval=TRUE}
configFile |>
PHGLocalCon() |>
PHGMethod("PATH_METHOD")
```
## Reading data
### Read samples (e.g. taxa)
```{r, echo=TRUE, eval=TRUE}
configFile |>
PHGLocalCon() |>
PHGMethod("PATH_METHOD") |>
readSamples()
```
### Read reference ranges
```{r, echo=TRUE, eval=TRUE}
configFile |>
PHGLocalCon() |>
PHGMethod("PATH_METHOD") |>
readRefRanges()
```
### Read haplotype ID matrix
```{r, echo=TRUE, eval=TRUE}
configFile |>
PHGLocalCon() |>
PHGMethod("PATH_METHOD") |>
readHaplotypeIds()
```
## `PHGDataSet` objects
```{r, echo=TRUE, eval=TRUE, message=FALSE}
configFile |>
PHGLocalCon() |>
PHGMethod("PATH_METHOD") |>
readPHGDataSet()
```