filterChromosomes {regioneR} | R Documentation

## filterChromosomes

### Description

Filters the chromosomes in a region set. It can either filter using a predefined chromosome set (e.g. "autosomal chromosomes in Homo sapiens") or using a custom chromosome set (e.g. only chromosomes "chr22" and "chrX")

### Usage

    filterChromosomes(A, organism="hg", chr.type="canonical", keep.chr=NULL)

### Arguments

`A` | a region set in any of the formats accepted by `toGRanges` (`GenomicRanges`, `data.frame`, etc...)
`organism` | a character indicating the organism from which to get the predefined chromosome sets. It can be the organism code as used in `BSgenome` (e.g. hg for human, mm for mouse...) or the full genome assembly identifier, since any digit will be removed to get the organism code.
`chr.type` | a character indicating the specific chromosome set to be used. Usually "autosomal" or "canonical", althought other values could be available for certain organisms.
`keep.chr` | is a character vector stating the names of the chromosomes to keep. Any chromosome not in the vector will be filtered out. If keep.chr is supplied, organism and chr.type are ignored.

### Value

A `GRanges` object containing only the regions in the original region set belonging to the selected chromosomes. All regions in non selected chromosomes are removed.

### See Also

`getGenomeAndMask`, `listChrTypes` `getChromosomesByOrganism`

### Examples

    g <- getGenomeAndMask("hg19")$genome
    listChrTypes()
    g <- filterChromosomes(g, chr.type="autosomal", organism="hg19")
    g <- filterChromosomes(g, keep.chr=c("chr1", "chr2", "chr3"))

[Package regioneR version 1.22.0 Index]