bodkan/slendr

Not getting an output when running slim

AhmedSelim1997 opened this issue · 7 comments

When I run slim on a compiled slender model, and save the output in a variable, the value of the variable ends up being NULL. Is there something I am forgetting to do?

I'm sorry but without seeing a complete script which gives you troubles, I can't do anything here to help.

Additionally, it would be helpful to know what version of R are you using, what operating system are you using, and what you get when you run slendr::check_env() in your R session.

I am using the exact script from this vignette
https://www.slendr.net/articles/vignette-02-grid-model.html

R version: 4.0.4
OS: darwin17.0 (Mac)

Check_env():
Summary of the currently active Python environment:

Python binary: /Users/afselim/Library/r-miniconda/envs/msprime-1.1.1_tskit-0.4.1_pyslim-0.700/bin/python
Python version: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:05:47) [Clang 12.0.1 ]

slendr requirements:

  • tskit: version 0.4.1 ✓
  • msprime: version 1.1.1 ✓
  • pyslim: version 0.700 ✓

Great, we're getting somewhere! That vignette doesn't really have a "script" as much as a collection of code chunks, but assuming you're trying to run the first example, here I collected the relevant bits to a real R script:

library(slendr)

map <- world(
  xrange = c(0, 1000),
  yrange = c(0, 1000),
  landscape = "blank"
)

create_pop <- function(i, n_side, map, N, radius) {
  # get dimensions of the world map
  dim <- c(diff(attr(map, "xrange")), diff(attr(map, "yrange")))

  # position of the i-th population on the two-dimensional lattice grid
  coords <- c((i - 1) %% n_side, (i - 1) %/% n_side)
  center <- coords / n_side * dim + dim / (2 * n_side)

  pop <- tryCatch({
    population(
      name = sprintf("pop%d", i),
      N = N,
      time = 1,
      map = map,
      center = center + c(attr(map, "xrange")[1], attr(map, "yrange")[1]),
      radius = radius
    )
  }, error = function(e) NULL)

  pop
}

n <- 5

populations <-
  seq(1, n * n) %>%
  lapply(create_pop, n_side = n, map = map, N = 100, radius = 40)

set_geneflow <- function(i, n_side, rate, start, end, populations) {
  pop <- populations[[i]]

  # get the position of the i-th population on the n*n grid
  coords <- c((i - 1) %% n_side, (i - 1) %/% n_side)

  # get coordinates of the i-th population's neighbors on the grid
  neighbor_pos <- list(
    c(coords[1] - 1, coords[2]), c(coords[1] + 1, coords[2]),
    c(coords[1], coords[2] + 1), c(coords[1], coords[2] - 1)
  )

  # generate geneflow events for population coordinates inside the grid
  geneflows <- lapply(neighbor_pos, function(pos) {
    if (any(pos < 0 | pos >= n_side)) return(NULL)
    neighbor <- populations[[pos[2] * n_side + pos[1] + 1]]
    if (is.null(neighbor)) return(NULL)

    rbind(
      gene_flow(from = pop, to = neighbor, rate = rate, start = start, end = end, overlap = FALSE),
      gene_flow(from = neighbor, to = pop, rate = rate, start = start, end = end, overlap = FALSE)
    )
  }) %>%
    do.call(rbind, .)

  geneflows
}

geneflows <-
  seq(1, n * n) %>%
  lapply(set_geneflow, n, rate = 0.05, start = 2, end = 1000, populations) %>%
  do.call(rbind, .) %>%
  unique # filter out duplicate events due to symmetries

