Learn R Programming

qtl2 (version 0.36)

subset.cross2: Subsetting data for a QTL experiment

Description

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

Usage

# S3 method for cross2
subset(x, ind = NULL, chr = NULL, ...)

# S3 method for cross2 [(x, ind = NULL, chr = NULL)

Value

The input cross2 object, with the selected individuals and/or chromsomes.

Arguments

x

An object of class "cross2", as output by read_cross2(). For details, see the R/qtl2 developer guide.

ind

A vector of individuals: numeric indices, logical values, or character string IDs.

chr

A vector of chromosomes: numeric indices, logical values, or character string IDs

...

Ignored.

Warning

The order of the two arguments is reversed relative to the related function in R/qtl.

Details

When subsetting by individual, if ind is numeric, they're assumed to be numeric indices; if character strings, they're assumed to be individual IDs. ind can be numeric or logical only if the genotype, phenotype, and covariate data all have the same individuals in the same order.

When subsetting by chromosome, chr is always converted to character strings and treated as chromosome IDs. So if there are three chromosomes with IDs "18", "19", and "X", mycross[,18] will give the first of the chromosomes (labeled "18") and mycross[,3] will give an error.

When using character string IDs for ind or chr, you can use "negative" subscripts to indicate exclusions, for example mycross[,c("-18", "-X")] or mycross["-Mouse2501",]. But you can't mix "positive" and "negative" subscripts, and if any of the individuals has an ID that begins with "-", you can't use negative subscripts like this.

Examples

Run this code
grav2 <- read_cross2(system.file("extdata", "grav2.zip", package="qtl2"))
# keep individuals 1-20 and chromosomes 3 and 4
grav2sub <- grav2[1:20, c(3,4)]
# keep just chromosome 1
grav2_c1 <- grav2[,1]

Run the code above in your browser using DataLab