utils.vcf.depth: Utility function to read locus depth, allele read counts and...

View source: R/utils.vcf.depth.r

utils.vcf.depthR Documentation

Utility function to read locus depth, allele read counts and genotype likelihoods from a vcfR object

Description

WARNING: UTILITY SCRIPTS ARE FOR INTERNAL USE ONLY AND SHOULD NOT BE USED BY END USERS AS THEIR USE OUT OF CONTEXT COULD LEAD TO UNPREDICTABLE OUTCOMES.

Usage

utils.vcf.depth(
  vcf,
  loci = seq_len(nrow(vcf@fix)),
  read.counts = FALSE,
  likelihoods = FALSE,
  chunk = 10000L
)

Arguments

vcf

A vcfR object [defined in function gl.read.vcf].

loci

Indices of the records kept as loci, in the order of the loci in the genlight object [default all records].

read.counts

If TRUE, the reference and alternative read counts of each genotype are also returned [default FALSE].

likelihoods

If TRUE, the likelihoods of the three diploid genotypes of each genotype call are also returned [default FALSE].

chunk

Number of records processed at a time, which bounds the memory used [default 10000].

Details

rdepth is the mean of FORMAT DP over the called genotypes of a locus. Missing and half-missing calls (e.g. ./., 0/.) are not called, as in utils.vcfr2genlight.polyploid; some callers report DP = 0 for them. A locus without called genotypes or without DP gets NA.

Read counts come from FORMAT AD (first value REF, second ALT). Where a genotype has no AD, they come from FORMAT BSDP (read counts of the bases A, C, G and T, as written by some callers) taken at the REF and ALT bases; records whose REF or ALT is not a single base get NA. Counts are stored as reported, also for uncalled genotypes.

Likelihoods come from FORMAT PL or, for genotypes without PL, from FORMAT GL as round(-10 * GL). They are phred-scaled and shifted so that the most likely genotype has 0; a likelihood of 0 (-inf in GL) becomes the largest integer. A genotype whose likelihoods are missing, do not number three or are all equal (e.g. ./.:0,0,0) gets NA; uncalled genotypes with informative likelihoods keep them.

Value

A list with rdepth (one value per locus, NULL when the vcf has no DP); when read.counts is TRUE, ref.count and alt.count (integer matrices, individuals x loci, NULL when the vcf has neither AD nor BSDP); and when likelihoods is TRUE, pl.ref, pl.het and pl.alt (the phred-scaled likelihoods of 0/0, 0/1 and 1/1, integer matrices of individuals x loci, NULL when the vcf has neither PL nor GL).

Author(s)

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

See Also

Other utilities: gl.He(), gl.Ho(), gl.alf(), utils.allelic.richness(), utils.basic.stats(), utils.check.datatype(), utils.collapse.matrix(), utils.dart2genlight(), utils.dist.binary(), utils.fbm.amat(), utils.fbm.blocks(), utils.fbm.colblocks(), utils.fbm.colwise(), utils.fbm.copy(), utils.fbm.count.mean(), utils.fbm.decode(), utils.fbm.grm(), utils.fbm.has(), utils.fbm.new(), utils.fbm.pair.counts(), utils.fbm.reader(), utils.fbm.rowwise(), utils.fbm.tempfile(), utils.flag.start(), utils.het.pop(), utils.history.call(), utils.is.fixed(), utils.jackknife(), utils.n.var.invariant(), utils.plot.save(), utils.read.fasta(), utils.read.ped(), utils.recalc.avgpic(), utils.recalc.callrate(), utils.recalc.freqhets(), utils.recalc.freqhomref(), utils.recalc.freqhomsnp(), utils.recalc.maf(), utils.reset.flags(), utils.transpose(), utils.vcfr2genlight.polyploid()

Examples

## Not run: 
depth <- utils.vcf.depth(vcf, read.counts = TRUE, likelihoods = TRUE)

## End(Not run)

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