Sequence Ranges

Bioconductor เบื้องต้นใน R

Paula Andrea Martinez, PhD.

Data scientist

IRanges ด้วยอาร์กิวเมนต์ตัวเลข

# Loading IRanges
library(IRanges)

ช่วง (range) กำหนดด้วย start และ 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
Bioconductor เบื้องต้นใน 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

สมการ: width = end - start + 1

Bioconductor เบื้องต้นใน R

Rle - run length encoding

  • Rle ย่อมาจาก Run length encoding
  • คำนวณและจัดเก็บ lengths และ values ของเวกเตอร์หรือแฟกเตอร์
  • Rle คือ S4 container ทั่วไปสำหรับจัดเก็บเวกเตอร์ซ้ำยาวอย่างมีประสิทธิภาพ
(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
Bioconductor เบื้องต้นใน R

IRanges ด้วย logical vector

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
Bioconductor เบื้องต้นใน R

IRanges ด้วย logical 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
Bioconductor เบื้องต้นใน R

สรุป

IRanges เป็นโครงสร้างข้อมูลแบบลำดับชั้นที่รองรับ metadata

วิธีสร้างออบเจ็กต์ IRanges:

  • ระบุ start, end หรือ width เป็น numeric vector (หรือ NULL)
  • ระบุอาร์กิวเมนต์ start เป็น logical vector หรือ logical Rle object
    • Rle ย่อมาจาก Run length encoding และจัดเก็บข้อมูลได้อย่างมีประสิทธิภาพ
    • อาร์กิวเมนต์ของ IRanges รองรับการ recycle (เติมค่าที่ขาด)
    • สมการของ sequence range: width = end - start + 1
Bioconductor เบื้องต้นใน R

มาฝึกกันเถอะ!

Bioconductor เบื้องต้นใน R

Preparing Video For Download...