sampleSequence: Sample nucleotides or motifs on a subset of genome defined by...

Description Usage Arguments Value Examples

View source: R/sampleSequence.R

Description

A function used to extract the regions of a query sequence mapped to user defined sub-regions of the genome.

Usage

1
2
3
4
5
6
7
8
sampleSequence(
  motif,
  region,
  sequence,
  N = NULL,
  fixed = FALSE,
  replace = FALSE
)

Arguments

motif

a character string indicating the query sequence or motifs; Rules in IUPAC_CODE_MAP is supported when Fixed = FALSE.

region

the GRanges object used to define the subset of the genome.

sequence

the BSgenome object containing the sequence of the genome.

N

number of ranges sampled, by default, it returns all the ranges without sampling.

fixed

FALSE to support the vague mapping rule of the chagracter string, default is FALSE.

replace

whether sample with replacement or not, default is FALSE.

Value

a GRanges object contains the (sampled) mapped regions of the query sequence on the defined subset of the genome.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Retrieve the sequence "CG" on a defined exonic region
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(BSgenome.Hsapiens.UCSC.hg19)
exons_gr <- GRanges(c("chr1","chr2","chr2"),
                    IRanges(start=c(11874,38814,45440),
                    end=c(12227,41627,46588)),
                    strand=c("+","-","-"))
CpG_regions <- sampleSequence("GG", exons_gr, Hsapiens)

## Not run: 
## Sample 100000 ranges of RRACH motif on all exonic regions of hg19:
exons_hg19 <- exons(TxDb.Hsapiens.UCSC.hg19.knownGene)
Motif_exons_hg19 <- sampleSequence("RRACH", exons_hg19, Hsapiens, N = 100000)

## End(Not run)

ZW-xjtlu/WhistleR documentation built on March 13, 2021, 10:50 a.m.