gl.save: Saves an object in compressed binary format for later rapid...

View source: R/gl.save.r

gl.saveR Documentation

Saves an object in compressed binary format for later rapid retrieval

Description

This is a wrapper for saveRDS(). The script saves the object in compressed binary form to the nominated file and returns the input gl object unchanged.

Only the object is saved, not the workspace. A file-backed (FBM) object is saved as a gen-backed copy (genotypes in @gen): an FBM holds only a reference to its backing file, which is usually temporary, and the gen-backed copy is also smaller. The input object stays file-backed. Use gl.load(file, fbm = TRUE) to load it back as a file-backed object.

**Always use gl.save(), not saveRDS(), for a file-backed object.** saveRDS() stores only the reference to the backing file, not the genotypes; the backing file is usually a temporary file that is deleted at the end of the R session, so the genotypes are lost. After saving, check that the file size makes sense for the number of individuals and loci: a file of only a few Kb for thousands of loci means the genotypes were not saved. gl.save() reports the size of the saved file at verbose >= 2.

Usage

gl.save(x, file, verbose = NULL)

Arguments

x

Name of the genlight object containing SNP genotypes [required].

file

Name of the file to receive the binary version of the object [required].

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default 2 or as specified using gl.set.verbosity].

Value

The input object, returned invisibly

Author(s)

Author(s): Arthur Georges. Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr

See Also

gl.load

Other io: gl.load(), gl.read.PLINK(), gl.read.csv(), gl.read.dart(), gl.read.fasta(), gl.read.silicodart(), gl.write.csv(), utils.read.dart()

Examples

gl.save(testset.gl,file.path(tempdir(),'testset.rds'))

dartR.base documentation built on Nov. 18, 2026, 9:06 a.m.