Package {dartR.sexlinked}


Type: Package
Title: Analysing SNP Data to Identify Sex-Linked Markers
Version: 1.3.0
Date: 2026-11-18
Revision: Hardy Hedgehog
Author: Diana Robledo-Ruiz [aut, cre], Floriaan Devloo-Delva [aut], Bernd Gruber [aut], Arthur Georges [aut], Jose L. Mijangos [aut], Carlo Pacioni [aut], Peter J. Unmack [ctb], Oliver Berry [ctb]
Description: Identifies, filters and exports sex linked markers using 'SNP' (single nucleotide polymorphism) data. To install the other packages, we recommend to install the 'dartRverse' package, that supports the installation of all packages in the 'dartRverse'. If you want understand the applied rational to identify sexlinked markers and/or want to cite 'dartR.sexlinked', you find the information by typing citation('dartR.sexlinked') in the console.
License: GPL (≥ 3)
URL: https://green-striped-gecko.github.io/dartR/
BugReports: https://groups.google.com/g/dartr?pli=1
Depends: dartR.base (≥ 1.3.0), dartR.data, R (≥ 3.5)
Imports: adegenet (≥ 2.0.0), doParallel (≥ 1.0.17), ggplot2, methods, utils, foreach, patchwork
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2026-11-18 06:16:41 UTC; bernd
RoxygenNote: 7.3.3
Maintainer: Diana Robledo-Ruiz <diana.robledoruiz1@monash.edu>
Repository: CRAN
Date/Publication: 2026-11-23 00:20:15 UTC

Removes loci that are sex linked (deprecated)

Description

This function is deprecated. Please use gl.filter.sexlinked instead. It warns and then runs gl.filter.sexlinked with the same arguments, so scripts written for it keep working.

Usage

gl.drop.sexlinked(x, system = NULL, ...)

Arguments

x

Name of the genlight object containing the SNP data. This genlight object needs to contain the sex of the individuals [required].

system

String that declares the sex-determination system of the species: 'zw' or 'xy' [required].

...

Further arguments passed to gl.filter.sexlinked (ncores, plot.display, plot.theme, plot.colors, plot.file, plot.dir, verbose).

Details

This function has been deprecated and replaced by gl.filter.sexlinked in order to keep consistency with other functions (gl.report -> gl.filter).

Value

What gl.filter.sexlinked returns: a genlight object with the autosomal loci, or NULL.

Author(s)

Author(s): Diana Robledo-Ruiz. Custodian: Diana Robledo-Ruiz – Post to https://groups.google.com/d/forum/dartr

References

See Also

gl.filter.sexlinked


Removes loci that are sex linked

Description

This function identifies sex-linked and autosomal loci present in a SNP dataset (genlight object) using individuals with known sex. It identifies five types of loci: w-linked or y-linked, sex-biased, z-linked or x-linked, gametologous and autosomal.

This function returns a genlight object with autosomal loci only, and displays 4 plots.

Usage

gl.filter.sexlinked(
  x,
  system = NULL,
  ncores = 1,
  plot.display = TRUE,
  plot.theme = theme_dartR(),
  plot.colors = NULL,
  plot.file = NULL,
  plot.dir = NULL,
  verbose = NULL
)

Arguments

x

Name of the genlight object containing the SNP data. This genlight object needs to contain the sex of the individuals. See explanation in details [required].

system

String that declares the sex-determination system of the species: 'zw' or 'xy' [required].

ncores

Number of processes to be used in parallel operation. If ncores > 1 parallel operation is activated [default 1].

plot.display

If TRUE, displays the four output plots. See explanation in details [default TRUE].

plot.theme

Theme for the plots [default theme_dartR()].

plot.colors

Not implemented; the plots use fixed colours for each category of loci [default NULL].

plot.file

Name for the RDS binary file to save (base name only, exclude extension) [default NULL].

plot.dir

Directory to save the plot RDS files [default as specified by the global working directory or tempdir()].

verbose

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

Details

The genlight object must contain in gl@other$ind.metrics a column named "sex" (case-insensitive) in which individuals with known sex are assigned 'F' or 'Female' for females, and 'M' or 'Male' for males (case-insensitive). The rows of ind.metrics must be in the same order as the individuals in the genlight object. The function ignores individuals that are assigned anything else or nothing at all (unknown sex). At least one female and one male are required. SilicoDArT (presence/absence) data are not accepted.

Loci are classified as in gl.report.sexlinked, which describes the tests and thresholds used.

