% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/subset.R
\name{subsetbd}
\alias{subsetbd}
\title{Subset a binary dosage file}
\usage{
subsetbd(
  bdfiles,
  bdose_file,
  minmaf = NULL,
  locations = NULL,
  startloc = NULL,
  endloc = NULL,
  subjectids = NULL
)
}
\arguments{
\item{bdfiles}{Vector of file names for the input binary dosage file.
Format 4 files require one file name. Formats 1, 2, and 3 require three
file names: the binary dosage file, the family file, and the map file.
Format 5 files require two file names: the .bdose file and the .bdinfo
file.}

\item{bdose_file}{Path for the output .bdose file. The companion .bdi
metadata file is written to \code{paste0(bdose_file, ".bdi")}.}

\item{minmaf}{Minimum minor allele frequency. SNPs whose MAF (computed over
the retained subjects) is below this value are excluded. Must be a single
numeric value between 0 and 0.5.}

\item{locations}{Integer or numeric vector of SNP base-pair locations to
retain. Cannot be used together with \code{startloc} and \code{endloc}.}

\item{startloc}{Start of the location range to retain (inclusive). Must be
used together with \code{endloc}. Cannot be used together with
\code{locations}.}

\item{endloc}{End of the location range to retain (inclusive). Must be used
together with \code{startloc}. Cannot be used together with
\code{locations}.}

\item{subjectids}{Character vector of subject IDs to retain.}
}
\value{
NULL (invisibly)
}
\description{
Creates a new Format 5 binary dosage file containing a subset of the SNPs
and/or subjects from an existing binary dosage file. The input file may be
in any format (1-5). At least one filtering criterion must be supplied, and
all supplied criteria must be met for a SNP or subject to be retained.
}
\examples{
bdfile <- system.file("extdata", "vcf1a.bdose", package = "BinaryDosage")
bdinfo     <- getbdinfo(bdfile)
bdose_file <- tempfile(fileext = ".bdose")
subsetbd(bdfiles    = bdfile,
         bdose_file = bdose_file,
         subjectids = bdinfo$samples$sid[1:30])
}
