R: Remove Samples or Loci from an Object

deleteSamples {polysat} | R Documentation

## Remove Samples or Loci from an Object

### Description

These functions remove samples or loci from all relevant slots of an object.

### Usage

    deleteSamples(object, samples)
    deleteLoci(object, loci)

### Arguments

`object` | An object containing the dataset of interest. Generally an object of some subclass of `gendata`.
`samples` | A numerical or character vector of samples to be removed.
`loci` | A numerical or character vector of loci to be removed.

### Details

These are generic functions with methods for `genambig`, `genbinary`, and `gendata` objects. The methods for the subclasses remove samples or loci from the `@Genotypes` slot, then pass the object to the method for `gendata`, which removes samples or loci from the `@PopInfo`, `@Ploidies`, and/or `@Usatnts` slots, as appropriate. The `@PopNames` slot is left untouched even if an entire population is deleted, in order to preserve the connection between the numbers in `@PopInfo` and the names in `@PopNames`.

If your intent is to experiment with excluding samples or loci, it may be a better idea to create character vectors of samples and loci that you want to use and then use these vectors as the `samples` and `loci` arguments for analysis or export functions.

### Value

An object identical to `object`, but with the specified samples or loci removed.

### Note

These functions are somewhat redundant with the subscripting function `"["`, which also works for all `gendata` objects. However, they may be more convenient depending on whether the user prefers to specify the samples and loci to use or to exclude.

### Author(s)

Lindsay V. Clark

### See Also

`Samples`, `Loci`, `merge,gendata,gendata-method`

### Examples

    # set up genambig object
    mygen <- new("genambig", samples = c("ind1", "ind2", "ind3", "ind4"),
                 loci = c("locA", "locB", "locC", "locD"))

    # delete a sample
    Samples(mygen)
    mygen <- deleteSamples(mygen, "ind1")
    Samples(mygen)

    # delete some loci
    Loci(mygen)
    mygen <- deleteLoci(mygen, c("locB", "locC"))
    Loci(mygen)

[Package polysat version 1.7-6 Index]