Skip to content

Commit 5ab0453

Browse files
committed
Expanding vignette with the demo package and fortify configure
1 parent 2af189d commit 5ab0453

3 files changed

Lines changed: 20 additions & 25 deletions

File tree

RcppTskit/inst/WORDLIST

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ SLiM
55
TreeSequence
66
Tskit
77
etc
8+
finaliser
89
kastore
910
msprime
10-
num
11-
ts
1211
tskit
1312
tskitr

RcppTskit/tools/configure.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env Rscript
22

3-
# TODO: Check if we can link AlphaSimR against RcppTskit on Windows and Linux #40
4-
# https://github.com/HighlanderLab/RcppTskit/issues/40
5-
63
# Set platform-specific linker flags for RcppTskit
74
setRcppTskitLibAndFlags <- function() {
85
sysname <- Sys.info()[["sysname"]]
@@ -53,14 +50,16 @@ if (.Platform$OS.type == "unix") {
5350
template = "src/Makevars.in",
5451
output = "src/Makevars"
5552
)
56-
} else {
53+
} else if (.Platform$OS.type == "windows") {
5754
# readLines(con = "src/Makevars.win.in")
5855
success <- renderMakevars(
5956
# Currently, both Unix and Windows use the same template
6057
# template = "src/Makevars.win.in",
6158
template = "src/Makevars.in",
6259
output = "src/Makevars.win"
6360
)
61+
} else {
62+
stop("Unknown .Platform$OS.type!")
6463
}
6564
if (!success) {
6665
stop("renderMakevars() failed!")

RcppTskit/vignettes/RcppTskit_intro.qmd

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ To call the `tskit` C API in your own R package via `Rcpp`
293293
you can leverage `RcppTskit`, which will simplify your installation
294294
and enable you to quickly call
295295
To do this, follow the steps below and check how these were implemented in
296-
the test R package `RcppTskitTestLinkingTo` at https://github.com/HighlanderLab/RcppTskitTestLinking.
296+
the demo R package `RcppTskitTestLinkingTo` at
297+
https://github.com/HighlanderLab/RcppTskitTestLinking.
297298

298299
a) Open `DESCRIPTION` file and
299300
add `RcppTskit` to the `Imports:` and `LinkingTo:` field, and further
@@ -332,31 +333,27 @@ h) You should now be ready to build, check, and install your package using
332333
`devtools::build()`, `devtools::check()`, and `devtools::install()`
333334
or their `R CMD` equivalents.
334335

336+
Here is code you can run to check out `RcppTskitTestLinkingTo`:
337+
335338
```{r}
336339
#| label: use_case_4
337340
#| eval: false
338-
#| echo: false
341+
# Install and load the demo package
342+
remotes::install_github("HighlanderLab/RcppTskitTestLinking")
343+
library(RcppTskitTestLinking)
339344
340-
# This code will not work atm because we used tskitr!
341-
# TODO: Create a minimal package to demonstrate how to link against RcppTskit and call tskit C API
345+
# Check the demo function
346+
print(ts_num_individuals_ptr2)
342347
343-
# Install AlphaSimR
344-
# (Commit with a proof of concept of using tskit C API;
345-
# study the file contents in there! Can also use later commits.)
346-
remotes::install_github(
347-
repo = "HighlanderLab/AlphaSimR",
348-
ref = "12657b08e7054d88bc214413d13f36c7cde60d95"
349-
)
348+
# Example tree sequence
349+
ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
350+
ts <- ts_load(ts_file)
350351
351-
# Load packages
352-
library(RcppTskit)
353-
library(AlphaSimR)
352+
# Function from RcppTskit (working with TreeSequence R6 class)
353+
ts$num_individuals()
354354
355-
# Load tree sequence and count the number of individuals
356-
ts_file <- system.file("examples/test.trees", package = "RcppTskit")
357-
ts <- ts_load(ts_file)
358-
RcppTskit::ts_num_individuals(ts)
359-
AlphaSimR::ts_num_individuals2(ts)
355+
# Function from RcppTskitTestLinking (working with externalptr)
356+
ts_num_individuals_ptr2(ts$pointer)
360357
```
361358

362359
## Conclusion

0 commit comments

Comments
 (0)