| 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 |
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
Robledo‐Ruiz, D. A., Austin, L., Amos, J. N., Castrejon‐Figueroa, J., Harley, D. K., Magrath, M. J., Sunnucks, P., & Pavlova, A. (2023). Easy‐to‐use R functions to separate reduced‐representation genomic datasets into sex‐linked and autosomal loci, and conduct sex assignment. Molecular Ecology Resources, 00, 1-21.
See Also
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:
-
A BEFORE plot based on loci call rate by sex, with w/y-linked loci colored in yellow and sex-biased loci in blue
-
An AFTER plot based on loci call rate by sex, with sex-linked loci removed
-
A BEFORE plot based on loci heterozygosity by sex, with z/x-linked loci colored in orange and gametologs in green
-
An AFTER plot based on loci heterozygosity by sex, with sex-linked loci removed
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
Robledo-Ruiz, D. A., Austin, L., Amos, J. N., Castrejon-Figueroa, J., Harley, D. K., Magrath, M. J., Sunnucks, P., & Pavlova, A. (2023). Easy to use R functions to separate reduced representation genomic datasets into sex linked and autosomal loci, and conduct sex assignment. Molecular Ecology Resources, 00, 1-21.
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:
-
W-linked or Y-linked loci: each individual is assigned to the heterogametic sex if it has more called than missing genotypes, and to the homogametic sex otherwise.
-
Z-linked or X-linked loci: used only if there are at least 2 loci. Individuals are split into two groups by KMeans on their proportions of heterozygous and homozygous genotypes.
-
Gametologs: used only if there are at least 5 loci. Only the 5 gametologs with the smallest adjusted p-value in the results table are used, and they are split into two groups by KMeans as for Z-/X-linked loci.
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:
-
id > Individuals' ID.
-
w.linked.sex or y.linked.sex > Sex inferred using w-linked or y-linked loci.
-
#called > Number of W-linked or Y-linked loci for which the individual had a called genotype (cf. missing genotype).
-
#missing > Number of W-linked or Y-linked loci for which the individual had a missing genotype (cf. called genotype).
-
z.linked.sex or x.linked.sex > Sex inferred using z-linked or x-linked loci.
-
#Het.z or #Het.x > Number of z-linked or x-linked loci for which the individual is heterozygous.
-
#Hom.z or #Hom.x > Number of z-linked or x-linked loci for which the individual is homozygous.
-
gametolog.sex > Sex inferred using gametologs.
-
#Het.g > Number of the 5 gametologs used for which the individual is heterozygous.
-
#Hom.g > Number of the 5 gametologs used for which the individual is homozygous.
-
agreed.sex > Agreed sex: 'F' or 'M' if all available preliminary sex-assignments match (i.e., definite sex assignment); '*F' or '*M' if NOT all preliminary sex-assignments match (i.e., indefinite sex assignment), following the majority; '*?' if there is no majority; and NA if no preliminary sex-assignment is available.
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
Robledo-Ruiz, D. A., Austin, L., Amos, J. N., Castrejon-Figueroa, J., Harley, D. K., Magrath, M. J., Sunnucks, P., & Pavlova, A. (2023). Easy to use R functions to separate reduced representation genomic datasets into sex linked and autosomal loci, and conduct sex assignment. Molecular Ecology Resources, 00, 1-21.
See Also
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:
-
$results.table > Table with statistics (columns) for each loci (rows), as returned by
gl.report.sexlinked -
$w.linked or $y.linked > Genlight object with w-linked/y-linked loci
-
$sex.biased > Genlight object with sex-biased scoring rate loci
-
$z.linked or $x.linked > Genlight object with z-linked/x-linked loci
-
$gametolog > Genlight object with gametologs
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:
-
A BEFORE plot based on loci call rate by sex, with w/y-linked loci colored in yellow and sex-biased loci in blue
-
An AFTER plot based on loci call rate by sex, with only sex-linked loci
-
A BEFORE plot based on loci heterozygosity by sex, with z/x-linked loci colored in orange and gametologs in green
-
An AFTER plot based on loci heterozygosity by sex, with only sex-linked loci
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
Robledo-Ruiz, D. A., Austin, L., Amos, J. N., Castrejon-Figueroa, J., Harley, D. K., Magrath, M. J., Sunnucks, P., & Pavlova, A. (2023). Easy to use R functions to separate reduced representation genomic datasets into sex linked and autosomal loci, and conduct sex assignment. Molecular Ecology Resources, 00, 1-21.
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:
-
w-linked (zw) or y-linked (xy): adjusted p-value of phase 1 <= 0.01 and call rate <= 0.1 in males (zw) or females (xy).
-
sex-biased: adjusted p-value of phase 1 <= 0.01, and not w/y-linked.
-
z-linked (zw) or x-linked (xy): not w/y-linked or sex-biased, adjusted p-value of phase 2 <= 0.01, and heterozygosity higher in males (zw) or females (xy).
-
gametolog: as z/x-linked, but heterozygosity not higher in males (zw) or females (xy).
-
autosomal: all other loci.
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:
-
A plot based on loci call rate by sex, with w/y-linked loci colored in yellow and sex-biased loci in blue
-
A plot based on loci heterozygosity by sex, with z/x-linked loci colored in orange and gametologs in green
The plots are not returned; use plot.file to save them.
And it returns a dataframe in which loci are in rows, and columns:
-
index - Index number to identify loci
-
count.F.miss - Count of females that have this locus as missing data (NA).
-
count.M.miss - Count of males that have this locus as missing data (NA)
-
count.F.scored - Count of females that have this locus scored (0, 1 or 2; i.e. non-missing)
-
count.M.scored - Count of males that have this locus scored (0, 1 or 2; i.e. non-missing)
-
ratio - Test statistic for the independence of call rate and sex for this locus: the Fisher's exact test odds ratio estimate, or the chi-square statistic when 1,000 or more individuals are tested
-
p.value - P-value of the test
-
p.adjusted - P-value adjusted for false discovery rate
-
scoringRate.F - Female call rate (proportion of females that were scored for this locus; x-axis in the 1st plot)
-
scoringRate.M - Male call rate (proportion of males that were scored for this locus; y-axis in the 1st plot)
-
w.linked/y.linked - Boolean for this locus being w-linked/y-linked
-
sex.biased - Boolean for this locus having sex-biased call rate
-
count.F.het - Count of females that are heterozygous for this locus
-
count.M.het - Count of males that are heterozygous for this locus
-
count.F.hom - Count of females that are homozygous for this locus
-
count.M.hom - Count of males that are homozygous for this locus
-
stat - Test statistic for the independence of heterozygosity and sex for this locus: the Fisher's exact test odds ratio estimate, or the chi-square statistic when 1,000 or more individuals are tested. NA for w/y-linked and sex-biased loci, which are not tested
-
stat.p.value - P-value of the test
-
stat.p.adjusted - P-value adjusted for false discovery rate
-
heterozygosity.F - Proportion of females that are heterozygotes for this locus (x-axis in the 2nd plot)
-
heterozygosity.M - Proportion of males that are heterozygotes for this locus (y-axis in the 2nd plot)
-
z.linked/x.linked - Boolean for this locus being z-linked/x.linked
-
gametolog - Boolean for this locus being a gametolog
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
Robledo-Ruiz, D. A., Austin, L., Amos, J. N., Castrejon-Figueroa, J., Harley, D. K., Magrath, M. J., Sunnucks, P., & Pavlova, A. (2023). Easy to use R functions to separate reduced representation genomic datasets into sex linked and autosomal loci, and conduct sex assignment. Molecular Ecology Resources, 00, 1-21.
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.