gl.fbm2gen: Converts a file-backed (FBM) genlight object to a gen-backed...

View source: R/gl.fbm2gen.r

gl.fbm2genR Documentation

Converts a file-backed (FBM) genlight object to a gen-backed one

Description

'gl.fbm2gen()' converts a 'dartR' whose genotypes live in the '@fbm' slot into a 'dartR' with genotypes in the '@gen' (list of SNPbin) slot. At the end, '@fbm' is set to 'NULL' and '@gen' holds the SNPbin list.

The conversion reads the FBM in **blocks of loci** (the order in which the backing file is stored, so reading is fast) and packs each block directly into the bits of the SNPbin objects; the full genotype matrix is never decoded at once. The block size follows the bigstatsr option bigstatsr.block.sizeGB (default 1): a block holds one sixteenth of bigstatsr::block_size(nInd(x)) loci (at least 512). Beyond the result itself, the conversion needs a few hundred Mb with the default (about 370 Mb for 2,000 individuals x 200,000 loci); lower the option to convert with less memory.

Genotypes must be 0, 1, 2 or missing (0 or 1 for haploid individuals); other values give an error.

Usage

gl.fbm2gen(x, chunk = NULL, quiet = TRUE, verbose = NULL)

Arguments

x

A 'dartR' or 'genlight' object. If it holds no FBM, it is returned unchanged.

chunk

Deprecated and ignored: the blocks are now blocks of loci whose size follows bigstatsr.block.sizeGB. Kept for compatibility [default NULL].

quiet

Logical; if 'TRUE', suppress the non-critical "no FBM found" message regardless of verbosity [default TRUE].

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default NULL, adopting the global verbosity set by gl.set.verbosity(), or 2 if no global is set].

Value

A 'dartR' object with **'@gen' populated** and **'@fbm = NULL'**.

Author(s)

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

See Also

gl.gen2fbm

Other data manipulation: gl.add.indmetrics(), gl.define.pop(), gl.drop.ind(), gl.drop.loc(), gl.drop.pop(), gl.edit.recode.pop(), gl.fbm.cleanup(), gl.gen2fbm(), gl.impute(), gl.join(), gl.keep.ind(), gl.keep.loc(), gl.keep.pop(), gl.make.recode.ind(), gl.make.recode.pop(), gl.merge.pop(), gl.reassign.ind(), gl.reassign.pop(), gl.recode.ind(), gl.recode.pop(), gl.rename.pop(), gl.sample(), gl.sim.genotypes(), gl.sort(), gl.subsample.ind(), gl.subsample.loc(), gl.subsample.loci()

Examples

x <- gl.gen2fbm(testset.gl)
y <- gl.fbm2gen(x)
length(y@gen)      # one SNPbin per individual
identical(as.matrix(y), as.matrix(testset.gl))

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