Skip to content

Commit 6b6b49d

Browse files
authored
Things that CRAN wants. (#135)
1 parent 8491608 commit 6b6b49d

11 files changed

+121
-41
lines changed

docs/packages/airr-R/topics.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Reference Topics
1212
topics/validate_airr
1313
topics/load_schema
1414
topics/Schema-class
15+
topics/ExampleData
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ExampleData
2+
-----------
3+
4+
**Example AIRR data**
5+
6+
Description
7+
~~~~~~~~~~~
8+
9+
Example data files compliant with the the AIRR Data Representation
10+
standards.
11+
12+
Format
13+
~~~~~~
14+
15+
``extdata/rearrangement-example.tsv.gz``: Rearrangement TSV file.
16+
17+
Examples
18+
~~~~~~~~
19+
20+
.. code:: r
21+
22+
# Get path to the rearrangement-example file
23+
file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
24+
25+
# Load data file
26+
df <- read_rearrangement(file)

docs/packages/airr-R/topics/load_schema.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ Examples
4848

4949
.. code:: r
5050
51-
# Load the rearrangement definition
51+
# Load the Rearrangement definition
5252
schema <- load_schema("Rearrangement")
5353
54+
# Load the Alignment definition
55+
schema <- load_schema("Alignment")
56+
5457
See also
5558
~~~~~~~~
5659

docs/packages/airr-R/topics/read_airr.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ Examples
5858

5959
.. code:: r
6060
61-
### Not run:
62-
# Read a Rearrangement TSV file with default options
63-
# df <- read_rearrangement("file.tsv")
61+
# Get path to the rearrangement-example file
62+
file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
63+
64+
# Load data file
65+
df <- read_rearrangement(file)
6466
6567
See also
6668
~~~~~~~~

docs/packages/airr-R/topics/validate_airr.rst

+17-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ Examples
3535

3636
.. code:: r
3737
38-
### Not run:
38+
# Get path to the rearrangement-example file
39+
file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
40+
41+
# Load data file
42+
df <- read_rearrangement(file)
43+
3944
# Validate a data.frame against the Rearrangement schema
40-
# validate_airr(data, schema=RearrangementSchema)
45+
validate_airr(data, schema=RearrangementSchema)
46+
47+
*Warning*:Warning: File is missing AIRR mandatory field(s): sequence_id,
48+
sequence, rev_comp, productive, v_call, d_call, j_call,
49+
sequence_alignment, germline_alignment, junction, junction_aa, v_cigar,
50+
d_cigar, j_cigar
51+
52+
::
53+
54+
[1] FALSE
55+

docs/packages/airr-R/topics/write_airr.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ Examples
5757

5858
.. code:: r
5959
60-
### Not run:
60+
# Get path to the rearrangement-example file
61+
file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
62+
63+
# Load data file
64+
df <- read_rearrangement(file)
65+
6166
# Write a Rearrangement data file
62-
# write_rearrangement(data, "file.tsv")
67+
outfile <- file.path(tempdir(), "output.tsv")
68+
write_rearrangement(df, outfile)
6369
6470
See also
6571
~~~~~~~~

docs/packages/airr-R/vignettes/Usage-Vignette.rst

+16-19
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ intervals (R style) using the default setting of ``base="0"``. If
6161
6262
library(airr)
6363
64-
example_data <- file.path("..", "tests", "data-tests", "toy_data.tsv")
64+
example_data <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
6565
basename(example_data)
6666
6767
::
6868

69-
## [1] "toy_data.tsv"
69+
## [1] "rearrangement-example.tsv.gz"
7070

7171
.. code:: r
7272
@@ -83,27 +83,24 @@ intervals (R style) using the default setting of ``base="0"``. If
8383
8484
::
8585

86-
## # A tibble: 6 x 44
87-
## rearrangement_id rearrangement_se… sequence_id sequence rev_comp
88-
## <chr> <chr> <chr> <chr> <lgl>
89-
## 1 IVKNQEJ01BVGQ6 1 IVKNQEJ01B… GGCCCAGGACTGGTG… TRUE
90-
## 2 IVKNQEJ01AQVWS 1 IVKNQEJ01A… GGCCCAGGACTGGTG… TRUE
91-
## 3 IVKNQEJ01AOYFZ 1 IVKNQEJ01A… GGCCCAGGACTGGTG… TRUE
92-
## 4 IVKNQEJ01EI5S4 1 IVKNQEJ01E… GGCCCAGGACTGGTG… TRUE
93-
## 5 IVKNQEJ01DGRRI 1 IVKNQEJ01D… GGCCCAGGACTGGTG… TRUE
94-
## 6 IVKNQEJ01APN5N 1 IVKNQEJ01A… GGCCCAGGACTGGTG… TRUE
95-
## # ... with 39 more variables: productive <lgl>, sequence_alignment <chr>,
96-
## # germline_alignment <chr>, v_call <chr>, d_call <chr>, j_call <chr>,
97-
## # c_call <chr>, junction <chr>, junction_length <int>,
98-
## # junction_aa <chr>, v_score <dbl>, d_score <dbl>, j_score <dbl>,
99-
## # c_score <dbl>, v_cigar <chr>, d_cigar <chr>, j_cigar <chr>,
100-
## # c_cigar <chr>, v_identity <dbl>, v_evalue <dbl>, d_identity <dbl>,
101-
## # d_evalue <dbl>, j_identity <dbl>, j_evalue <dbl>,
86+
## # A tibble: 6 x 33
87+
## sequence_id sequence rev_comp productive stop_codon vj_in_frame v_call
88+
## <chr> <chr> <lgl> <lgl> <lgl> <lgl> <chr>
89+
## 1 SRR765688.7… NNNNNNNN… FALSE TRUE FALSE TRUE IGHV2…
90+
## 2 SRR765688.3… NNNNNNNN… FALSE TRUE FALSE TRUE IGHV5…
91+
## 3 SRR765688.3… NNNNNNNN… FALSE TRUE FALSE TRUE IGHV7…
92+
## 4 SRR765688.3… NNNNNNNN… FALSE TRUE FALSE TRUE IGHV7…
93+
## 5 SRR765688.4… NNNNNNNN… FALSE TRUE FALSE TRUE IGHV7…
94+
## 6 SRR765688.1… NNNNNNNN… FALSE FALSE TRUE TRUE IGHV2…
95+
## # ... with 26 more variables: d_call <chr>, j_call <chr>, c_call <chr>,
96+
## # sequence_alignment <chr>, germline_alignment <chr>, junction <chr>,
97+
## # junction_aa <chr>, v_cigar <chr>, d_cigar <chr>, j_cigar <chr>,
98+
## # junction_length <int>, np1_length <int>, np2_length <int>,
10299
## # v_sequence_start <dbl>, v_sequence_end <int>, v_germline_start <dbl>,
103100
## # v_germline_end <int>, d_sequence_start <dbl>, d_sequence_end <int>,
104101
## # d_germline_start <dbl>, d_germline_end <int>, j_sequence_start <dbl>,
105102
## # j_sequence_end <int>, j_germline_start <dbl>, j_germline_end <int>,
106-
## # np1_length <int>, np2_length <int>, duplicate_count <int>
103+
## # duplicate_count <int>
107104

108105
Writing AIRR formatted files
109106
----------------------------

lang/R/R/Interface.R

+22-12
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
#' See \link{write_airr} for writing AIRR data.
2222
#'
2323
#' @examples
24-
#' \dontrun{
25-
#' # Read a Rearrangement TSV file with default options
26-
#' df <- read_rearrangement("file.tsv")
27-
#' }
24+
#' # Get path to the rearrangement-example file
25+
#' file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
26+
#'
27+
#' # Load data file
28+
#' df <- read_rearrangement(file)
2829
#'
2930
#' @export
3031
read_airr <- function(file, base=c("0", "1"), schema=RearrangementSchema, ...) {
@@ -68,10 +69,14 @@ read_airr <- function(file, base=c("0", "1"), schema=RearrangementSchema, ...) {
6869
#' \code{FALSE} if not.
6970
#'
7071
#' @examples
71-
#' \dontrun{
72-
#' # Validate a data.frame against the Rearrangement schema
73-
#' validate_airr(data, schema=RearrangementSchema)
74-
#' }
72+
#' # Get path to the rearrangement-example file
73+
#' file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
74+
#'
75+
#' # Load data file
76+
#' df <- read_rearrangement(file)
77+
#'
78+
#' # Validate a data.frame against the Rearrangement schema
79+
#' validate_airr(data, schema=RearrangementSchema)
7580
#'
7681
#' @export
7782
validate_airr <- function(data, schema=RearrangementSchema){
@@ -167,10 +172,15 @@ read_alignment <- function(file, base=c("0", "1"), ...) {
167172
#' See \link{read_airr} for reading to AIRR files.
168173
#'
169174
#' @examples
170-
#' \dontrun{
171-
#' # Write a Rearrangement data file
172-
#' write_rearrangement(data, "file.tsv")
173-
#' }
175+
#' # Get path to the rearrangement-example file
176+
#' file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
177+
#'
178+
#' # Load data file
179+
#' df <- read_rearrangement(file)
180+
#'
181+
#' # Write a Rearrangement data file
182+
#' outfile <- file.path(tempdir(), "output.tsv")
183+
#' write_rearrangement(df, outfile)
174184
#'
175185
#' @export
176186
write_airr <- function(data, file, base=c("0", "1"), schema=RearrangementSchema, ...) {

lang/R/R/Schema.R

+21-1
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ setMethod("$",
8888
#' @seealso See \link{Schema} for the return object.
8989
#'
9090
#' @examples
91-
#' # Load the rearrangement definition
91+
#' # Load the Rearrangement definition
9292
#' schema <- load_schema("Rearrangement")
9393
#'
94+
#' # Load the Alignment definition
95+
#' schema <- load_schema("Alignment")
96+
#'
9497
#' @export
9598
load_schema <- function(definition) {
9699
# Load schema from yaml file
@@ -123,6 +126,23 @@ load_schema <- function(definition) {
123126

124127
#### Data ####
125128

129+
#' Example AIRR data
130+
#'
131+
#' Example data files compliant with the the AIRR Data Representation standards.
132+
#'
133+
#' @format
134+
#' \code{extdata/rearrangement-example.tsv.gz}: Rearrangement TSV file.
135+
#'
136+
#' @examples
137+
#' # Get path to the rearrangement-example file
138+
#' file <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
139+
#'
140+
#' # Load data file
141+
#' df <- read_rearrangement(file)
142+
#'
143+
#' @name ExampleData
144+
NULL
145+
126146
#' @details \code{AlignmentSchema}: AIRR Alignment \code{Schema}.
127147
#' @rdname Schema-class
128148
#' @export
19.8 KB
Binary file not shown.

lang/R/vignettes/Usage-Vignette.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ If `base="1"` is specified, then positional fields will not be modified.
8181
```{r read_rearrangement, message=FALSE}
8282
library(airr)
8383
84-
example_data <- file.path("..", "tests", "data-tests", "toy_data.tsv")
84+
example_data <- system.file("extdata", "rearrangement-example.tsv.gz", package="airr")
8585
basename(example_data)
8686
airr_rearrangement <- read_rearrangement(example_data, base="0")
8787
class(airr_rearrangement)

0 commit comments

Comments
 (0)