Learn R Programming

qtl2fst (version 0.30)

replace_path: Replace the path used in fst_genoprob object

Description

Replace the path used in an fst_genoprob object.

Usage

replace_path(object, path)

Value

The input object with the path replaced. If any of the expected files don't exist with the new path, warnings are issued.

Arguments

object

An object of class "fst_genoprob" as created by fst_genoprob().

path

New path (directory + file stem as a single character string) to be used in the object.

See Also

fst_path(), fst_files()

Examples

Run this code
library(qtl2)
grav2 <- read_cross2(system.file("extdata", "grav2.zip", package="qtl2"))
probs <- calc_genoprob(grav2, error_prob=0.002)
dir <- tempdir()
fprobs <- fst_genoprob(probs, "grav2", dir, overwrite=TRUE)

# move the probabilities into a different directory
new_dir <- file.path(tempdir(), "subdir")
if(!dir.exists(new_dir)) dir.create(new_dir)
for(file in fst_files(fprobs)) {
   file.rename(file, file.path(new_dir, basename(file)))
}

# revise the path in fprobs
new_path <- sub(dir, new_dir, fst_path(fprobs), fixed=TRUE)
fprobs <- replace_path(fprobs, new_path)

Run the code above in your browser using DataLab