# The "Genome_intervals" class
i <- new(
"Genome_intervals",
matrix(
c(1,2,
3,5,
4,6,
8,9
),
byrow = TRUE,
ncol = 2
),
closed = matrix(
c(
TRUE, FALSE,
TRUE, FALSE,
TRUE, TRUE,
TRUE, FALSE
),
byrow = TRUE,
ncol = 2
),
annotation = data.frame(
seq_name = factor(c("chr01","chr01", "chr02","chr02")),
inter_base = c(FALSE, FALSE, TRUE, TRUE)
)
)
colnames(i) <- c( "start", "end" )
# print
print(i)
# size (number of bases per interval)
size(i)
## convert to a data.frame
as(i,"data.frame")
## simpler way to construct a Genome_intervals object:
G <- GenomeIntervals(start=c(1,3,4,5,10,8), end=c(5,5,6,8,11,9),
chromosome=rep(c("chr2","chrX","chr1"), each=2),
leftOpen=rep(c(FALSE, FALSE, TRUE), 2))
show(G)
Run the code above in your browser using DataLab