model <- compile_model(
  populations = populations, gene_flow = geneflows,
  generation_time = 1, resolution = 10,
  competition = 10, mating = 10, dispersal = 10,
  simulation_length = 1000
)
  1. It would be great if you could run devtools::install_github("bodkan/slendr") (to make sure you're on the latest development version), then please run the above script in a fresh R session and make sure you're not getting any errors.

  2. Then please run the following command:

ts <- slim(model, sequence_length = 10000, recombination_rate = 0, verbose = TRUE)

and paste here everything you get as an output into your R console (it might be quite long, but it's important to see the whole thing).

  1. After that (assuming 1. and 2. don't give any errors), please run this:
ts

and paste here what you get. For instance, I get something like this, suggesting that the simulation ran OK on that example:

> ts
╔═══════════════════════════╗
║TreeSequence               ║
╠═══════════════╤═══════════╣
║Trees          │          1║
╟───────────────┼───────────╢
║Sequence Length│      10000║
╟───────────────┼───────────╢
║Time Units     │generations║
╟───────────────┼───────────╢
║Sample Nodes   │       5000║
╟───────────────┼───────────╢
║Total Size     │    1.3 MiB║
╚═══════════════╧═══════════╝
╔═══════════╤════╤═════════╤════════════╗
║Table      │Rows│Size     │Has Metadata║
╠═══════════╪════╪═════════╪════════════╣
║Edges      │9053│282.9 KiB│          No║
╟───────────┼────┼─────────┼────────────╢
║Individuals│6308│617.6 KiB│         Yes║
╟───────────┼────┼─────────┼────────────╢
║Migrations │   0│  8 Bytes│          No║
╟───────────┼────┼─────────┼────────────╢
║Mutations  │   0│  1.2 KiB│          No║
╟───────────┼────┼─────────┼────────────╢
║Nodes      │9078│337.6 KiB│         Yes║
╟───────────┼────┼─────────┼────────────╢
║Populations│  25│  5.7 KiB│         Yes║
╟───────────┼────┼─────────┼────────────╢
║Provenances│   1│ 33.2 KiB│          No║
╟───────────┼────┼─────────┼────────────╢
║Sites      │   0│ 16 Bytes│          No║
╚═══════════╧════╧═════════╧════════════╝

Ok, still getting NULL unfortunately :(

here's my slim simulation output:

ts <- slim(model, sequence_length = 10000, recombination_rate = 0, verbose = TRUE)
Tree-sequence recording is on but no sampling schedule was given. Generating one for all individuals surviving to the end of the simulation.


SLiM command to be executed:

slim
-d 'SAMPLES="/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464/output_slim_sampling.tsv"'
-d 'MODEL="/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464"'
-d 'OUTPUT="/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464/output"'
-d SPATIAL=T
-d SEQUENCE_LENGTH=10000
-d RECOMB_RATE=0
-d BURNIN_LENGTH=0
-d SIMULATION_LENGTH=1000
-d SAVE_LOCATIONS=F
-d COALESCENT_ONLY=T
-d MAX_ATTEMPTS=1
/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464/script.slim

// Initial random seed:
1835872248262

// RunInitializeCallbacks():
SEED: 1835872248262
initializeSLiMOptions(keepPedigrees = T, dimensionality = 'xy');
initializeInteractionType(0, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(1, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(2, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(3, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(4, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(5, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(6, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(7, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(8, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(9, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(10, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(11, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(12, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(13, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(14, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(15, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(16, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(17, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(18, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(19, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(20, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(21, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(22, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(23, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(24, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(25, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(26, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(27, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(28, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(29, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(30, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(31, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(32, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(33, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(34, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(35, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(36, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(37, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(38, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(39, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(40, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(41, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(42, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(43, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(44, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(45, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(46, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(47, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(48, "xy", reciprocal=T, maxDistance=1);
initializeInteractionType(49, "xy", reciprocal=T, maxDistance=1);
initializeTreeSeq();
initializeMutationType(0, 0.5, "f", 0);
initializeGenomicElementType(1, m0, 1);
initializeGenomicElement(g1, 0, 9999);
initializeMutationRate(0);
initializeRecombinationRate(0);

// Starting run at generation :
1

Generation 1: starting the simulation
Generation 1: creating pop1(p0)
Generation 1: creating pop2(p1)
Generation 1: creating pop3(p2)
Generation 1: creating pop4(p3)
Generation 1: creating pop5(p4)
Generation 1: creating pop6(p5)
Generation 1: creating pop7(p6)
Generation 1: creating pop8(p7)
Generation 1: creating pop9(p8)
Generation 1: creating pop10(p9)
Generation 1: creating pop11(p10)
Generation 1: creating pop12(p11)
Generation 1: creating pop13(p12)
Generation 1: creating pop14(p13)
Generation 1: creating pop15(p14)
Generation 1: creating pop16(p15)
Generation 1: creating pop17(p16)
Generation 1: creating pop18(p17)
Generation 1: creating pop19(p18)
Generation 1: creating pop20(p19)
Generation 1: creating pop21(p20)
Generation 1: creating pop22(p21)
Generation 1: creating pop23(p22)
Generation 1: creating pop24(p23)
Generation 1: creating pop25(p24)
Generation 1: updating map for pop1(p0)
Generation 1: distributing individuals of pop1(p0)
Generation 1: updating map for pop2(p1)
Generation 1: distributing individuals of pop2(p1)
Generation 1: updating map for pop3(p2)
Generation 1: distributing individuals of pop3(p2)
Generation 1: updating map for pop4(p3)
Generation 1: distributing individuals of pop4(p3)
Generation 1: updating map for pop5(p4)
Generation 1: distributing individuals of pop5(p4)
Generation 1: updating map for pop6(p5)
Generation 1: distributing individuals of pop6(p5)
Generation 1: updating map for pop7(p6)
Generation 1: distributing individuals of pop7(p6)
Generation 1: updating map for pop8(p7)
Generation 1: distributing individuals of pop8(p7)
Generation 1: updating map for pop9(p8)
Generation 1: distributing individuals of pop9(p8)
Generation 1: updating map for pop10(p9)
Generation 1: distributing individuals of pop10(p9)
Generation 1: updating map for pop11(p10)
Generation 1: distributing individuals of pop11(p10)
Generation 1: updating map for pop12(p11)
Generation 1: distributing individuals of pop12(p11)
Generation 1: updating map for pop13(p12)
Generation 1: distributing individuals of pop13(p12)
Generation 1: updating map for pop14(p13)
Generation 1: distributing individuals of pop14(p13)
Generation 1: updating map for pop15(p14)
Generation 1: distributing individuals of pop15(p14)
Generation 1: updating map for pop16(p15)
Generation 1: distributing individuals of pop16(p15)
Generation 1: updating map for pop17(p16)
Generation 1: distributing individuals of pop17(p16)
Generation 1: updating map for pop18(p17)
Generation 1: distributing individuals of pop18(p17)
Generation 1: updating map for pop19(p18)
Generation 1: distributing individuals of pop19(p18)
Generation 1: updating map for pop20(p19)
Generation 1: distributing individuals of pop20(p19)
Generation 1: updating map for pop21(p20)
Generation 1: distributing individuals of pop21(p20)
Generation 1: updating map for pop22(p21)
Generation 1: distributing individuals of pop22(p21)
Generation 1: updating map for pop23(p22)
Generation 1: distributing individuals of pop23(p22)
Generation 1: updating map for pop24(p23)
Generation 1: distributing individuals of pop24(p23)
Generation 1: updating map for pop25(p24)
Generation 1: distributing individuals of pop25(p24)
Generation 2: geneflow pop1(p0) -> pop2(p1) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop2(p1) -> pop1(p0) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop1(p0) -> pop6(p5) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop6(p5) -> pop1(p0) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop2(p1) -> pop3(p2) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop3(p2) -> pop2(p1) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop2(p1) -> pop7(p6) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop7(p6) -> pop2(p1) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop3(p2) -> pop4(p3) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop4(p3) -> pop3(p2) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop3(p2) -> pop8(p7) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop8(p7) -> pop3(p2) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop4(p3) -> pop5(p4) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop5(p4) -> pop4(p3) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop4(p3) -> pop9(p8) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop9(p8) -> pop4(p3) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop5(p4) -> pop10(p9) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop10(p9) -> pop5(p4) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop6(p5) -> pop7(p6) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop7(p6) -> pop6(p5) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop6(p5) -> pop11(p10) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop11(p10) -> pop6(p5) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop7(p6) -> pop8(p7) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop8(p7) -> pop7(p6) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop7(p6) -> pop12(p11) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop12(p11) -> pop7(p6) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop8(p7) -> pop9(p8) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop9(p8) -> pop8(p7) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop8(p7) -> pop13(p12) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop13(p12) -> pop8(p7) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop9(p8) -> pop10(p9) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop10(p9) -> pop9(p8) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop9(p8) -> pop14(p13) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop14(p13) -> pop9(p8) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop10(p9) -> pop15(p14) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop15(p14) -> pop10(p9) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop11(p10) -> pop12(p11) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop12(p11) -> pop11(p10) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop11(p10) -> pop16(p15) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop16(p15) -> pop11(p10) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop12(p11) -> pop13(p12) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop13(p12) -> pop12(p11) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop12(p11) -> pop17(p16) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop17(p16) -> pop12(p11) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop13(p12) -> pop14(p13) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop14(p13) -> pop13(p12) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop13(p12) -> pop18(p17) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop18(p17) -> pop13(p12) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop14(p13) -> pop15(p14) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop15(p14) -> pop14(p13) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop14(p13) -> pop19(p18) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop19(p18) -> pop14(p13) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop15(p14) -> pop20(p19) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop20(p19) -> pop15(p14) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop16(p15) -> pop17(p16) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop17(p16) -> pop16(p15) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop16(p15) -> pop21(p20) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop21(p20) -> pop16(p15) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop17(p16) -> pop18(p17) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop18(p17) -> pop17(p16) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop17(p16) -> pop22(p21) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop22(p21) -> pop17(p16) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop18(p17) -> pop19(p18) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop19(p18) -> pop18(p17) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop18(p17) -> pop23(p22) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop23(p22) -> pop18(p17) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop19(p18) -> pop20(p19) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop20(p19) -> pop19(p18) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop19(p18) -> pop24(p23) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop24(p23) -> pop19(p18) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop20(p19) -> pop25(p24) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop25(p24) -> pop20(p19) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop21(p20) -> pop22(p21) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop22(p21) -> pop21(p20) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop22(p21) -> pop23(p22) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop23(p22) -> pop22(p21) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop23(p22) -> pop24(p23) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop24(p23) -> pop23(p22) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop24(p23) -> pop25(p24) (5.01002e-05% over 998 generations)
Generation 2: geneflow pop25(p24) -> pop24(p23) (5.01002e-05% over 998 generations)
Generation 1000: geneflow pop1(p0) -> pop2(p1) set to 0%
Generation 1000: geneflow pop2(p1) -> pop1(p0) set to 0%
Generation 1000: geneflow pop1(p0) -> pop6(p5) set to 0%
Generation 1000: geneflow pop6(p5) -> pop1(p0) set to 0%
Generation 1000: geneflow pop2(p1) -> pop3(p2) set to 0%
Generation 1000: geneflow pop3(p2) -> pop2(p1) set to 0%
Generation 1000: geneflow pop2(p1) -> pop7(p6) set to 0%
Generation 1000: geneflow pop7(p6) -> pop2(p1) set to 0%
Generation 1000: geneflow pop3(p2) -> pop4(p3) set to 0%
Generation 1000: geneflow pop4(p3) -> pop3(p2) set to 0%
Generation 1000: geneflow pop3(p2) -> pop8(p7) set to 0%
Generation 1000: geneflow pop8(p7) -> pop3(p2) set to 0%
Generation 1000: geneflow pop4(p3) -> pop5(p4) set to 0%
Generation 1000: geneflow pop5(p4) -> pop4(p3) set to 0%
Generation 1000: geneflow pop4(p3) -> pop9(p8) set to 0%
Generation 1000: geneflow pop9(p8) -> pop4(p3) set to 0%
Generation 1000: geneflow pop5(p4) -> pop10(p9) set to 0%
Generation 1000: geneflow pop10(p9) -> pop5(p4) set to 0%
Generation 1000: geneflow pop6(p5) -> pop7(p6) set to 0%
Generation 1000: geneflow pop7(p6) -> pop6(p5) set to 0%
Generation 1000: geneflow pop6(p5) -> pop11(p10) set to 0%
Generation 1000: geneflow pop11(p10) -> pop6(p5) set to 0%
Generation 1000: geneflow pop7(p6) -> pop8(p7) set to 0%
Generation 1000: geneflow pop8(p7) -> pop7(p6) set to 0%
Generation 1000: geneflow pop7(p6) -> pop12(p11) set to 0%
Generation 1000: geneflow pop12(p11) -> pop7(p6) set to 0%
Generation 1000: geneflow pop8(p7) -> pop9(p8) set to 0%
Generation 1000: geneflow pop9(p8) -> pop8(p7) set to 0%
Generation 1000: geneflow pop8(p7) -> pop13(p12) set to 0%
Generation 1000: geneflow pop13(p12) -> pop8(p7) set to 0%
Generation 1000: geneflow pop9(p8) -> pop10(p9) set to 0%
Generation 1000: geneflow pop10(p9) -> pop9(p8) set to 0%
Generation 1000: geneflow pop9(p8) -> pop14(p13) set to 0%
Generation 1000: geneflow pop14(p13) -> pop9(p8) set to 0%
Generation 1000: geneflow pop10(p9) -> pop15(p14) set to 0%
Generation 1000: geneflow pop15(p14) -> pop10(p9) set to 0%
Generation 1000: geneflow pop11(p10) -> pop12(p11) set to 0%
Generation 1000: geneflow pop12(p11) -> pop11(p10) set to 0%
Generation 1000: geneflow pop11(p10) -> pop16(p15) set to 0%
Generation 1000: geneflow pop16(p15) -> pop11(p10) set to 0%
Generation 1000: geneflow pop12(p11) -> pop13(p12) set to 0%
Generation 1000: geneflow pop13(p12) -> pop12(p11) set to 0%
Generation 1000: geneflow pop12(p11) -> pop17(p16) set to 0%
Generation 1000: geneflow pop17(p16) -> pop12(p11) set to 0%
Generation 1000: geneflow pop13(p12) -> pop14(p13) set to 0%
Generation 1000: geneflow pop14(p13) -> pop13(p12) set to 0%
Generation 1000: geneflow pop13(p12) -> pop18(p17) set to 0%
Generation 1000: geneflow pop18(p17) -> pop13(p12) set to 0%
Generation 1000: geneflow pop14(p13) -> pop15(p14) set to 0%
Generation 1000: geneflow pop15(p14) -> pop14(p13) set to 0%
Generation 1000: geneflow pop14(p13) -> pop19(p18) set to 0%
Generation 1000: geneflow pop19(p18) -> pop14(p13) set to 0%
Generation 1000: geneflow pop15(p14) -> pop20(p19) set to 0%
Generation 1000: geneflow pop20(p19) -> pop15(p14) set to 0%
Generation 1000: geneflow pop16(p15) -> pop17(p16) set to 0%
Generation 1000: geneflow pop17(p16) -> pop16(p15) set to 0%
Generation 1000: geneflow pop16(p15) -> pop21(p20) set to 0%
Generation 1000: geneflow pop21(p20) -> pop16(p15) set to 0%
Generation 1000: geneflow pop17(p16) -> pop18(p17) set to 0%
Generation 1000: geneflow pop18(p17) -> pop17(p16) set to 0%
Generation 1000: geneflow pop17(p16) -> pop22(p21) set to 0%
Generation 1000: geneflow pop22(p21) -> pop17(p16) set to 0%
Generation 1000: geneflow pop18(p17) -> pop19(p18) set to 0%
Generation 1000: geneflow pop19(p18) -> pop18(p17) set to 0%
Generation 1000: geneflow pop18(p17) -> pop23(p22) set to 0%
Generation 1000: geneflow pop23(p22) -> pop18(p17) set to 0%
Generation 1000: geneflow pop19(p18) -> pop20(p19) set to 0%
Generation 1000: geneflow pop20(p19) -> pop19(p18) set to 0%
Generation 1000: geneflow pop19(p18) -> pop24(p23) set to 0%
Generation 1000: geneflow pop24(p23) -> pop19(p18) set to 0%
Generation 1000: geneflow pop20(p19) -> pop25(p24) set to 0%
Generation 1000: geneflow pop25(p24) -> pop20(p19) set to 0%
Generation 1000: geneflow pop21(p20) -> pop22(p21) set to 0%
Generation 1000: geneflow pop22(p21) -> pop21(p20) set to 0%
Generation 1000: geneflow pop22(p21) -> pop23(p22) set to 0%
Generation 1000: geneflow pop23(p22) -> pop22(p21) set to 0%
Generation 1000: geneflow pop23(p22) -> pop24(p23) set to 0%
Generation 1000: geneflow pop24(p23) -> pop23(p22) set to 0%
Generation 1000: geneflow pop24(p23) -> pop25(p24) set to 0%
Generation 1000: geneflow pop25(p24) -> pop24(p23) set to 0%
Generation 1001: sampling all (100) individuals of pop1(p0)
Generation 1001: sampling all (100) individuals of pop10(p9)
Generation 1001: sampling all (100) individuals of pop11(p10)
Generation 1001: sampling all (100) individuals of pop12(p11)
Generation 1001: sampling all (100) individuals of pop13(p12)
Generation 1001: sampling all (100) individuals of pop14(p13)
Generation 1001: sampling all (100) individuals of pop15(p14)
Generation 1001: sampling all (100) individuals of pop16(p15)
Generation 1001: sampling all (100) individuals of pop17(p16)
Generation 1001: sampling all (100) individuals of pop18(p17)
Generation 1001: sampling all (100) individuals of pop19(p18)
Generation 1001: sampling all (100) individuals of pop2(p1)
Generation 1001: sampling all (100) individuals of pop20(p19)
Generation 1001: sampling all (100) individuals of pop21(p20)
Generation 1001: sampling all (100) individuals of pop22(p21)
Generation 1001: sampling all (100) individuals of pop23(p22)
Generation 1001: sampling all (100) individuals of pop24(p23)
Generation 1001: sampling all (100) individuals of pop25(p24)
Generation 1001: sampling all (100) individuals of pop3(p2)
Generation 1001: sampling all (100) individuals of pop4(p3)
Generation 1001: sampling all (100) individuals of pop5(p4)
Generation 1001: sampling all (100) individuals of pop6(p5)
Generation 1001: sampling all (100) individuals of pop7(p6)
Generation 1001: sampling all (100) individuals of pop8(p7)
Generation 1001: sampling all (100) individuals of pop9(p8)
Generation 1001: saving the tree sequence output
Generation 1001: simulation finished

I tried with much simpler simulations and it seems that a tree sequence is consistently not given as an output for the slim() function.

The output you pasted suggests that you are running an older version of slendr. Did you upgrade your installation the way I suggested under point "1." above? Here it is again:

  1. It would be great if you could run devtools::install_github("bodkan/slendr") (to make sure you're on the latest development version), then please run the above script in a fresh R session and make sure you're not getting any errors.

Here is the deduction process by which I arrived at this conclusion.

First, here is the beginning of your slim() log output above:

SLiM command to be executed:

slim 
-d 'SAMPLES="/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464/output_slim_sampling.tsv"' 
-d 'MODEL="/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464"' 
-d 'OUTPUT="/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464/output"'
-d SPATIAL=T 
-d SEQUENCE_LENGTH=10000 
-d RECOMB_RATE=0 
-d BURNIN_LENGTH=0 
-d SIMULATION_LENGTH=1000 
-d SAVE_LOCATIONS=F 
-d COALESCENT_ONLY=T 
-d MAX_ATTEMPTS=1 
/var/folders/_1/c79k2gdx1v3f_j28s0kscpk80000gn/T//Rtmpr3ymHb/file449a46fb4464/script.slim

[... I cut the rest ...]

But this is the output which I'm getting on my machine (using a slendr version pushed last week). In particular, note that the old version which you are running does not have OUTPUT_TS=<path to tree sequence> which was implemented last week:

SLiM command to be executed:

slim   \
    -d 'SAMPLES="/var/folders/d_/hblb15pd3b94rg0v35920wd80000gn/T//RtmpitFwVf/file591b57356ed4"' \
    -d 'MODEL="/var/folders/d_/hblb15pd3b94rg0v35920wd80000gn/T//RtmpitFwVf/file591b7623bff1"' \
    -d 'OUTPUT_TS="/var/folders/d_/hblb15pd3b94rg0v35920wd80000gn/T//RtmpitFwVf/file591b48d7e9c8.trees"' \ 
    -d SPATIAL=T \
    -d SEQUENCE_LENGTH=10000 \
    -d RECOMB_RATE=0 \
    -d BURNIN_LENGTH=0 \
    -d SIMULATION_LENGTH=1000 \
    -d 'OUTPUT_LOCATIONS=""' \
    -d COALESCENT_ONLY=T \
    -d MAX_ATTEMPTS=1 \
    /var/folders/d_/hblb15pd3b94rg0v35920wd80000gn/T//RtmpitFwVf/file591b7623bff1/script.slim 

[... I cut the rest ...]

Most importantly, however, the end of the log output from the slim() command using latest version is supposed to look like this (again, this is what I'm seeing on my machine using the latest version of slendr):

[... the beginning cut for brevity ...]

Generation 1001: sampling all (100) individuals of pop7(p6)
Generation 1001: sampling all (100) individuals of pop8(p7)
Generation 1001: sampling all (100) individuals of pop9(p8)
Generation 1001: saving the tree sequence output to '/var/folders/d_/hblb15pd3b94rg0v35920wd80000gn/T//RtmpitFwVf/file591b48d7e9c8.trees'
Generation 1001: simulation finished
Tree sequence was saved to:
 /var/folders/d_/hblb15pd3b94rg0v35920wd80000gn/T//RtmpitFwVf/file591b48d7e9c8.trees 
Loading the tree-sequence file...

Note how different this is from the end of your log output. In particular, in the log from the newest slendr, the last bit of information says that a tree sequence is being loaded.

The reason you're getting NULL in your ts object is because... well, no tree sequence is being loaded in the old version of slendr (as indicated by the end of your log output). Tree sequence is automatically loaded only in the slendr released last week, as you can see in the output just above.


All of the above is evidence that you're not running the latest version of slendr. The vignette is using this new version of slendr. If you copy paste examples designed for the new slendr version and use them in an old version, this will not work.

To repeat, please run devtools::github_install("bodkan/slendr") and check again.

Closing this because the log outputs give pretty clear evidence that a version of slendr released before slim() and msprime() returned tree sequence objects directly was used here (which is why those functions return NULL, as would be the case with an older slendr).

If anyone else has the same issue, please make sure to install the latest version of slendr by running devtools::github_install("bodkan/slendr"), and check that the logging output indicates that a tree-sequence file is saved and loaded.