The display of plots can be turned off (plot.display = FALSE), but we strongly encourage you to always inspect the output plots at least once to make sure everything is working properly.

Function's output

This function returns a genlight object that contains only autosomal loci (i.e. sex-linked loci have been filtered out), or NULL if every locus is sex-linked. The object keeps all individuals, carries the locus metrics of the autosomal loci only, and records this call in its history. To keep the sex-linked loci instead, use gl.keep.sexlinked.

And displays four plots:

The plots are not returned; use plot.file to save them.

Value

A genlight object with autosomal loci, or NULL (see Details).

Author(s)

Author(s): Diana Robledo-Ruiz. Custodian: Diana Robledo-Ruiz – Post to https://groups.google.com/d/forum/dartr

References

Examples

LBP_noSexLinked <- gl.filter.sexlinked(x = LBP, system = "xy", 
plot.display = TRUE, ncores = 1)
LBP_noSexLinked


Uses sex-linked loci to infer sex of individuals

Description

This function uses the output of function gl.keep.sexlinked (list of 5 elements) to infer the sex of all individuals in the dataset. It uses 3 types of sex-linked loci (W-/Y-linked, Z-/X-linked, and gametologs), assigns a preliminary genetic sex for each type of sex-linked loci available, and outputs an agreed sex.

This function produces as output a dataframe with individuals in rows and 11 columns.

Usage

gl.infer.sex(gl_sexlinked, system = NULL, seed = NULL, verbose = NULL)

Arguments

gl_sexlinked

The output of function gl.keep.sexlinked (complete list with 5 elements). See explanation in "Details" section [required].

system

String that declares the sex-determination system of the species: 'zw' or 'xy'. It must be the same system used in gl.keep.sexlinked [required].

seed

User-defined integer for repeatability purposes. If not provided by user, it is chosen randomly. See "Details" section [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, unless specified using gl.set.verbosity].

Details

Parameter gl_sexlinked must be the name of the output object (a list of 5 elements) produced by function gl.keep.sexlinked, run with the same system. Parameter seed must be an integer that will be used on the KMeans algorithm used by the function. If seed is not provided, the value chosen is not reported, so we highly recommend choosing the seed to guarantee repeatability. The random number stream of the R session is restored when the function ends.

Each type of sex-linked loci is used as follows:

KMeans always returns two groups, so the Z-/X-linked and gametolog assignments assume that both sexes are present in the dataset. If only one sex is present, part of the individuals will still be assigned to the other sex.

Note that this function was created with the explicit intent that a human checks the evidence for the sex assignments that do NOT agree for all types of sex-linked loci (called "indefinite sex assignments" and denoted as "*M", "*F" or "*?" in the last column of dataframe output). This human can then use their criterion to validate these assignments.

Function's output

This function creates a dataframe with one row per individual and 11 columns:

Columns for a type of sex-linked loci that could not be used are NA.

Value

A dataframe with one row per individual and the 11 columns described in "Details".

Author(s)

Author(s): Diana Robledo-Ruiz. Custodian: Diana Robledo-Ruiz – Post to https://groups.google.com/d/forum/dartr

References

See Also

gl.keep.sexlinked

Examples

LBP_sexLinked <- gl.keep.sexlinked(x = LBP, system = "xy", 
plot.display = FALSE, ncores = 1)
inferred.sexes <- gl.infer.sex(gl_sexlinked = LBP_sexLinked, system = "xy", 
seed = 100)
inferred.sexes


Keeps loci that are sex linked

Description

This function identifies sex-linked and autosomal loci present in a SNP dataset (genlight object) using individuals with known sex. It identifies five types of loci: w-linked or y-linked, sex-biased, z-linked or x-linked, gametologous and autosomal.

This function returns a list with 5 elements, including one dataframe and 4 genlight objects with sex-linked loci, and displays 4 plots.

Usage

gl.keep.sexlinked(
  x,
  system = NULL,
  ncores = 1,
  plot.display = TRUE,
  plot.theme = theme_dartR(),
  plot.colors = NULL,
  plot.file = NULL,
  plot.dir = NULL,
  verbose = NULL
)

Arguments

x

Name of the genlight object containing the SNP data. This genlight object needs to contain the sex of the individuals. See explanation in details [required].

system

String that declares the sex-determination system of the species: 'zw' or 'xy' [required].

ncores

Number of processes to be used in parallel operation. If ncores > 1 parallel operation is activated [default 1].

plot.display

If TRUE, displays the four output plots. See explanation in details [default TRUE].

