[,snpRdata,ANY,ANY,ANY-method | R Documentation |
Subsets snpRdata objects by specific snps, samples, facets, subfacets, etc. Statistics will need to be recalculated after subsetting to avoid confusion. The bracket operators can be alternatively, following the same syntax.
## S4 method for signature 'snpRdata,ANY,ANY,ANY'
x[i, j, ..., drop = FALSE]
subset_snpR_data(
x,
.snps = 1:nsnps(x),
.samps = 1:nsamps(x),
...,
.facets = NULL,
.subfacets = NULL,
.snp.facets = NULL,
.snp.subfacets = NULL
)
x |
snpRdata object. |
i |
numeric, default |
j |
numeric, default |
... |
Facet subsetting may be specified by providing the facet as an argument and then providing the levels to keep or remove. Setting pop = "ASP", for example, would keep only samples in the "ASP" level of the pop facet, and setting pop.fam = "ASP.A" would keep only samples the ASP pop and the A fam. Negative subscripts are allowed: pop = -c("ASP", "PAL") would remove samples in the ASP or PAL pops. Subsetting by multiple facets is supported, although negative and positive subscripts cannot be mixed across sample or SNP facets. They may be mixed between the two. |
drop |
logical, default FALSE. Deprecated. |
.snps |
numeric, default |
.samps |
numeric, default |
.facets |
Character, default NULL. Sample facet to select by. Alternative
to direct specification as in |
.subfacets |
Character, default NULL. Sample facet level matching a level
of the provided |
.snp.facets |
Character, default NULL. SNP facet to select by.
Alternative to direct specification as in |
.snp.subfacets |
Character, default NULL. SNP facet level matching a
level of the provided |
Sample and snp facets to subset over can be provided. Filtering by facet
categories is performed by naming the facet as an argument name, then
providing the levels to keep or remove to that argument. See examples. Facets
designated as described in Facets_in_snpR
.
x[i
: extraction operator
subset_snpR_data()
: subset_snpR_data
# Keep only individuals in the ASP and PAL populations
# and on the LGIX or LGIV chromosome.
subset_snpR_data(stickSNPs, pop = c("ASP", "PAL"),
chr = c("groupIX", "groupIV"))
# keep individuals/SNPs in the first 10 columns/rows.
subset_snpR_data(stickSNPs, 1:10, 1:10)
# negative subscripts: remove individuals in family B
subset_snpR_data(stickSNPs, fam = -"B")
# negative subscripts: remove individuals in pop PAL AND fam B or C,
# and keep only SNPs on LGIV
subset_snpR_data(stickSNPs, pop.fam = -c("PAL.B", "PAL.C"),
chr = "groupIV")
# using the bracket operator, same as example 1
stickSNPs[pop = c("ASP", "PAL"), chr = c("groupIX", "groupIV")]
# bracket operator, excluding first ten SNPs and only keeping pop = PAL,
# fam = B
stickSNPs[-c(1:10), pop.fam = c("PAL.B")]
# using the .facet etc arguments, useful when the facet is stored as an
# object
target_facet <- "pop"
target_subfacet <- "ASP"
subset_snpR_data(stickSNPs,
.facets = target_facet,
.subfacets = target_subfacet)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.