range1 <- IRanges::RangesList(chr1 = IRanges::IRanges(c(1,2,3), c(5,2,8)))
## just ranges ##
## GRanges instance
gr <- GenomicData(range1, asRangedData = FALSE)
## with a genome (universe) ##
## GRanges instance
gr <- GenomicData(range1, genome = "hg18", asRangedData = FALSE)
genome(gr) ## "hg18"
## with some data ##
filter <- c(1L, 0L, 1L)
score <- c(10L, 2L, NA)
strand <- factor(c("+", NA, "-"), levels = levels(strand()))
## GRanges instance
gr <- GenomicData(range1[[1]], score, chrom = "chr1", genome = "hg18",
asRangedData = FALSE)
mcols(gr)[["score"]]
strand(gr) ## all '*'
gr <- GenomicData(range1[[1]], score, filt = filter, strand = strand,
chrom = "chr1", asRangedData = FALSE)
mcols(gr)[["filt"]]
strand(gr) ## equal to 'strand'
## coercion from data.frame ##
df <- as.data.frame(gr)
Run the code above in your browser using DataLab