Skip to content

Commit 2af189d

Browse files
Prepping for release (#47)
* Prepping for release * Polish for different platfroms #40 * Tests
1 parent aa49361 commit 2af189d

26 files changed

Lines changed: 797 additions & 320 deletions

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
## Overview
44

5-
Tskit enables performant storage, manipulation, and analysis of ancestral
5+
`Tskit` enables performant storage, manipulation, and analysis of ancestral
66
recombination graphs (ARGs) using succinct tree sequence encoding.
77
See https://tskit.dev for project news, documentation, and tutorials.
8-
Tskit provides Python, C, and Rust APIs. The Python API can be called from R
9-
via the `reticulate` R package to seamlessly load and analyse a tree sequence,
10-
as described at https://tskit.dev/tutorials/RcppTskit.html.
8+
`Tskit` provides Python, C, and Rust application programming interfaces (APIs).
9+
The Python API can be called from R via the `reticulate` R package to
10+
seamlessly load and analyse a tree sequence, as described at
11+
https://tskit.dev/tutorials/RcppTskit.html.
1112
`RcppTskit` provides R access to the `tskit` C API for use cases where the
1213
`reticulate` option is not optimal. For example, for high-performance and
1314
low-level work with tree sequences. Currently, `RcppTskit` provides a limited
@@ -91,10 +92,11 @@ By contributing to this project, you agree to abide by its terms.
9192

9293
### Clone
9394

94-
First clone the repository:
95+
First clone the repository and step into the directory:
9596

9697
```
9798
git clone https://github.com/HighlanderLab/RcppTskit.git
99+
cd RcppTskit
98100
```
99101

100102
### Pre-commit install

RcppTskit/.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
^\.covrignore$
1111
^\.github$
1212
^codecov\.yaml$
13+
^cran-comments\.md$
1314
^inst/examples/create_test\.trees\.R$
1415
^inst/examples/create_test\.trees\.py$
16+
^LICENSE.md$
1517
^notes_pkg_dev\.Rmd$
1618
^pkg_dev_notes\.md$
1719
^tests/testthat/_snaps$

RcppTskit/DESCRIPTION

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
Type: Package
22
Package: RcppTskit
3-
Title: R access to the tskit C API
3+
Title: R Access to the Tskit C API
44
Version: 0.1.0
5-
Date: 2026-01-2607
6-
Authors@R:
7-
person("Gregor", "Gorjanc", , "gregor.gorjanc@gmail.com", role = c("aut", "cre"),
8-
comment = c(ORCID = "0000-0001-8008-2787"))
9-
Description: Tskit enables performant storage, manipulation, and analysis
10-
of ancestral recombination graphs (ARGs) using succinct tree sequence
11-
encoding. See https://tskit.dev for project news, documentation, and
12-
tutorials. Tskit provides Python, C, and Rust APIs. The Python API
13-
can be called from R via the `reticulate` R package to seamlessly load
14-
and analyse a tree sequence as described at
15-
https://tskit.dev/tutorials/RcppTskit.html. `RcppTskit` provides R
16-
access to the `tskit` C API for use cases where the `reticulate`
5+
Date: 2026-01-27
6+
Authors@R: c(
7+
person("Gregor", "Gorjanc", , "gregor.gorjanc@gmail.com", role = c("aut", "cre", "cph"),
8+
comment = c(ORCID = "0000-0001-8008-2787")),
9+
person("Tskit Developers", role = "cph",
10+
comment = "Authors of included tskit C library")
11+
)
12+
Description: 'Tskit' enables performant storage, manipulation, and
13+
analysis of ancestral recombination graphs (ARGs) using succinct tree
14+
sequence encoding. See <https://tskit.dev> for project news,
15+
documentation, and tutorials. 'Tskit' provides Python, C, and Rust
16+
application programming interfaces (APIs). The Python API can be
17+
called from R via the 'reticulate' R package to seamlessly load and
18+
analyse a tree sequence as described at
19+
<https://tskit.dev/tutorials/tskitr.html>. 'RcppTskit' provides R
20+
access to the 'tskit' C API for use cases where the 'reticulate'
1721
option is not optimal. For example, for high-performance and low-level
18-
work with tree sequences. Currently, `RcppTskit` provides a limited
22+
work with tree sequences. Currently, 'RcppTskit' provides a limited
1923
number of R functions due to the availability of extensive Python API
20-
and the `reticulate` option.
24+
and the 'reticulate' option.
2125
License: MIT + file LICENSE
2226
URL: https://github.com/HighlanderLab/RcppTskit
2327
BugReports: https://github.com/HighlanderLab/RcppTskit/issues
@@ -26,16 +30,16 @@ Depends:
2630
Imports:
2731
methods,
2832
R6,
29-
Rcpp (>= 1.1.0),
30-
reticulate
33+
Rcpp (>= 0.12.10),
34+
reticulate (>= 1.41.0)
3135
Suggests:
3236
covr,
3337
knitr,
3438
quarto,
3539
spelling,
3640
testthat (>= 3.0.0)
3741
LinkingTo:
38-
Rcpp
42+
Rcpp (>= 0.12.10)
3943
VignetteBuilder:
4044
quarto
4145
Config/testthat/edition: 3

RcppTskit/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
YEAR: 2025
1+
YEAR: 2026
22
COPYRIGHT HOLDER: Gregor Gorjanc

RcppTskit/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright (c) 2026 Gregor Gorjanc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

RcppTskit/LICENSE.note

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The tskit C library is distributed under the MIT license.
2+
Full copies of the license are included in `inst/include/tskit/LICENSE` and `src/tskit/LICENSE.

RcppTskit/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(TreeSequence)
4+
export(check_tskit_py)
45
export(get_tskit_py)
56
export(kastore_version)
67
export(ts_load)

RcppTskit/R/Class-TreeSequence.R

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ TreeSequence <- R6Class(
7171
},
7272

7373
#' @description Alias for \code{\link[=TreeSequence]{TreeSequence$dump}}.
74-
#' @param file see
75-
#' @param options see
74+
#' @param file see \code{\link[=TreeSequence]{TreeSequence$dump}}.
75+
#' @param options see \code{\link[=TreeSequence]{TreeSequence$dump}}.
7676
write = function(file, options = 0L) {
7777
self$dump(file = file, options = options)
7878
},
@@ -106,11 +106,14 @@ TreeSequence <- R6Class(
106106
#' ts_r$num_samples() # 160
107107
#'
108108
#' # Transfer the tree sequence to reticulate Python and use tskit Python API
109-
#' ts_py <- ts_r$r_to_py()
110-
#' is(ts_py)
111-
#' ts_py$num_samples # 160
112-
#' ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L))
113-
#' ts2_py$num_samples # 4
109+
#' tskit <- get_tskit_py()
110+
#' if (check_tskit_py(tskit)) {
111+
#' ts_py <- ts_r$r_to_py()
112+
#' is(ts_py)
113+
#' ts_py$num_samples # 160
114+
#' ts2_py <- ts_py$simplify(samples = c(0L, 1L, 2L, 3L))
115+
#' ts2_py$num_samples # 4
116+
#' }
114117
r_to_py = function(tskit_module = get_tskit_py(), cleanup = TRUE) {
115118
ts_r_to_py_ptr(
116119
self$pointer,
@@ -120,107 +123,137 @@ TreeSequence <- R6Class(
120123
},
121124

122125
#' @description Get the number of provenances in a tree sequence.
126+
#' @examples
123127
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
124128
#' ts <- ts_load(ts_file)
125-
#' ts_num_provenances(ts)
129+
#' ts$num_provenances()
126130
num_provenances = function() {
127131
ts_num_provenances_ptr(self$pointer)
128132
},
129133

130134
#' @description Get the number of populations in a tree sequence.
135+
#' @examples
131136
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
132137
#' ts <- ts_load(ts_file)
133-
#' ts_num_populations(ts)
138+
#' ts$num_populations()
134139
num_populations = function() {
135140
ts_num_populations_ptr(self$pointer)
136141
},
137142

138143
#' @description Get the number of migrations in a tree sequence.
144+
#' @examples
139145
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
140146
#' ts <- ts_load(ts_file)
141-
#' ts_num_migrations(ts)
147+
#' ts$num_migrations()
142148
num_migrations = function() {
143149
ts_num_migrations_ptr(self$pointer)
144150
},
145151

146152
#' @description Get the number of individuals in a tree sequence.
153+
#' @examples
147154
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
148155
#' ts <- ts_load(ts_file)
149-
#' ts_num_individuals(ts)
156+
#' ts$num_individuals()
150157
num_individuals = function() {
151158
ts_num_individuals_ptr(self$pointer)
152159
},
153160

154161
#' @description Get the number of samples (of nodes) in a tree sequence.
162+
#' @examples
155163
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
156164
#' ts <- ts_load(ts_file)
157-
#' ts_num_samples(ts)
165+
#' ts$num_samples()
158166
num_samples = function() {
159167
ts_num_samples_ptr(self$pointer)
160168
},
161169

162170
#' @description Get the number of nodes in a tree sequence.
171+
#' @examples
163172
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
164173
#' ts <- ts_load(ts_file)
165-
#' ts_num_nodes(ts)
174+
#' ts$num_nodes()
166175
num_nodes = function() {
167176
ts_num_nodes_ptr(self$pointer)
168177
},
169178

170179
#' @description Get the number of edges in a tree sequence.
180+
#' @examples
171181
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
172182
#' ts <- ts_load(ts_file)
173-
#' ts_num_edges(ts)
183+
#' ts$num_edges()
174184
num_edges = function() {
175185
ts_num_edges_ptr(self$pointer)
176186
},
177187

178188
#' @description Get the number of trees in a tree sequence.
189+
#' @examples
179190
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
180191
#' ts <- ts_load(ts_file)
181-
#' ts_num_trees(ts)
192+
#' ts$num_trees()
182193
num_trees = function() {
183194
ts_num_trees_ptr(self$pointer)
184195
},
185196

186197
#' @description Get the number of sites in a tree sequence.
198+
#' @examples
187199
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
188200
#' ts <- ts_load(ts_file)
189-
#' ts_num_sites(ts)
201+
#' ts$num_sites()
190202
num_sites = function() {
191203
ts_num_sites_ptr(self$pointer)
192204
},
193205

194206
#' @description Get the number of mutations in a tree sequence.
207+
#' @examples
195208
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
196209
#' ts <- ts_load(ts_file)
197-
#' ts_num_mutations(ts)
210+
#' ts$num_mutations()
198211
num_mutations = function() {
199212
ts_num_mutations_ptr(self$pointer)
200213
},
201214

202215
#' @description Get the sequence length.
216+
#' @examples
203217
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
204218
#' ts <- ts_load(ts_file)
205-
#' ts_sequence_length(ts)
219+
#' ts$sequence_length()
206220
sequence_length = function() {
207221
ts_sequence_length_ptr(self$pointer)
208222
},
209223

210224
#' @description Get the time units string.
225+
#' @examples
211226
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
212227
#' ts <- ts_load(ts_file)
213-
#' ts_time_units(ts)
228+
#' ts$time_units()
214229
time_units = function() {
215230
ts_time_units_ptr(self$pointer)
216231
},
217232

233+
#' @description Get the min time in node table and mutation table.
234+
#' @examples
235+
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
236+
#' ts <- ts_load(ts_file)
237+
#' ts$min_time()
238+
min_time = function() {
239+
ts_min_time_ptr(self$pointer)
240+
},
241+
242+
#' @description Get the max time in node table and mutation table.
243+
#' @examples
244+
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
245+
#' ts <- ts_load(ts_file)
246+
#' ts$max_time()
247+
max_time = function() {
248+
ts_max_time_ptr(self$pointer)
249+
},
250+
218251
#' @description Get the length of metadata in a tree sequence and its tables.
219252
#' @return A named list with the length of metadata.
220253
#' @examples
221-
#'ts_file <- system.file("examples/test.trees", package = "RcppTskit")
254+
#' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
222255
#' ts <- ts_load(ts_file)
223-
#'ts$metadata_length()
256+
#' ts$metadata_length()
224257
metadata_length = function() {
225258
ts_metadata_length_ptr(self$pointer)
226259
}

RcppTskit/R/RcppExports.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ ts_metadata_length_ptr <- function(ts) {
9595
.Call(`_RcppTskit_ts_metadata_length_ptr`, ts)
9696
}
9797

98-
ts_grow <- function(ts) {
99-
.Call(`_RcppTskit_ts_grow`, ts)
100-
}
101-
10298
test_tsk_bug_assert_c <- function() {
10399
invisible(.Call(`_RcppTskit_test_tsk_bug_assert_c`))
104100
}

RcppTskit/R/RcppTskit-package.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Contains the package description and .onLoad() function
22

33
#' @description
4-
#' Tskit enables performant storage, manipulation, and analysis of
4+
#' `Tskit` enables performant storage, manipulation, and analysis of
55
#' ancestral recombination graphs (ARGs) using succinct tree sequence encoding.
66
#' See https://tskit.dev for project news, documentation, and tutorials.
7-
#' Tskit provides Python, C, and Rust APIs. The Python API can be called from R
8-
#' via the `reticulate` R package to seamlessly load and analyse a tree sequence
9-
#' as described at https://tskit.dev/tutorials/tskitr.html.
7+
#' `Tskit` provides Python, C, and Rust application programming interfaces (APIs).
8+
#' The Python API can be called from R via the `reticulate` R package to
9+
#' seamlessly load and analyse a tree sequence as described at
10+
#' https://tskit.dev/tutorials/tskitr.html.
1011
#' `RcppTskit` provides R access to the `tskit` C API for use cases where the
1112
#' `reticulate` option is not optimal. For example, for high-performance
1213
#' and low-level work with tree sequences. Currently, `RcppTskit` provides a

0 commit comments

Comments
 (0)