plot.theme

Theme for the plots [default theme_dartR()].

plot.colors

Not implemented; the plots use fixed colours for each category of loci [default NULL].

plot.file

Name for the RDS binary file to save (base name only, exclude extension) [default NULL].

plot.dir

Directory to save the plot RDS files [default as specified by the global working directory or tempdir()].

verbose

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

Details

The genlight object must contain in gl@other$ind.metrics a column named "sex" (case-insensitive) in which individuals with known sex are assigned 'F' or 'Female' for females, and 'M' or 'Male' for males (case-insensitive). The rows of ind.metrics must be in the same order as the individuals in the genlight object. The function ignores individuals that are assigned anything else or nothing at all (unknown sex). At least one female and one male are required. SilicoDArT (presence/absence) data are not accepted.

Loci are classified as in gl.report.sexlinked, which describes the tests and thresholds used.

The display of plots can be turned off (plot.display = FALSE), but we strongly encourage you to always inspect the output plots at least once to make sure everything is working properly.

Function's output

This function returns a list of 5 elements:

A category with no loci is returned as NULL. Each genlight object keeps all individuals, carries the locus metrics of its own loci only, and records this call in its history.

And displays four plots:

The plots are not returned; use plot.file to save them.

Value

A list of 5 elements (see Details).

Author(s)

Author(s): Diana Robledo-Ruiz. Custodian: Diana Robledo-Ruiz – Post to https://groups.google.com/d/forum/dartr

References

Examples

LBP_sexLinked <- gl.keep.sexlinked(x = LBP, system = "xy", 
plot.display = TRUE, ncores = 1)
LBP_sexLinked$gametolog


Reports loci that are sex linked

Description

This function identifies sex-linked and autosomal loci present in a SNP dataset (genlight object) using individuals with known sex. It identifies five types of loci: w-linked or y-linked, sex-biased, z-linked or x-linked, gametologous and autosomal.

This function returns a dataframe and displays 2 plots.

Usage

gl.report.sexlinked(
  x,
  system = NULL,
  ncores = 1,
  plot.display = TRUE,
  plot.theme = theme_dartR(),
  plot.colors = NULL,
  plot.file = NULL,
  plot.dir = NULL,
  verbose = NULL
)

Arguments

x

Name of the genlight object containing the SNP data. This genlight object needs to contain the sex of the individuals. See explanation in details [required].

system

String that declares the sex-determination system of the species: 'zw' or 'xy' [required].

ncores

Number of processes to be used in parallel operation. If ncores > 1 parallel operation is activated [default 1].

plot.display

If TRUE, displays the two output plots. See explanation in details [default TRUE].

plot.theme

Theme for the plots [default theme_dartR()].

plot.colors

Not implemented; the plots use fixed colours for each category of loci [default NULL].

plot.file

Name for the RDS binary file to save (base name only, exclude extension) [default NULL].

plot.dir

Directory to save the plot RDS files [default as specified by the global working directory or tempdir()].

verbose

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

Details

The genlight object must contain in gl@other$ind.metrics a column named "sex" (case-insensitive) in which individuals with known sex are assigned 'F' or 'Female' for females, and 'M' or 'Male' for males (case-insensitive). The rows of ind.metrics must be in the same order as the individuals in the genlight object. The function ignores individuals that are assigned anything else or nothing at all (unknown sex). At least one female and one male are required. SilicoDArT (presence/absence) data are not accepted.

Classification of loci

For each locus, the function tests for independence of sex and call rate (phase 1), and of sex and heterozygosity (phase 2). It uses Fisher's exact test when fewer than 1,000 individuals of known sex are scored, and a chi-square test (without continuity correction) otherwise. P-values are adjusted for false discovery rate. Loci are then classified as follows:

The display of plots can be turned off (plot.display = FALSE), but we strongly encourage you to always inspect the output plots at least once to make sure everything is working properly.

Function's output

This function displays two plots:

The plots are not returned; use plot.file to save them.

And it returns a dataframe in which loci are in rows, and columns:

Value

A dataframe with one row per locus (see Details).

Author(s)

Author(s): Diana Robledo-Ruiz. Custodian: Diana Robledo-Ruiz – Post to https://groups.google.com/d/forum/dartr

References

Examples

out <- gl.report.sexlinked(x = LBP, system = "xy", plot.display = TRUE,
ncores = 1)


Setting up the package dartR.sexlinked

Description

Setting up dartR.sexlinked

Usage

zzz

Format

An object of class NULL of length 0.