Lud*_*udo 2 r bioconductor iranges
我有一个GRanges对象,我想扩展所有范围,例如两侧1kb,因此每个范围将变为2kb.这很奇怪,但我无法使用inter-range-methodsGenomicRanges或IRanges 来做到这一点.产生所需结果的一种方法是使用两次调整大小,首先扩展5'然后再扩展3'.但这当然非常尴尬.有没有更直接的方式这样做?请指教
gr <- GRanges(c('chr1','chr1'), IRanges(start=c(20, 120), width=10), strand='+')
gr <- resize(gr, fix='start', width=width(gr)+10)
gr <- resize(gr, fix='end', width=width(gr)+10)
gr
Run Code Online (Sandbox Code Playgroud)
这很简单.你可以使用start和end功能GenomicRanges.
gr <- GRanges(c('chr1','chr1'), IRanges(start=c(20, 120), width=10), strand='+')
gr
# GRanges object with 2 ranges and 0 metadata columns:
# seqnames ranges strand
# <Rle> <IRanges> <Rle>
# [1] chr1 [ 20, 29] +
# [2] chr1 [120, 129] +
# -------
# seqinfo: 1 sequence from an unspecified genome; no seqlengths
start(gr) <- start(gr) - 10
end(gr) <- end(gr) + 10
gr
# GRanges object with 2 ranges and 0 metadata columns:
# seqnames ranges strand
# <Rle> <IRanges> <Rle>
# [1] chr1 [ 10, 39] +
# [2] chr1 [110, 139] +
# -------
# seqinfo: 1 sequence from an unspecified genome; no seqlengths
Run Code Online (Sandbox Code Playgroud)