subset.cross: Subsetting data for QTL experiment

View source: R/util.R

subset.crossR Documentation

Subsetting data for QTL experiment

Description

Pull out a specified set of chromosomes and/or individuals from a cross object.

Usage

## S3 method for class 'cross'
subset(x, chr, ind, ...)
## S3 method for class 'cross'
x[chr, ind]

Arguments

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.

Details

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.

If the ind argument is a logical vector (TRUE/FALSE), it should have length equal to the number of individuals in the input cross x. The individuals with corresponding TRUE values are retained.

If the ind argument is numeric, it should have values either between 1 and the number of individuals in the input cross x (in which case these individuals will be retained), or it should have values between -1 and -n, where n is the number of individuals in the input cross x, in which case all except these individuals will be retained.

If the input cross object x contains individual identifiers (a phenotype column labeled "id" or "ID"), and if the ind argument contains character strings, then these will be matched against the individual identifiers. If all values in ind are preceded by a -), we omit those individuals whose IDs match those in ind. Otherwise, we retain those individuals whose IDs match those in ind.

Value

The input cross object, but with only the specified subset of the data.

Author(s)

Karl W Broman, broman@wisc.edu

See Also

pull.map, drop.markers, subset.map

Examples

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"))

# you can also use brackets (like matrix with rows=chromosomes and columns=individuals)
temp <- listeria[c("5","13"),]  # chr 5 and 13
temp <- listeria[ , 1:10]       # first ten individuals
temp <- listeria[5, 1:10]       # chr 5 for first ten individuals

qtl documentation built on Nov. 28, 2023, 1:09 a.m.