Get startedGet started for free

Constructing IRanges

In the video, some IRanges constructor examples were provided. This is your turn to practice creating sequence ranges with different arguments and see how these arguments are reused or complemented.

Using the IRanges() function, you can specify parameters such as start, end, or width. These parameter inputs can fall into one of two categories:

  • start, end, and width are numeric vectors.
  • The start parameter is a logical vector.

Missing arguments will be resolved using the equation width = end - start + 1.

The IRanges() constructor indicates that all of the parameters are optional with default NULL:

IRanges(start = NULL, end = NULL, width = NULL, names = NULL)

This exercise is part of the course

Introduction to Bioconductor in R

View Course

Exercise instructions

Construct three IRanges objects with the following arguments:

  • IRnum1: A start equal to a vector of values 1 through 5 and end equal to 100.
  • IRnum2: An end equal to 100 and width equal to both 89 and 10.
  • IRlog1: start equal to Rle(c(F, T, T, T, F, T, T, T)).
  • Print the objects and see the results!

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Load IRanges package
library(___)

# IRnum1: start - vector 1 through 5, end - 100  
IRnum1 <- ___

# IRnum2: end - 100, width - 89 and 10
IRnum2 <- ___

# IRlog1: start = Rle(c(F, T, T, T, F, T, T, T)))
IRlog1 <- IRanges(___ = Rle(___))

# Print objects in a list
print(list(IRnum1 = IRnum1, IRnum2 = IRnum2, IRlog1 = IRlog1))
Edit and Run Code