Sekvenční rozsahy

Úvod do Bioconductoru v R

Paula Andrea Martinez, PhD.

Data scientist

IRanges s číselnými argumenty

# Loading IRanges
library(IRanges)

Rozsah je definován hodnotami start a end

myIRanges <- IRanges(start = 20, end = 30)
myIRanges
IRanges object with 1 range and 0 metadata columns:
   start       end     width
<integer> <integer> <integer>
[1]   20        30        11
Úvod do Bioconductoru v R
(myIRanges_width <- IRanges(start = c(1, 20), width = c(30, 11)))
 IRanges object with 2 ranges and 0 metadata columns:
         start       end     width    
      <integer> <integer> <integer>
[1]         1        30        30       
[2]        20        30        11
(myIRanges_end <- IRanges(start = c(1, 20), end = 30))
 IRanges object with 2 ranges and 0 metadata columns:
         start       end     width    
      <integer> <integer> <integer>
[1]         1        30        30       
[2]        20        30        11

Rovnice: width = end - start + 1

Úvod do Bioconductoru v R

Rle – kódování délky běhu

  • Rle je zkratka pro kódování délky běhu (Run Length Encoding)
  • Vypočítá a uloží délky a hodnoty vektoru nebo faktoru
  • Rle je obecný kontejner S4 pro efektivní ukládání dlouhých opakujících se vektorů
(some_numbers <- c(3, 2, 2, 2, 3, 3, 4, 2))
3 2 2 2 3 3 4 2
(Rle(some_numbers))
numeric-Rle of length 8 with 5 runs
Lengths: 1 3 2 1 1
Values : 3 2 3 4 2
Úvod do Bioconductoru v R

IRanges s logickým vektorem

IRanges(start = c(FALSE, FALSE, TRUE, TRUE))
 IRanges object with 1 range and 0 metadata columns:
      start       end     width
  <integer> <integer> <integer>
[1]       3         4         2
Úvod do Bioconductoru v R

IRanges s logickým Rle

gi <- c(TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE)
myRle <- Rle(gi)
logical-Rle of length 7 with 3 runs
Lengths:     2     2     3
Values :  TRUE FALSE  TRUE
IRanges(start = myRle)
IRanges object with 2 ranges and 0 metadata columns:
         start       end     width
      <integer> <integer> <integer>
[1]         1         2         2
[2]         5         7         3
Úvod do Bioconductoru v R

Shrnutí

IRanges jsou hierarchické datové struktury, které mohou obsahovat metadata.

Konstrukce objektů IRanges:

  • start, end nebo width jako číselné vektory (nebo NULL).
  • Argument start jako logický vektor nebo objekt logického Rle.
    • Rle je zkratka pro kódování délky běhu (Run Length Encoding) – úsporné uložení dat.
    • Argumenty IRanges se recyklují (doplňují chybějící hodnoty).
    • Rovnice pro sekvenční rozsah: width = end - start + 1.
Úvod do Bioconductoru v R

Procvičte práci se sekvenčními rozsahy!

Úvod do Bioconductoru v R

Preparing Video For Download...