View source: R/subset_cross2.R
subset.cross2 | R Documentation |
Pull out a specified set of individuals and/or chromosomes from a
cross2
object.
## S3 method for class 'cross2'
subset(x, ind = NULL, chr = NULL, ...)
## S3 method for class 'cross2'
x[ind = NULL, chr = NULL]
x |
An object of class |
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. |
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.
The input cross2
object, with the selected
individuals and/or chromsomes.
The order of the two arguments is reversed relative to the related function in R/qtl.
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]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.