Skip to content

Instantly share code, notes, and snippets.

@sirusb
Created February 18, 2015 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirusb/a96f6da7f0053ce5e3ad to your computer and use it in GitHub Desktop.
Save sirusb/a96f6da7f0053ce5e3ad to your computer and use it in GitHub Desktop.
GRanges construction
# بعدة طرق GRanges يمكن انشاء
# مثلا يمكننا تحديد فقط المجالات الجينومية
gr <- GRanges(seqnames = c("chr1","chr1","chr2","chrX"),
ranges = IRanges(start = c(130,30050,4509,69098),
width= c(250,1300,400,590)),
strand = c("+","+","-","*"))
gr
#GRanges object with 4 ranges and 0 metadata columns:
# seqnames ranges strand
# <Rle> <IRanges> <Rle>
# [1] chr1 [ 130, 379] +
# [2] chr1 [30050, 31349] +
# [3] chr2 [ 4509, 4908] -
# [4] chrX [69098, 69687] *
# -------
# seqinfo: 3 sequences from an unspecified genome; no seqlengths
# mcols يمكن اظافة البيانات الوصفية باستعمال دالة
mcols(gr) <- DataFrame(score = runif(4))
gr
#GRanges object with 4 ranges and 1 metadata column:
# seqnames ranges strand | score
# <Rle> <IRanges> <Rle> | <numeric>
# [1] chr1 [ 130, 379] + | 0.779228801373392
# [2] chr1 [30050, 31349] + | 0.325288600986823
# [3] chr2 [ 4509, 4908] - | 0.609552363865077
# [4] chrX [69098, 69687] * | 0.229161157971248
# -------
# seqinfo: 3 sequences from an unspecified genome; no seqlengths
# او يمكننا اظافتها عند الانشاء, يمكن اعطاء اي اسم للحقول المضافة
gr <- GRanges(seqnames = c("chr1","chr1","chr2","chrX"),
ranges = IRanges(start = c(130,30050,4509,69098),
width= c(250,1300,400,590)),
strand = c("+","+","-","*"),
score = runif(4))
gr
#GRanges object with 4 ranges and 1 metadata column:
# seqnames ranges strand | score
# <Rle> <IRanges> <Rle> | <numeric>
# [1] chr1 [ 130, 379] + | 0.0297835641540587
# [2] chr1 [30050, 31349] + | 0.42395940516144
# [3] chr2 [ 4509, 4908] - | 0.112338428385556
# [4] chrX [69098, 69687] * | 0.800393168348819
# -------
# seqinfo: 3 sequences from an unspecified genome; no seqlengths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment