subset.cross2: Subsetting data for a QTL experiment

View source: R/subset_cross2.R

subset.cross2R Documentation

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 class 'cross2'
subset(x, ind = NULL, chr = NULL, ...)

## S3 method for class 'cross2'
x[ind = NULL, chr = NULL]

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.

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.

Value

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

Warning

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

Examples

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]

qtl2 documentation built on May 29, 2024, 11:46 a.m.