Load a gen_tibble
previously saved with gt_save()
. If the .rds and
.bk files have not
been moved, they should be found automatically. If they were moved, use
reattach_to
to point to the .rds file (the .bk file needs to be in the
same directory as the .rds file).
Arguments
- file
the file name, including the full path. If it does not end with .gt, the extension will be added.
- reattach_to
the file name, including the full path, of the .rds file if it was moved. It assumes that the .bk file is found in the same path. You should be able to leave this to NULL unless you have moved the files.
Examples
example_gt <- example_gt("gen_tbl")
# remove some individuals
example_gt_filtered <- example_gt %>% filter(id != "a")
# save the filtered gen_tibble object
backing_files <- gt_save(example_gt_filtered,
file_name = paste0(tempfile(), "_example_filtered")
)
#>
#> gen_tibble saved to /tmp/RtmpyN1xne/file22a26f1b5930_example_filtered.gt
#> using bigSNP file: /tmp/RtmpyN1xne/file22a21f4ce286.rds
#> with backing file: /tmp/RtmpyN1xne/file22a21f4ce286.bk
#> make sure that you do NOT delete those files!
#> to reload the gen_tibble in another session, use:
#> gt_load('/tmp/RtmpyN1xne/file22a26f1b5930_example_filtered.gt')
# backing_files[1] contains the name of the saved .gt file
backing_files[1]
#> [1] "/tmp/RtmpyN1xne/file22a26f1b5930_example_filtered.gt"
# To load the saved gen_tibble object, use the path to the saved .gt file
reloaded_gt <- gt_load(backing_files[1])
# And we have loaded the gt without individual "a"
reloaded_gt
#> # A gen_tibble: 6 loci
#> # A tibble: 6 × 3
#> id population genotypes
#> <chr> <chr> <vctr_SNP>
#> 1 b pop1 2
#> 2 c pop2 3
#> 3 d pop2 4
#> 4 e pop1 5
#> 5 f pop3 6
#> 6 g pop3 7