gl.join: Combines two dartR genlight objects

View source: R/gl.join.r

gl.joinR Documentation

Combines two dartR genlight objects

Description

This function combines two genlight objects and their associated metadata. The history of the new genlight object is taken from the first genlight object, with the gl.join call appended. Either the individuals/samples must be the same in each genlight object, in which case the new genlight object has the same individuals but combined loci, or the loci must be the same in each genlight object in which case the new genlight object has the same loci but combined individuals/samples. The function is typically used to combine datasets from the same service where the files have been split because of size limitations. The data is read in from multiple csv files, then the resultant genlight objects are combined.

This function works with both SNP and Tag P/A data.

Usage

gl.join(x1, x2, method = NULL, verbose = NULL)

Arguments

x1

Name of the first genlight object [required].

x2

Name of the second genlight object [required].

method

Legacy parameter, deprecated and no longer required. Accepted legacy values for backward compatibility: 'join.by.loc' or 'end2end' (same loci, individuals combined); 'join.by.ind' or 'sidebyside' (same individuals, loci combined) [default NULL].

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].

Details

This script joins two genlight objects together along with the associated metadata. The join mode is detected automatically: if the two objects have identical individuals (in the same order), the loci are combined; if they have identical loci (in the same order), the individuals are combined. Individual names duplicated across the two objects are made unique. The legacy method parameter is deprecated and no longer required; the historical values 'join.by.loc'/'end2end' (join by shared loci) and 'join.by.ind'/'sidebyside' (join by shared individuals) remain accepted for backward compatibility, and the requested join is validated against the data.

Value

A new genlight object with the combined data and metadata.

Author(s)

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

See Also

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.fbm2gen(), gl.gen2fbm(), gl.impute(), 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

if (isTRUE(getOption("dartR_fbm"))) testset.gl <- gl.gen2fbm(testset.gl)
# Joining by loci in common, both datasets have the same loci in the same order
x1 <- testset.gl[1:7, ]
nInd(x1)
x2 <- testset.gl[11:14, ]
nInd(x2)
gl <- gl.join(x1, x2, verbose = 4)
nInd(gl)
# Joining by individuals in common, both datasets have the same individuals
# in the same order
if (isTRUE(getOption("dartR_fbm"))) platypus.gl <- gl.gen2fbm(platypus.gl)
x1 <- platypus.gl[, 1:100]
nLoc(x1)
x2 <- platypus.gl[, 101:200]
nLoc(x2)
gl <- gl.join(x1, x2, verbose=3)
nLoc(gl)

# Join by adding individuals with a set of common loci
nInd(testset.gl)
x1 <- gl.drop.ind(testset.gl,ind.list=c("AA010915","UC_00126","AA032760","AA013214",
"AA011723","AA012411","AA019237","AA019238","AA019239","AA019235","AA019240",
"AA019241","AA019242","AA019243"))
nInd(x1)
x2 <- gl.keep.ind(testset.gl,ind.list=c("AA010915","UC_00126","AA032760","AA013214",
"AA011723","AA012411","AA019237","AA019238","AA019239","AA019235","AA019240",
"AA019241","AA019242","AA019243"))
nInd(x2)
gl <- gl.join(x1, x2, verbose=3)
nInd(gl)

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