-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
272 lines (194 loc) · 12.4 KB
/
README.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
---
output: rmarkdown::github_document
always_allow_html: true
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "",
fig.path = "inst/extdata/"
)
```
```{r, out.width = '100%', echo = FALSE, eval = FALSE}
knitr::include_graphics("https://raw.githubusercontent.com/aravind-j/PGRdup/master/inst/extdata/PGRdup.png")
```
<img src="https://raw.githubusercontent.com/aravind-j/PGRdup/master/inst/extdata/PGRdup.png" align="center" alt="logo" width="750" height = "85" style = "border: solid white 10px;">
```{r,echo = FALSE, message = FALSE}
devtools::load_all(".", quiet = TRUE) # quiet = T for hiding macOS compiler warnings
```
###### Version : [`r getNamespaceVersion("PGRdup")`](https://aravind-j.github.io/PGRdup/articles/Introduction.html#version-history); Copyright (C) 2014-`r format(Sys.Date(), "%Y")`: [ICAR-NBPGR](http://www.nbpgr.ernet.in/); License: [GPL-2|GPL-3](https://www.r-project.org/Licenses/)
##### *Aravind, J.^1^, Radhamani, J.^1^, Kalyani Srinivasan^1^, Ananda Subhash, B.^2^, and Tyagi, R. K.^1^*
1. ICAR-National Bureau of Plant Genetic Resources, New Delhi, India
2. Centre for Development of Advanced Computing, Thiruvananthapuram, Kerala, India
***
[![minimal R version](https://img.shields.io/badge/R>%3D-3.0.2-6666ff.svg?logo=R)](https://cran.r-project.org/)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version-last-release/PGRdup)](https://cran.r-project.org/package=PGRdup)
[![Dependencies](https://tinyverse.netlify.com/badge/PGRdup)](https://cran.r-project.org/package=PGRdup)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/grand-total/PGRdup?color=green)](https://CRAN.R-project.org/package=PGRdup)
```{r, results='asis', echo=FALSE}
dver <- ifelse(test = gsub("(.\\.)(\\d+)(\\..)", "", getNamespaceVersion("PGRdup")) != "",
yes = getNamespaceVersion("PGRdup"),
no = gsub("Version:\\s*", "", readLines(paste0("https://raw.githubusercontent.com/", "aravind-j/PGRdup", "/master/DESCRIPTION"))[grep("Version:", readLines(paste0("https://raw.githubusercontent.com/", "aravind-j/PGRdup", "/master/DESCRIPTION")))]))
cat(paste("[![develVersion](https://img.shields.io/badge/devel%20version-", dver, "-orange.svg)](https://github.com/aravind-j/PGRdup)", sep = ""))
```
[![Github Code Size](https://img.shields.io/github/languages/code-size/aravind-j/PGRdup.svg)](https://github.com/aravind-j/PGRdup)
[![R-CMD-check](https://github.com/aravind-j/PGRdup/workflows/R-CMD-check/badge.svg)](https://github.com/aravind-j/PGRdup/actions)
[![Project Status: Inactive](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](https://github.com/aravind-j/PGRdup)
[![Rdoc](https://api.rdocumentation.org/badges/version/PGRdup)](https://rdocumentation.org/packages/PGRdup/)
[![Zenodo DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.841963.svg)](https://doi.org/10.5281/zenodo.841963)
[![Website - pkgdown](https://img.shields.io/website-up-down-green-red/https/aravind-j.github.io/PGRdup.svg)](https://aravind-j.github.io/PGRdup/)
[![.](https://pro-pulsar-193905.appspot.com/UA-112827210-2/welcome-page)](https://github.com/aravind-j/google-analytics-beacon)
<!-- [![packageversion](https://img.shields.io/badge/Package%20version-0.2.3.3-orange.svg)](https://github.com/aravind-j/PGRdup) -->
<!-- [![GitHub Download Count](https://github-basic-badges.herokuapp.com/downloads/aravind-j/PGRdup/total.svg)] -->
***
## Introduction <img src="https://raw.githubusercontent.com/aravind-j/PGRdup/master/inst/extdata/PGRdup_v2.png" align="right" alt="logo" width="173" height = "200" style = "padding: 10px; border: none; float: right;">
The `R` package `PGRdup` was developed as a tool to aid genebank managers in the identification of probable duplicate accessions from plant genetic resources (PGR) passport databases.
This package primarily implements a workflow designed to fetch groups or sets of germplasm accessions with similar passport data particularly in fields associated with accession names within or across PGR passport databases.
The functions in this package are primarily built using the following R packages:
* [`data.table`](https://cran.r-project.org/package=data.table)
* [`igraph`](https://cran.r-project.org/package=igraph)
* [`stringdist`](https://cran.r-project.org/package=stringdist)
* [`stringi`](https://cran.r-project.org/package=stringi)
## Installation
The package can be installed from CRAN as follows:
```{r, eval=FALSE}
# Install from CRAN
install.packages('PGRdup', dependencies=TRUE)
The development version can be installed from github as follows:
# Install development version from Github
devtools::install_github("aravind-j/PGRdup")
```
## Workflow
The series of steps involve in the workflow along with the associated functions are are illustrated below:
#### Step 1
**Function(s) :**
* `DataClean`
* `MergeKW`
* `MergePrefix`
* `MergeSuffix`
Use these functions for the appropriate data standardisation of the relevant fields in the passport databases to harmonize punctuation, leading zeros, prefixes, suffixes etc. associated with accession names.
#### Step 2
**Function(s) :**
* `KWIC`
Use this function to extract the information in the relevant fields as keywords or text strings in the form of a searchable Keyword in Context (KWIC) index.
#### Step 3
**Function(s) :**
* `ProbDup`
Execute fuzzy, phonetic and semantic matching of keywords to identify probable duplicate sets either within a single KWIC index or between two indexes using this function. For fuzzy matching the levenshtein edit distance is used, while for phonetic matching, the double metaphone algorithm is used. For semantic matching, synonym sets or 'synsets' of accession names can be supplied as an input and the text strings in such sets will be treated as being identical for matching. Various options to tweak the matching strategies used are also available in this function.
#### Step 4
**Function(s) :**
* `DisProbDup`
* `ReviewProbDup`
* `ReconstructProbDup`
Inspect, revise and improve the retrieved sets using these functions. If considerable intersections exist between the initially identified sets, then `DisProbDup` may be used to get the disjoint sets. The identified sets may be subjected to clerical review after transforming them into an appropriate spreadsheet format which contains the raw data from the original database(s) using `ReviewProbDup` and subsequently converted back using `ReconstructProbDup`.
#### Adjuncts
**Function(s) :**
* `ValidatePrimKey`
* `DoubleMetaphone`
* `ParseProbDup`
* `AddProbDup`
* `SplitProbDup`
* `MergeProbDup`
* `ViewProbDup`
* `KWCounts`
* `read.genesys`
Use these helper functions if needed. `ValidatePrimKey` can be used to check whether a column chosen in a data.frame as the primary primary key/ID confirms to the constraints of absence of duplicates and NULL values.
`DoubleMetaphone` is an implementation of the Double Metaphone phonetic algorithm in `R` and is used for phonetic matching.
`ParseProbDup` and `AddProbDup` work with objects of class `ProbDup`. The former can be used to parse the probable duplicate sets in a `ProbDup` object to a `data.frame` while the latter can be used to add these sets data fields to the passport databases. `SplitProbDup` can be used to split an object of class `ProbDup` according to set counts. `MergeProbDup` can be used to merge together two objects of class `ProbDup`. `ViewProbDup` can be used to plot the summary visualizations of probable duplicate sets retrieved in an object of class `ProbDup`.
`KWCounts` can be used to compute keyword counts from PGR passport database fields(columns), which can give a rough indication of the completeness of the data.
`read.genesys` can be used to import PGR data in a Darwin Core - germplasm zip archive downloaded from genesys database into the R environment.
## Tips
* Use [`fread`](https://rdrr.io/cran/data.table/man/fread.html) to rapidly read large files instead of `read.csv` or `read.table` in `base`.
* In case the PGR passport data is in any DBMS, use the appropriate [`R`-database interface packages](https://www.burns-stat.com/r-database-interfaces/) to get the required table as a `data.frame` in `R`.
## Note
* The `ProbDup` function can be memory hungry with large passport databases. In such cases, ensure that the system has sufficient memory for smooth functioning (See `?ProbDup`).
## Detailed tutorial
For a detailed tutorial (vignette) on how to used this package type:
```{r, eval=FALSE}
browseVignettes(package = 'PGRdup')
```
The vignette for the latest version is also available [online](https://aravind-j.github.io/PGRdup/articles/Introduction.html).
## What's new
To know whats new in this version type:
```{r, eval=FALSE}
news(package='PGRdup')
```
## Links
[CRAN page](https://cran.r-project.org/package=PGRdup)
[Github page](https://github.com/aravind-j/PGRdup)
[Documentation website](https://aravind-j.github.io/PGRdup/)
[Zenodo DOI](https://doi.org/10.5281/zenodo.841963)
## CRAN checks
```{r, echo = FALSE}
pkgname <- "PGRdup"
osdf <-
rbind(data.frame(OS = "Linux",
Flavour = c("r-devel-linux-x86_64-debian-clang",
"r-devel-linux-x86_64-debian-gcc",
"r-devel-linux-x86_64-fedora-clang",
"r-devel-linux-x86_64-fedora-gcc",
"r-patched-linux-x86_64",
"r-release-linux-x86_64")),
# data.frame(OS = "Solaris",
# Flavour = c("r-patched-solaris-x86")),
data.frame(OS = "Windows",
Flavour = c("r-devel-windows-x86_64",
"r-release-windows-x86_64",
"r-oldrel-windows-x86_64")),
data.frame(OS = "macOS",
Flavour = c("r-release-macos-x86_64",
# "r-release-macos-arm64",
# "r-oldrel-macos-arm64",
"r-oldrel-macos-x86_64")))
chkurl <- paste("https://cran.r-project.org/web/checks/check_results_",
pkgname, ".html", sep = "")
library(RCurl)
if (url.exists(chkurl)) {
chklink <- paste("(", chkurl, ")", sep = "")
} else {
chklink <- "(https://cran.r-project.org/web/checks/check_results_j.aravind_at_icar.gov.in.html)"
}
osdf$`CRAN check` <- paste("[![CRAN check - ", osdf$Flavour, "]",
"(https://badges.cranchecks.info/flavor/",
osdf$Flavour, "/", pkgname, ".svg)]",
chklink,
sep = "")
```
```{r, echo = FALSE, results='asis'}
cat("[![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)](https://cran.r-project.org/web/checks/check_results_germinationmetrics.html)", "\n")
knitr::kable(osdf[osdf$OS == "Linux", c(2, 3)], format = "simple",
col.names = c("", ""),
row.names = FALSE)
cat("[![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white)](https://cran.r-project.org/web/checks/check_results_germinationmetrics.html)", "\n")
knitr::kable(osdf[osdf$OS == "Windows", c(2, 3)], format = "simple",
col.names = c("", ""),
row.names = FALSE)
cat("[![MacOS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white)](https://cran.r-project.org/web/checks/check_results_germinationmetrics.html)", "\n")
knitr::kable(osdf[osdf$OS == "macOS", c(2, 3)], format = "simple",
col.names = c("", ""),
row.names = FALSE)
cat("\n")
```
## Citing `PGRdup`
To cite the methods in the package use:
```{r, eval = FALSE}
citation("PGRdup")
```
```{r, echo = FALSE}
detach("package:PGRdup", unload=TRUE)
suppressPackageStartupMessages(library(PGRdup))
cit <- citation("PGRdup")
# yr <- format(Sys.Date(), "%Y")
# cit[1]$year <- yr
# oc <- class(cit)
#
# cit <- unclass(cit)
# attr(cit[[1]],"textVersion") <- gsub("\\(\\)",
# paste("\\(", yr, "\\)", sep = ""),
# attr(cit[[1]],"textVersion"))
# class(cit) <- oc
cit
```