df <- data.frame(
chrom = c("chr1", "chr1", "chr2"),
start = c(100L, 500L, 200L),
end = c(200L, 700L, 400L),
t1 = c(1.5, 2.5, 3.5),
t2 = c(10, 20, 30)
)
mat <- gintervals.to_mat(df)
rownames(mat)
# subset preserves intervals:
sub <- mat[c(1, 3), ]
attr(sub, "intervals")
# round-trip back to a data.frame:
gintervals.from_mat(sub)
Run the code above in your browser using DataLab