subset.cross {qtl} | R Documentation |
Pull out a specified set of chromosomes and/or individuals from a
cross
object.
## S3 method for class 'cross': subset(x, chr, ind, ...)
x |
An object of class cross . See
read.cross for details. |
chr |
Optional vector specifying which chromosomes to keep or discard. This may be a logical, numeric, or character string vector. See Details, below. |
ind |
Optional vector specifying which individuals to keep discard. This may be a logical, numeric or chacter string vector. See Details, below. |
... |
Ignored at this point. |
The chr
argument may be a logical vector with length equal to
the number of chromosomes in the input cross x
. Alternatively, it
should be a vector of character strings referring to chromosomes by
name. Numeric values are converted to strings. Refer to chromosomes
with a preceding -
to have all chromosomes but those
considered.
The ind
argument may be a logical vector with length equal to
the number of individuals in the input cross x
. Otherwise, its
treatment depends on whether the input cross contains individual
identifiers in the phenotype data (which is a column named either
id
or ID
).
If there are no individual identifiers in the input cross, the
ind
argument should be logical or numeric. If numeric, the
values should indicate which individuals to retain (if they are all
positive) or which to omit (if they are all negative).
If there are individual identifiers in the input cross and the
argument ind
is numeric, we first look to see whether all of
the values match an individual identifier. If some do not match, we
treat the vector as we would if the input cross had no individual
identifiers. If ind
is numeric and all values match an
individual identifier, we treat them as such identifiers.
When the values of ind
are to be treated as individual
identifiers, we either retain those individuals whose IDs match those
in ind
, or (in the case that all values in ind
are
preceded by a -
), we omit those individauls whose IDs match
those in ind
.
The input cross
object, but with only the specified subset
of the data.
Karl W Broman, kbroman@biostat.wisc.edu
data(fake.f2) fake.f2.A <- subset(fake.f2, chr=c("5","13")) fake.f2.B <- subset(fake.f2, ind = -c(1,5,10)) fake.f2.C <- subset(fake.f2, chr=1:5, ind=1:50) data(listeria) y <- pull.pheno(listeria, 1) listeriaB <- subset(listeria, ind = (!is.na(y) & y < 264)) # individual identifiers listeria$pheno$ID <- paste("mouse", 1:nind(listeria), sep="") listeriaC <- subset(listeria, ind=c("mouse1","mouse11","mouse21")) listeriaD <- subset(listeria, ind=c("-mouse1","-mouse11","-mouse21"))