subset_snpRdata: Subset snpRdata objects

[,snpRdata-methodR Documentation

Subset snpRdata objects

Description

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.

Usage

## S4 method for signature 'snpRdata'
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
)

Arguments

x

snpRdata object.

i

numeric, default 1:nrow(x). Row numbers corresponding to SNPs to keep. Negative subscripts allowed.

j

numeric, default 1:nrow(x). Row numbers corresponding to SNPs to keep. Negative subscripts allowed.

...

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 1:nrow(x). Row numbers corresponding to SNPs to keep. Negative subscripts allowed.

.samps

numeric, default 1:ncol(x). Column numbers corresponding to samples to keep. Negative subscripts allowed.

.facets

Character, default NULL. Sample facet to select by. Alternative to direct specification as in pop = "ASP".

.subfacets

Character, default NULL. Sample facet level matching a level of the provided .facets. Alternative to direct specification as in pop = "ASP".

.snp.facets

Character, default NULL. SNP facet to select by. Alternative to direct specification as in chr = "groupIX".

.snp.subfacets

Character, default NULL. SNP facet level matching a level of the provided .snp.facets. Alternative to direct specification as in chr = "groupIX".

Details

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.

Functions

  • [: extraction operator

  • subset_snpR_data(): subset_snpR_data

Examples

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

hemstrow/snpR documentation built on March 20, 2024, 7:03 a.m.