pooldata.subset: Create a subset of the pooldata object that contains Pool-Seq...

View source: R/pooldata.subset.R

pooldata.subsetR Documentation

Create a subset of the pooldata object that contains Pool-Seq data as a function of pool and/or SNP indexes

Description

Create a subset of the pooldata object that contains Pool-Seq data as a function of pool and/or SNP indexes

Usage

pooldata.subset(
  pooldata,
  pool.index = 1:pooldata@npools,
  snp.index = 1:pooldata@nsnp,
  min.cov.per.pool = -1,
  max.cov.per.pool = 1e+06,
  min.maf = -1,
  cov.qthres.per.pool = c(0, 1),
  return.snp.idx = FALSE,
  verbose = TRUE
)

Arguments

pooldata

A pooldata object containing Pool-Seq information

pool.index

Indexes of the pools (at least two), that should be selected to create the new pooldata object (default=all the pools)

snp.index

Indexes of the SNPs (at least two), that should be selected to create the new pooldata object (default=all the SNPs)

min.cov.per.pool

Minimal allowed read count (per pool). If at least one pool is not covered by at least min.cov.perpool reads, the position is discarded

max.cov.per.pool

Maximal allowed read count (per pool). If at least one pool is covered by more than min.cov.perpool reads, the position is discarded

min.maf

Minimal allowed Minor Allele Frequency (computed from the ratio over all read counts for the reference allele over the read coverage)

cov.qthres.per.pool

A two-elements vector containing the minimal (qmin) and maximal (qmax) quantile coverage thresholds applied to each pools (0<=qmin<qmax<=1). See details below

return.snp.idx

If TRUE, the row.names of the snp.info slot of the returned pooldata object are named as "rsx" where x is the index of SNP in the initial pooldata object (default=FALSE)

verbose

If TRUE return some information

Details

This function allows subsetting a pooldata object by selecting only some pools and/or some SNPs (e.g., based on their position on the genome). Additional filtering steps on SNPs can be carried out on the resulting subset to discard SNP with low polymorphism or poorly or too highly covered. In addition, coverage criteria can be applied on a per-pool basis with the cov.qthres.per.pool argument. 'more specific SNP selection based on their positions on the genome or their characteristics. For instance if qmax=0.95, a position is discarded if in a given pool it has a number of reads higher than the 95-th percentile of the empirical coverage distribution in this same pool (defined over the SNPs selected by snp.index). Similarly, if qmax=0.05, a position is discarded if in a given pool it has a number of reads lower than the 5-th percentile of the empirical coverage distribution in this same pool. This mode of selection may be more relevant when considering pools with heterogeneous read coverages.

Value

A pooldata object with 7 elements:

  1. "refallele.readcount": a matrix with nsnp rows and npools columns containing read counts for the reference allele (chosen arbitrarily) in each pool

  2. "readcoverage": a matrix with nsnp rows and npools columns containing read coverage in each pool

  3. "snp.info": a matrix with nsnp rows and four columns containing respectively the contig (or chromosome) name (1st column) and position (2nd column) of the SNP; the allele in the reference assembly (3rd column); the allele taken as reference in the refallele matrix.readcount matrix (4th column); and the alternative allele (5th column)

  4. "poolsizes": a vector of length npools containing the haploid pool sizes

  5. "poolnames": a vector of length npools containing the names of the pools

  6. "nsnp": a scalar corresponding to the number of SNPs

  7. "npools": a scalar corresponding to the number of pools

See Also

To generate pooldata object, see vcf2pooldata, popsync2pooldata

Examples

 make.example.files(writing.dir=tempdir())
 pooldata=popsync2pooldata(sync.file=paste0(tempdir(),"/ex.sync.gz"),poolsizes=rep(50,15))
 subset.by.pools=pooldata.subset(pooldata,pool.index=c(1,2))
 subset.by.snps=pooldata.subset(pooldata,snp.index=10:100)
 subset.by.pools.and.snps=pooldata.subset(pooldata,pool.index=c(1,2),snp.index=10:100)
 subset.by.pools.qcov.thr=pooldata.subset(pooldata,pool.index=1:8,cov.qthres.per.pool=c(0.05,0.95)) 

poolfstat documentation built on Sept. 8, 2023, 5:49 p.m.